Использование ModiTect для генерации информации о модуле и создания образа среды выполнения
Однако попытался использовать JLink для создания образа времени выполнения:
Error: automatic module cannot be used with JLink: graphviz.java
Я использую следующую библиотеку, в которой есть только автоматические модули.
Сделал несколько поисков, и кажется, что я могу использовать ModiTect для генерации информации о модуле для библиотеки и создания образа во время выполнения.
Однако, поскольку я новичок в модулях, я не мог этого понять. Думаю, мне понадобится более подробное объяснение, чем то, что я мог найти на странице ModiTect GitHub.
мои модули-info.java:
module elitonlais {
requires javafx.controls;
requires javafx.fxml;
requires graphviz.java;
opens elitonlais to javafx.fxml;
opens elitonlais.controller to javafx.fxml;
opens elitonlais.model to javafx.fxml;
exports elitonlais;
exports elitonlais.controller;
exports elitonlais.model;
}
Мой файл pom:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>elitonlais</groupId>
<artifactId>minafd</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>guru.nidi</groupId>
<artifactId>graphviz-java</artifactId>
<version>0.17.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>elitonlais.App</mainClass>
<launcher>launch.sh</launcher>
<compress>2</compress>
<jlinkZipName>MinAFD</jlinkZipName>
<jlinkImageName>MinAFD</jlinkImageName>
<includePathExceptionsInClasspath>true</includePathExceptionsInClasspath>
</configuration>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Beta2</version>
<executions>
<execution>
<id>create-runtime-image</id>
<phase>package</phase>
<goals>
<goal>create-runtime-image</goal>
</goals>
<configuration>
<modulePath>
<path>${project.build.directory}/modules</path>
</modulePath>
<modules>
<module>module-info.java</module>
<!-- <module>javafx.controls</module>
<module>javafx.graphics</module> -->
</modules>
<launcher>
<name>test33</name>
<module>module-info.java/elitonlais.app</module>
</launcher>
<compression>2</compression>
<stripDebug>true</stripDebug>
<outputDirectory>${project.build.directory}/jlink-image</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Вся структура проекта:https://github.com/EMachad0/MinAFD
1 ответ
Вы сможете добавить его, следуя документации по ссылке Добавление дескрипторов модуля к существующим файлам JAR.
Добавление следующего к существующим pom.xml
как дополнительный <execution>
шаг для ModiTect должен работать:
<executions>
<execution>
<!-- your existing code here -->
</execution>
<execution>
<id>add-module-infos</id>
<phase>generate-resources</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/modules</outputDirectory>
<modules>
<module>
<artifact>
<groupId>guru.nidi</groupId>
<artifactId>graphviz-java</artifactId>
<version>0.17.0</version>
</artifact>
<!-- only use one of either moduleInfo or moduleInfoSource -->
<moduleInfo>
<name>guru.nidi.graphviz</name>
<exports>
*;
</exports>
<!-- possibly other fine-tuning -->
</moduleInfo>
<!-- only use one of either moduleInfo or moduleInfoSource -->
<moduleInfoSource>
module guru.nidi.graphviz {
requires ...;
exports ...;
provides ...
with ...;
}
</moduleInfoSource>
<!-- or use moduleInfoFile instead of the above -->
</module>
<module>
...
</module>
</modules>
</configuration>
</execution>
</executions>
Также обратите внимание, что в проекте указано автоматическое имя модуля guru.nidi.graphviz
так что вам нужно изменить свой собственный module-info
требовать этого, а не автоматически graphviz.java
.