Pact java libraries are incompatible with java 9+ modules
See original GitHub issueWe are attempting to utilize Pact in a project which is based on java11 (java 11, gradle 6, JUnit 5 + Jupiter) and utilizes some a jigsaw module which is only within java 11 (requires java.net.http
), and unfortunately we are stuck.
Upon further investigation (here is a useful article on DZone), it appears that the MANIFEST.MF for all of the java pact libraries includes an explicit entry to define an ‘Automatic-Module-Name’ per the following code:
See an example offending line of code in build.gradle currently in master on line 110:
'Automatic-Module-Name': project.group + "." + project.name
The problem is that the project.name includes hyphens, which are not allowed to be in java module names. Thus, whenever you try to include any of these Pact jars within a project which is built with Java 9 or higher, it fails.
A quick way to validate this problem is to execute the following command on any of the Pact library jars (see example command/output):
$ jar --describe-module --file=./pact-jvm-consumer-junit5-4.0.8.jar
Unable to derive module descriptor for: .\pact-jvm-consumer-junit5-4.0.8.jar
Automatic-Module-Name: au.com.dius.pact-jvm-consumer-junit5: Invalid module name: 'pact-jvm-consumer-junit5' is not a Java identifier
A potential quick fix (before actually creating module-info.java descriptors for these libraries) could be to stop explicitly including the invalid ‘Automatic-Module-Name’ within the builds for these jars. I have not attempted to build any of the Pact libraries myself using Java 9+, however if I manually remove that ‘Automatic-Module-Name’ line from the embedded generated manifest file in the above jar, it stops complaining:
$ jar --describe-module --file=./pact-jvm-consumer-junit5-4.0.8.jar
No module descriptor found. Derived automatic module.
au.com.dius.pactjvmconsumerjunit5@4.0.8 automatic
requires java.base mandated
contains au.com.dius.pact.consumer.junit5
If anyone has some thoughts on a work-around for utilizing Pact to test project which must be built with Java 9 or higher, I would welcome the thoughts
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Version 4.0.9 released.
But I think all the modules and dependencies of this project need to be re-visited, but that would have to be for 4.1.x