Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make picocli-codegen an explicitly declared named JPMS module #1599

Closed
remkop opened this issue Feb 24, 2022 · 0 comments
Closed

Make picocli-codegen an explicitly declared named JPMS module #1599

remkop opened this issue Feb 24, 2022 · 0 comments
Labels
theme: build An issue or change related to the build system theme: module An issue or change related to JPMS modules type: API 🔌
Milestone

Comments

@remkop
Copy link
Owner

remkop commented Feb 24, 2022

It should be possible to make the picocli-codegen artifact a full-blown named Java 9 JPMS module, since this subproject has no dependencies other than the picocli artifact.

// module-info.java
module info.picocli.codegen {
    requires info.picocli;
    requires java.base;
    requires java.compiler;
    requires java.logging;

    exports picocli.codegen.annotation.processing;
    exports picocli.codegen.aot.graalvm;
    exports picocli.codegen.aot.graalvm.processor;
    exports picocli.codegen.docgen.manpage;
}

What makes this tricky is that we need to build the picocli project with Java 8 in order to get Java 5 bytecode for the main picocli.jar artifact. We cannot use Java 9, because from Java 9 onwards the javac tool no longer supports -source 1.5 and -target 1.5 (the minimum becomes 1.6, and from Java 11 the minimum is 1.7).

To compile the module-info.java files with Java 8, we use the https://github.com/beryx/badass-jar-plugin Gradle plugin.

There was some issue with beryx/badass-jar 1.2.0 that meant building a modular picocli jar worked, but a modular picocli-codegen jar failed. It looks like the new 2.0.0 version does not have that problem.

Result:

> %JAVA_11_HOME%\bin\jar -v -d  -f C:\Users\remko\IdeaProjects\picocli3\picocli-codegen\build\libs\picocli-codegen-4.7.0-SNAPSHOT.jar --release 9
releases: 9

[email protected] jar:file:///C:/Users/remko/IdeaProjects/picocli3/picocli-codegen/build/libs/picocli-codegen-4.7.0-SNAPSHOT.jar/!META-INF/versions/9/module-info.class
exports picocli.codegen.annotation.processing
exports picocli.codegen.aot.graalvm
exports picocli.codegen.aot.graalvm.processor
exports picocli.codegen.docgen.manpage
requires info.picocli
requires java.base mandated
requires java.compiler
requires java.logging
> %JAVA_11_HOME%\bin\jar -v -d  -f C:\Users\remko\IdeaProjects\picocli3\build\libs\picocli-4.7.0-SNAPSHOT.jar --release 9
releases: 9

[email protected] jar:file:///C:/Users/remko/IdeaProjects/picocli3/build/libs/picocli-4.7.0-SNAPSHOT.jar/!META-INF/versions/9/module-info.class
exports picocli
requires java.base mandated

This is part of an effort to generate modular javadoc (#1298).

@remkop remkop added status: in-progress 👷‍♂️ theme: module An issue or change related to JPMS modules theme: build An issue or change related to the build system labels Feb 24, 2022
@remkop remkop added this to the 4.7 milestone Feb 24, 2022
@remkop remkop closed this as completed in 7a20f0f Feb 24, 2022
@remkop remkop changed the title Make picocli-codegen a named JPMS module Make picocli-codegen an explicitly declared named JPMS module Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: build An issue or change related to the build system theme: module An issue or change related to JPMS modules type: API 🔌
Projects
None yet
Development

No branches or pull requests

1 participant