Search code examples
javamavenintellij-ideajavafxjava-platform-module-system

Version combination (Maven / Log4J in Java 9 Jigsaw project)


I am trying to get a very simple JavaFX application to run with maven and Java 10 in IntelliJ.

The project: https://github.com/ClanWolf/C3-Client_Phoenix

The structure:

enter image description here

The module-info.java:

module net.clanwolf.c3.client {
    requires javafx.graphics;
    requires javafx.fxml;
    requires javafx.controls;
    requires javafx.base;
    requires org.apache.logging.log4j;
    exports net.clanwolf.c3.client;
}

The pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>net.clanwolf.c3</groupId>
    <artifactId>C3-Client_Phoenix</artifactId>
    <version>4.6.2</version>
    <packaging>jar</packaging>

    <name>C3-Client Phoenix</name>
    <url>http://c3.clanwolf.net</url>

    <organization>
        <name>ClanWolf W-7</name>
        <url>http://www.clanwolf.net</url>
    </organization>

    <description>Starsystem map of the Inner Sphere, Periphery and Clan space (BattleTech).</description>

    <prerequisites>
        <maven>3.5.3</maven>
        <!--<maven>3.3.9</maven>-->
    </prerequisites>

    <!-- Repositories ############################################################################################## -->
    <repositories>
        <repository>
            <id>mvnrepository</id>
            <name>mvnrepository</name>
            <url>http://www.mvnrepository.com</url>
        </repository>
        <repository>
            <id>mvncentral</id>
            <name>mvncentral</name>
            <url>http://central.maven.org/maven2/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>oss-sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <!-- Properties ################################################################################################ -->
    <properties>
        <!-- __________________________________________________________ Versions -->
        <java.version>10</java.version>
        <maven.compiler.plugin.version>3.7.0</maven.compiler.plugin.version>
        <maven.surefire.plugin.version>2.22.0</maven.surefire.plugin.version>
        <junit.version>4.12</junit.version>
        <junit.jupiter.version>5.2.0</junit.jupiter.version>
        <junit.platform.surefire.provider.version>1.2.0</junit.platform.surefire.provider.version>
        <asm.version>6.2</asm.version>
        <!-- __________________________________________________________ Encoding -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <mainClass>net.clanwolf.c3.client.MainFrame</mainClass>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
    </properties>

    <!-- Dependencies ############################################################################################## -->
    <dependencies>
        <!-- _____________________________________________________________ Maven -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
        </dependency>
        <!-- _____________________________________________________________ JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apiguardian</groupId>
            <artifactId>apiguardian-api</artifactId>
            <version>1.0.0</version>
            <scope>test</scope>
        </dependency>
        <!-- ___________________________________________________________ Logging -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.11.0</version>
        </dependency>
        <!-- _______________________________________________ Tektosyne / Voronoi -->
        <dependency>
            <groupId>org.kynosarges</groupId>
            <artifactId>tektosyne</artifactId>
            <version>6.2.0</version>
        </dependency>
        <!-- ______________________________________________________ C3-Preloader -->
        <dependency>
            <groupId>net.clanwolf</groupId>
            <artifactId>C3-Preloader</artifactId>
            <version>1.0.0</version>
        </dependency>
        <!-- ____________________________________________________________ Nadron -->
        <!--<dependency>-->
            <!--<groupId>com.github.menacher</groupId>-->
            <!--<artifactId>nadron</artifactId>-->
            <!--<version>0.8-SNAPSHOT</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>com.github.menacher</groupId>-->
            <!--<artifactId>nadclient</artifactId>-->
            <!--<version>0.8-SNAPSHOT</version>-->
        <!--</dependency>-->
        <!-- _________________________________________________________ Hibernate -->
        <!--<dependency>-->
            <!--<groupId>org.hibernate.javax.persistence</groupId>-->
            <!--<artifactId>hibernate-jpa-2.1-api</artifactId>-->
            <!--<version>1.0.0.Final</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>org.hibernate</groupId>-->
            <!--<artifactId>hibernate-core</artifactId>-->
            <!--<version>5.0.3.Final</version>-->
        <!--</dependency>-->
        <!-- ___________________________________________________________________________ C H E C K  I F  N E E D E D -->
        <!--<dependency>-->
            <!--<groupId>net.sourceforge.collections</groupId>-->
            <!--<artifactId>collections-generic</artifactId>-->
            <!--<version>4.01</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>com.google.code.gson</groupId>-->
            <!--<artifactId>gson</artifactId>-->
            <!--<version>2.4</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>commons-codec</groupId>-->
            <!--<artifactId>commons-codec</artifactId>-->
            <!--<version>1.10</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>dom4j</groupId>-->
            <!--<artifactId>dom4j</artifactId>-->
            <!--<version>1.6.1</version>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>commons-net</groupId>-->
            <!--<artifactId>commons-net</artifactId>-->
            <!--<version>3.3</version>-->
        <!--</dependency>-->

    </dependencies>

    <!-- Build ##################################################################################################### -->
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/version.number</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/version.number</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm</artifactId>
                        <version>${asm.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>${junit.platform.surefire.provider.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-engine</artifactId>
                        <version>${junit.jupiter.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm</artifactId>
                        <version>${asm.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <parallel>methods</parallel>
                    <threadCount>10</threadCount>
                    <includes>
                        <include>**/Test*.java</include>
                        <include>**/*Test.java</include>
                        <include>**/*Tests.java</include>
                        <include>**/*TestCase.java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>8.9.0-SNAPSHOT</version>
                <configuration>
                    <mainClass>net.clanwolf.c3.client.MainFrame</mainClass>
                    <preLoader>c3_preloader.C3_Preloader</preLoader>
                    <verbose>true</verbose>
                    <bundleArguments>
                        <!-- MSI installer Options -->
                        <!-- https://docs.oracle.com/javase/9/tools/javapackager.htm#GUID-E51F9601-E121-4A50-BCA7-C7F8730078B2__WINDOWSEXEBUNDLERARGUMENTS-26C9A39C -->
                        <!-- Custonmize MSI installer -->
                        <!-- http://wixtoolset.org/documentation/manual/v3/wixui/wixui_customizations.html -->
                        <icon>target/classes/icon.ico</icon>
                        <installdirChooser>true</installdirChooser>
                        <module-path>target/classes</module-path>
                        <module>net.clanwolf.c3.client</module>
                        <!--<add-modules>module1,module2,module3</add-modules>-->
                        <!--<limit-modules>module1,module2,module3</limit-modules>-->
                        <!--<runtime /> Not working together with the above commands -->
                    </bundleArguments>
                    <!--<jfxMainAppJarName>${project.build.finalName}.jar</jfxMainAppJarName>-->
                    <identifier>${project.artifactId}</identifier>
                    <vendor>ClanWolf.net</vendor>
                    <!-- win.app | linux.app | mac.app | exe | msi | rpm | deb -->
                    <bundler>msi</bundler>
                    <nativeReleaseVersion>${project.version}</nativeReleaseVersion>
                    <needShortcut>true</needShortcut>
                    <needMenu>true</needMenu>
                    <appName>${project.artifactId}</appName>
                    <jvmArgs>
                        <jvmArg>-Xmx2g</jvmArg>
                        <jvmArg>-Djavafx.verbose=true</jvmArg>
                        <!--<jvmProperty>-DMyProperty=true</jvmProperty>-->
                    </jvmArgs>
                    <!--<jvmProperties>-->
                    <!--<UserProperty>foo</UserProperty>-->
                    <!--</jvmProperties>-->
                    <!--<userJvmArgs>-->
                    <!--<Argument3>AppCommand</Argument3>-->
                    <!--</userJvmArgs>-->
                    <!--<keyStoreAlias>example-user</keyStoreAlias>-->
                    <!--<keyStorePassword>example-password</keyStorePassword>-->
                    <allPermissions>false</allPermissions>
                    <manifestAttributes>
                        <Specification-Title>${project.name}</Specification-Title>
                        <Specification-Version>${project.version}</Specification-Version>
                        <Specification-Vendor>${project.organization.name}</Specification-Vendor>
                        <Implementation-Title>${project.name}</Implementation-Title>
                        <Implementation-Version>${project.version}</Implementation-Version>
                        <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
                        <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
                    </manifestAttributes>
                </configuration>
                <executions>
                    <execution>
                        <id>create-jfxjar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>build-jar</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>create-native</id>
                        <phase>package</phase>
                        <goals>
                            <goal>build-native</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

This does not run. The maven build completes without problems, but if I start it in IntelliJ, it gives me this:

Error occurred during initialization of boot layer java.lang.module.ResolutionException: Modules maven.core and maven.artifact export package org.apache.maven.artifact.resolver.filter to module aether.impl

If I do remove the dependency for log4j-core, it will run, but it will complain at runtime that there is no implementation of log4j and that I should please add log4j-core. If I do that, the Resolution Bullshit is shown again. How can this be resolved, if possible at all?


Solution

  • Java 9 modularization came with a couple of new rules like: Split packages, i.e. classes with the same package but in different jars, are not allowed. This is only an issue when working on the modulepath, not with the traditional classpath. It seems like intellij decides for the wrong reason to switch to the modulepath, probably because log4j has a module descriptor.