Reputation: 287740
I've configured ModiTect to generate module-info.java
s for all my dependencies (that don't have them) and that seems to be working; but when it comes to dependencies that do have them, it's not finding them. For my own jars, I'm writing the module-info.java
by hand.
When I run mvn package
in my app it's failing with:
Error: Module tech.flexpoint.dashmancommon not found, required by tech.flexpoint.dashmanserver
The command line looks like this:
C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\classes --output C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image --launcher dashmanserver=tech.flexpoint.dashmanserver
I know tech.flexpoint.dashmancommon
is a module and has a module-info.java
because I built it myself. How do I make ModiTect/jlink find all the dependent modules in their original jars?
My under-construction ModiTect config looks like this:
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Beta1</version>
<executions>
<execution>
<id>add-module-info-to-dependencies</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/modules</outputDirectory>
<overwriteExistingFiles>true</overwriteExistingFiles>
<modules>
<module>
<artifact>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</artifact>
<moduleInfoSource>
module bcprov.jdk15on {
}
</moduleInfoSource>
</module> <!-- bcprov.jdk15on -->
<module>
<artifact>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</artifact>
<moduleInfoSource>
module com.fasterxml.jackson.core {
}
</moduleInfoSource>
</module> <!-- com.fasterxml.jackson.core -->
<module>
<artifact>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</artifact>
<moduleInfoSource>
module com.fasterxml.jackson.databind {
}
</moduleInfoSource>
</module> <!-- com.fasterxml.jackson.databind -->
<module>
<artifact>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</artifact>
<moduleInfoSource>
module hibernate.core {
}
</moduleInfoSource>
</module> <!-- hibernate.core -->
<module>
<artifact>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
</artifact>
<moduleInfoSource>
module io.sentry {
}
</moduleInfoSource>
</module> <!-- io.sentry -->
<module>
<artifact>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</artifact>
<moduleInfoSource>
module java.persistence {
}
</moduleInfoSource>
</module> <!-- java.persistence -->
<module>
<artifact>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</artifact>
<moduleInfoSource>
module java.validation {
}
</moduleInfoSource>
</module> <!-- java.validation -->
<module>
<artifact>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</artifact>
<moduleInfoSource>
module org.apache.commons.lang3 {
}
</moduleInfoSource>
</module> <!-- org.apache.commons.lang3 -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</artifact>
<moduleInfoSource>
module spring.core {
}
</moduleInfoSource>
</module> <!-- spring.core -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</artifact>
<moduleInfoSource>
module spring.web {
}
</moduleInfoSource>
</module> <!-- spring.web -->
<module>
<artifact>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</artifact>
<moduleInfoSource>
module spring.boot {
}
</moduleInfoSource>
</module> <!-- spring.boot -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</artifact>
<moduleInfoSource>
module spring.context {
}
</moduleInfoSource>
</module> <!-- spring.context -->
<module>
<artifact>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</artifact>
<moduleInfoSource>
module spring.data.commons {
}
</moduleInfoSource>
</module> <!-- spring.data.commons -->
<module>
<artifact>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</artifact>
<moduleInfoSource>
module spring.data.jpa {
}
</moduleInfoSource>
</module> <!-- spring.data.jpa -->
<module>
<artifact>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</artifact>
<moduleInfoSource>
module spring.security.core {
}
</moduleInfoSource>
</module> <!-- spring.security.core -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</artifact>
<moduleInfoSource>
module spring.tx {
}
</moduleInfoSource>
</module> <!-- spring.tx -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</artifact>
<moduleInfoSource>
module spring.webmvc {
}
</moduleInfoSource>
</module> <!-- spring.webmvc -->
<module>
<artifact>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</artifact>
<moduleInfoSource>
module tomcat.embed.core {
}
</moduleInfoSource>
</module> <!-- tomcat.embed.core -->
</modules>
</configuration>
</execution>
<execution>
<id>create-runtime-image</id>
<phase>package</phase>
<goals>
<goal>create-runtime-image</goal>
</goals>
<configuration>
<modulePath>
<path>${project.build.directory}/classes</path>
<path>${project.build.directory}/modules</path>
</modulePath>
<modules>
<module>tech.flexpoint.dashmanserver</module>
</modules>
<launcher>
<name>dashmanserver</name>
<module>tech.flexpoint.dashmanserver</module>
</launcher>
<outputDirectory>
${project.build.directory}/jlink-image
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
If I add
<path>c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11</path>
to my ModiTect config, it starts working, generating this command line:
C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\classes --output C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image --launcher dashmanserver=tech.flexpoint.dashmanserver
I guess this confirms the module works and it's installed. I'm just not sure how to make ModiTect find it (without a horrible hard-coded path).
Upvotes: 9
Views: 1350
Reputation: 5526
I think your issue corresponds to this known issue with moditect.
Generating a module-path from the subset of maven dependencies that happen to already be modules is not currently supported. The workaround is to use the maven-dependency plugin to copy them to a known directory which can be added to the module path.
Upvotes: 0