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

Adds explicit module descriptors to a subset of modules #1943

Merged
merged 1 commit into from Feb 20, 2023

Conversation

aalmiray
Copy link
Contributor

Applies the ModiTect Maven plugin to a select number of Maven modules.
Exports all packages by default as that's the current behavior when Automatic module names are in place.
Fine grained control of exported packages may be added at a later stage.

Fixes #1357

@aalmiray
Copy link
Contributor Author

cc @velo

Copy link
Member

@velo velo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we could test the chance?

jaxrs2/pom.xml Outdated Show resolved Hide resolved
@aalmiray
Copy link
Contributor Author

Is there any way we could test the chance?

We'd have to add at least one more Maven module that runs tests in the module path.

@velo
Copy link
Member

velo commented Feb 20, 2023

We'd have to add at least one more Maven module that runs tests in the module path.

Is that something you can do? My concern would be a future change breaking it

But if you can't do I can merge as is

@aalmiray
Copy link
Contributor Author

Is that something you can do? My concern would be a future change breaking it

I think I can make it happen but it'll take me a bit longer to figure it out.

But if you can't do I can merge as is

Given that the current module configuration exports everything by default (just like automatic modules do at the moment) there should not be much of a problem. With time this configuration may be refined to export only those packages that really must be visible to the exterior.

@velo velo merged commit bac0dd4 into OpenFeign:master Feb 20, 2023
@aalmiray aalmiray deleted the java-modules branch February 20, 2023 17:53
velo added a commit that referenced this pull request Feb 20, 2023
@velo
Copy link
Member

velo commented Feb 20, 2023

Will need to revert this change

[ERROR] Failed to execute goal org.moditect:moditect-maven-plugin:1.0.0.RC2:add-module-info (add-module-infos) on project feign-core: Execution add-module-infos of goal org.moditect:moditect-maven-plugin:1.0.0.RC2:add-module-info failed: A required class was missing while executing org.moditect:moditect-maven-plugin:1.0.0.RC2:add-module-info: java/lang/module/FindException
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.moditect:moditect-maven-plugin:1.0.0.RC2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/circleci/.m2/repository/org/moditect/moditect-maven-plugin/1.0.0.RC2/moditect-maven-plugin-1.0.0.RC2.jar
[ERROR] urls[1] = file:/home/circleci/.m2/repository/org/eclipse/aether/aether-util/1.1.0/aether-util-1.1.0.jar
[ERROR] urls[2] = file:/home/circleci/.m2/repository/org/moditect/moditect/1.0.0.RC2/moditect-1.0.0.RC2.jar
[ERROR] urls[3] = file:/home/circleci/.m2/repository/com/beust/jcommander/1.60/jcommander-1.60.jar
[ERROR] urls[4] = file:/home/circleci/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[project>io.github.openfeign:parent:12.2-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] : java.lang.module.FindException
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :feign-core


Exited with code exit status 1

CircleCI received exit code 1

@aalmiray
Copy link
Contributor Author

aalmiray commented Feb 20, 2023

Is circleci running the build with the wrapper? I think this might be an issue with incompatible (read: too old) Maven version.

velo added a commit that referenced this pull request Feb 20, 2023
@aalmiray
Copy link
Contributor Author

aalmiray commented Feb 20, 2023

I think I've got it. It's not the Maven version but the chosen JDK. The clue is in the exception

A required class was missing while executing org.moditect:moditect-maven-plugin:1.0.0.RC2:add-module-info: java/lang/module/FindException

The build requires [at least] Java 9 to run. Better set it to Java 11.

The update would have to happen here

java:
parameters:
version:
description: 'jdk version to use'
default: '8.0'
type: string
docker:
- image: cimg/openjdk:<<parameters.version>>

@velo
Copy link
Member

velo commented Feb 20, 2023

That is a problem, feign is java 8 compatible

@velo
Copy link
Member

velo commented Feb 20, 2023

BTW, we had this discussion a while back, both me and @kdavisk6 are happy to move build process and testing to java 11, 17, 20, whatever, as long we can keep sources/jars java 8 compatible.... if you keen to give that a shot

@aalmiray
Copy link
Contributor Author

aalmiray commented Feb 20, 2023

Yes, but you can target Java 8 bytecode even if the build uses Java 11. This is also why ModiTect is used in the PR, so that the codebase remains Java 8 compatible. Set maven.compiler.source and maven.compiler.target properties to 1.8 at the root pom and all compiled classes should have bytecode 52.

@aalmiray
Copy link
Contributor Author

Added back module-info support plus additional configuration to run Java8/Java11 on CI. #1948

@velo
Copy link
Member

velo commented Feb 20, 2023

and all compiled classes should have bytecode 52.

should is the tricky part here.

and still, maven would build with jdk X classpath, so it would allow me to invoke method/classes that don't exist for java 8

@aalmiray
Copy link
Contributor Author

Should? Yes. And verifiable. This is what I get when running the build with Java 11

$ jarviz bytecode show --file core/target/feign-core-12.2-SNAPSHOT.jar 
Unversioned classes. Bytecode version: 52 total: 156
Unversioned classes. Bytecode version: 53 total: 1

Besides, isn't animal-sniffer configured so that methods from Java 9+ are inaccessible? Also, running the build with Java 11 does not preclude you from configuring the IDE to use a lower Java setting. For example Intellij IDEA let's you configure the level in the project settings. I"m sure the other IDEs do so as well. that takes care of the problem when a developer might try to use java 9+ syntax/features. Animal sniffer OTOH can verify that at the build level regardless of the JDK used to run the build.

velo added a commit that referenced this pull request Feb 26, 2023
* Adds explicit module descriptors to a subset of modules (#1943)

Fixes #1357

* Configure CI to run with Java 11

* Configure moditect for all modules, enable only on those that required it

* Do not skip moditect when running tests

* Only skip modules that don't work with moditect plugin

---------

Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
Co-authored-by: Marvin Froeder <velobr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add module descriptor
2 participants