-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java] move the module-info.class to the correct place
- Loading branch information
Showing
1 changed file
with
3 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import static net.bytebuddy.jar.asm.Opcodes.ACC_STATIC_PHASE; | ||
import static net.bytebuddy.jar.asm.Opcodes.ACC_TRANSITIVE; | ||
import static net.bytebuddy.jar.asm.Opcodes.ASM9; | ||
import static net.bytebuddy.jar.asm.Opcodes.V11; | ||
|
||
import com.github.bazelbuild.rules_jvm_external.zip.StableZipEntry; | ||
import com.github.javaparser.JavaParser; | ||
|
@@ -319,9 +320,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { | |
exportedPackages.stream().map(Name::new).collect(Collectors.toSet()))))); | ||
|
||
ClassWriter classWriter = new ClassWriter(0); | ||
classWriter.visit( | ||
/* version 9 */ | ||
53, ACC_MODULE, "module-info", null, null, null); | ||
classWriter.visit(V11, ACC_MODULE, "module-info", null, null, null); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
ModuleVisitor moduleVisitor = classWriter.visitModule(moduleName, isOpen ? ACC_OPEN : 0, null); | ||
moduleVisitor.visitRequire("java.base", ACC_MANDATED, null); | ||
|
||
|
@@ -334,24 +333,14 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { | |
|
||
Manifest manifest = new Manifest(); | ||
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); | ||
manifest.getMainAttributes().put(Attributes.Name.MULTI_RELEASE, "true"); | ||
This comment has been minimized.
Sorry, something went wrong.
joerg1985
Author
Member
|
||
|
||
try (OutputStream os = Files.newOutputStream(outJar); | ||
JarOutputStream jos = new JarOutputStream(os, manifest)) { | ||
jos.setLevel(ZipOutputStream.STORED); | ||
|
||
ZipEntry dir = new StableZipEntry("META-INF/"); | ||
jos.putNextEntry(dir); | ||
|
||
dir = new StableZipEntry("META-INF/versions/"); | ||
jos.putNextEntry(dir); | ||
|
||
dir = new StableZipEntry("META-INF/versions/9/"); | ||
jos.putNextEntry(dir); | ||
|
||
byte[] bytes = classWriter.toByteArray(); | ||
|
||
ZipEntry entry = new StableZipEntry("META-INF/versions/9/module-info.class"); | ||
ZipEntry entry = new StableZipEntry("module-info.class"); | ||
This comment has been minimized.
Sorry, something went wrong.
joerg1985
Author
Member
|
||
entry.setSize(bytes.length); | ||
|
||
jos.putNextEntry(entry); | ||
|
As the released jar's minimum java version is 11 we can set the version here to 11.