Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand All @@ -28,6 +47,27 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Final</version>
<executions>
<execution>
<id>add-module-info</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<jvmVersion>9</jvmVersion>
<module>
<moduleInfoFile>${project.build.sourceDirectory}/module-info.java</moduleInfoFile>
</module>
<overwriteExistingFiles>true</overwriteExistingFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module prettytime {
exports org.ocpsoft.prettytime;
exports org.ocpsoft.prettytime.format;
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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is this provides declaration for? At first glance it doesn't seem like that class is relevant to the service loader?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nope, I found where in the code it came from

https://github.com/ocpsoft/prettytime/blob/master/core/src/main/resources/META-INF/services/org.ocpsoft.prettytime.PrettyTime

So it does seem like that is legitimate (if a bit strange)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

@webracer999 webracer999 Aug 10, 2023

Choose a reason for hiding this comment

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

As long as there is a defined service I think it is correct to add it to the module-info.java.

}