1

I am trying to use moditect in order to allow creating runtime image while using automated named modules (ArcGIS). ArcGIS module requires openjfx 11 (which I have added as dependency as well, since it is an JavaFX project). However, when I am trying to build the runtime image, I am getting the following error

java.lang.IllegalArgumentException: duplicate element: javafx.base

I think it is because maven is also adding the ArcGIS openjfx dependency to the project (this includes openjfx for every platform (win, mac, linux), which causes it to have duplicate javafxs.

How should I add module info without also adding the openjfx dependencies?

Here the part of pom.xml with moditect plugin if that helps

            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-module-info-to-dependencies</id>
                        <phase>package</phase>
                        <configuration>
                            <overwriteExistingFiles>true</overwriteExistingFiles>
                            <outputDirectory>${project.build.directory}/modules</outputDirectory>
                            <modules>
                                ...
                                <module>
                                    <artifact>
                                        <groupId>com.esri.arcgisruntime</groupId>
                                        <artifactId>arcgis-java</artifactId>
                                        <version>${arcgis.version}</version>
                                    </artifact>
                                    <moduleInfo>
                                        <name>com.esri.arcgisruntime</name>
                                    </moduleInfo>
                                </module>
                            </modules>
                        </configuration>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

1 Answers1

0

In addition to the <artifact>, instead <moduleInfo> tags, you will need to override the source of the moduleinfo.java using moduleInfoSource:

<module>
    <artifact>...</artifact>    
    <moduleInfoSource>
        module com.esri.arcgisruntime {
            requires ...;
            exports ...;
            provides ...
                with ...;
        }
    </moduleInfoSource>
</module>

You'll have to go through the dependency structure of com.esri.arcgisruntime to do this, but moditect does provide a generate-module-info goal that will auto-generate that for you.

Then you would update requires javafx.base to requires transitive javafx.base (and potentially other javafx entries) to indicate the module depends on it, but should load it from elsewhere.

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
  • I keep getting the error ```Execution default-cli of goal org.moditect:moditect-maven-plugin:1.0.0.RC1:generate-module-info failed.``` when I am trying to use the generate-module-info goal. Have you got any idea why? – Verdy Noorghifari Aug 21 '20 at 04:36
  • I think you need to configure the `generate-module-info` goal [in your pom.xml](https://github.com/moditect/moditect#generating-module-infojava-descriptors). Unlike the real `module-info` you can use wildcards here that will fill out everything else for you, but allow you some customization. – Daniel Widdis Aug 21 '20 at 04:39
  • And it acutally looks ike you can add `` etc. to the existing `` tag configuration to do that customization as well, without that whole intermediate step. I went for maximum configurability. Once you get it working you can probably improve it. – Daniel Widdis Aug 21 '20 at 04:43