[英]ModiTect and Jlink not finding module dependencies
我已將ModiTect配置為為我的所有依賴項(沒有它們)生成module-info.java
,並且這似乎有效; 但是當涉及到確實有它們的依賴項時,它沒有找到它們。 對於我自己的 jar,我正在手工編寫module-info.java
。
當我在我的應用mvn package
中運行mvn package
,它失敗了:
Error: Module tech.flexpoint.dashmancommon not found, required by tech.flexpoint.dashmanserver
命令行如下所示:
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
我知道tech.flexpoint.dashmancommon
是一個模塊並且有一個module-info.java
因為我自己構建了它。 如何讓 ModiTect/jlink 在原始 jars 中找到所有依賴模塊?
我在建的ModiTect 配置如下所示:
<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>
如果我添加
<path>c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11</path>
到我的 ModiTect 配置,它開始工作,生成這個命令行:
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
我想這證實了模塊可以工作並且已經安裝。 我只是不確定如何讓 ModiTect 找到它(沒有可怕的硬編碼路徑)。
我認為您的問題與 moditect 的這個已知問題相對應。
當前不支持從碰巧已經是模塊的 maven 依賴項的子集生成模塊路徑。 解決方法是使用 maven-dependency 插件將它們復制到可以添加到模塊路徑的已知目錄中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.