Create MRJAR with module-info.class#263
Conversation
| exports org.ocpsoft.prettytime.i18n; | ||
| exports org.ocpsoft.prettytime.impl; | ||
| exports org.ocpsoft.prettytime.units; | ||
| provides org.ocpsoft.prettytime.PrettyTime with org.ocpsoft.prettytime.PrettyTime; |
There was a problem hiding this comment.
What is this provides declaration for? At first glance it doesn't seem like that class is relevant to the service loader?
There was a problem hiding this comment.
Thank you @bowbahdoe for your feedback!
Sorry, I forgot to mention how I created the module-info.java.
As a workaround for my project I found out that moditect can generate and inject module-info to dependencies.
I used in my project the following configuration in my pom.xml under <project> -> <build> -> <plugins>:
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Final</version>
<executions>
<execution>
<id>add-module-infos</id>
<phase>generate-resources</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<overwriteExistingFiles>true</overwriteExistingFiles>
<modules>
<module>
<artifact>
<groupId>org.ocpsoft.prettytime</groupId>
<artifactId>prettytime</artifactId>
<version>5.0.7.Final</version>
</artifact>
<moduleInfo>
<name>prettytime</name>
</moduleInfo>
</module>
</modules>
</configuration>
</execution>
</executions>
</plugin>In the PR I used the generated module-info.java. To be honest, I was and I am not sure what the provides really does.
At least the BasicJavaApp.java from https://www.ocpsoft.org/prettytime/ would also work without provides.
Do you think it is safe to delete it?
There was a problem hiding this comment.
Nope, I found where in the code it came from
So it does seem like that is legitimate (if a bit strange)
There was a problem hiding this comment.
Yeah, I can't remember exactly why that service file was added. It may be simply so that PrettyTime can be loaded via a ServiceLoader, but... I can't honestly recall.
There was a problem hiding this comment.
As long as there is a defined service I think it is correct to add it to the module-info.java.
|
I have changed the module name to reverse DNS. |
|
I think there is nothing stopping this from being merged |
b3f94df to
bbc0c21
Compare
PR to issue #262
This creates a "Multi-Release JAR" (MRJAR). The generated jar works with Java 1.8 and Java >= 9.
For Java >= 9 a
module-info.classis provided (META-INF/versions/9/module-info.class). This allows the usage ofjlink-tool to generate custom java runtime image.