9

我已经将ModiTectmodule-info.java配置为为我的所有依赖项(没有它们)生成s 并且这似乎有效;但是当涉及到确实拥有它们的依赖项时,它并没有找到它们。对于我自己的罐子,我正在手写module-info.java

当我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 在其原始 jar 中找到所有依赖模块?

正在建设的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 找到它(没有可怕的硬编码路径)。

4

1 回答 1

0

我认为您的问题对应于moditect的这个已知问题。

当前不支持从碰巧已经是模块的 maven 依赖项子集生成模块路径。解决方法是使用 maven-dependency 插件将它们复制到可以添加到模块路径的已知目录中。

于 2020-08-19T09:05:26.890 回答