[英]Maven javafx:jlink. How to specifiy the module-path used?
我目前正在开发模块化 JavaFX 应用程序,我正在使用 maven 来编译/部署它。
我的应用程序的依赖项之一是 JBibTex,它没有module-info
文件,因此它被用作自动模块。 为了让我的javafx:jlink
工作(因为javafx:jlink
不能在自动模块上工作),我必须将 JBibTex 转换为显式模块。 为此,我使用了 maven 的ModiTect插件。
我使用ModiTect 为JBibTex 库生成module-info
文件,并将它添加到JBibTex 的jar 文件中(为此我使用moditect:add-module-infos
)。
现在的问题是javafx:jlink
jlink 使用位于我的“.m2”文件夹中的 JBibTex.jar 文件(maven 自动下载所有项目的依赖项)。 位于 my.m2 文件夹中的 JBibTex.jar 文件不是我添加模块信息文件的文件。
所以我仍然得到错误:
错误:自动模块不能与 jlink 一起使用:jbibtex
我通过使用 ModiTect 生成的显式 JBibtex 模块由我的 ModiTect 插件配置自动放入target/modules
中。
How can I get javafx:jlink
to use the target/modules/JBibTex.jar
file that contains the module-info.class file and not the JBibTex.jar of my.m2 folder?
这是我的 pom.xml 以防万一:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xxx</groupId>
<artifactId>BRM</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>BRM</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<mainClass>xxx.App</mainClass>
<moduleName>xxx.brm</moduleName>
<javafx.version>17.0.1</javafx.version>
<javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
</properties>
<dependencies>
<!-- javafx dependencies -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jbibtex/jbibtex -->
<dependency>
<groupId>org.jbibtex</groupId>
<artifactId>jbibtex</artifactId>
<version>1.0.17</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>configs</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.maven.plugin.version}</version>
<configuration>
<mainClass>${mainClass}</mainClass>
<launcher>launcher</launcher>
<jlinkImageName>BRM</jlinkImageName>
</configuration>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.RC2</version>
<executions>
<execution>
<id>add-module-infos</id>
<phase>generate-resources</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<overwriteExistingFiles>true</overwriteExistingFiles>
<outputDirectory>${project.build.directory}/modules</outputDirectory>
<modules>
<module>
<artifact>
<groupId>org.jbibtex</groupId>
<artifactId>jbibtex</artifactId>
<version>1.0.17</version>
</artifact>
<moduleInfoSource>
module jbibtex
{
exports org.jbibtex;
}
</moduleInfoSource>
</module>
</modules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
这里有一些选项。
Package 您的应用程序作为使用 jpackage 的非模块化应用程序
我认为 mipa 建议使用 JPackageScriptFX 可能是最好的方法:
从二进制文件创建一个新的 jar
然后,我相信你已经完成了,它会构建、链接和运行正常。
从源代码创建一个新的 jar
jbibtex 库也在github中,因此您可以在项目上创建问题或拉取请求以要求将其模块化。
此外,您还可以:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.