0

I'm writing an application that uses the JavaFX library and the JBibTex library.

I'm also using Maven in my project to be able to package my application in a .jar. Using the javafx-maven-plugin, the command one has to use to package the application is mvn javafx:jlink.

The issue now is that javafx:jlink only supports explicit modules. JBibTex isn't an explicit module so it yields the following error:

Error: automatic module cannot be used with jlink: jbibtex

I've then come accross the ModiTect maven plugin during my searches which sounded promising. So I've set my pom.xml up like so:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>15</maven.compiler.source>
    <maven.compiler.target>15</maven.compiler.target>
    
    <mainClass>project.view.App</mainClass>
    <moduleName>project.brm</moduleName>
    
    <javafx.version>17.0.1</javafx.version>
    <javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
</properties>


<dependencies>
<!-- javafx dependancies-->
    <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>
                </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>package</phase>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                        <configuration>
                            <jvmVersion>15</jvmVersion>
                            <module>
                                <moduleInfo>
                                    <name>org.jbibtex</name>
                                    <exports>
                                        *;
                                    </exports>
                                </moduleInfo>
                            </module>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

If I then run the mvn clean install command, i get the error:

Error: myProject-0.0.1-SNAPSHOT.jar is a modular JAR file that cannot be specified with the --generate-module-info option which is caused by the add-module-infos goal.

What is wrong with my setup? Why cannot ModiTect add the module-info of JBibTex to my .jar (if that's actually what it's doing)?

4

0 回答 0