9

I've configured ModiTect to generate module-info.javas for all my dependencies (that don't have them) and that seems to be working; but when it comes to dependencies that do have them, it's not finding them. For my own jars, I'm writing the module-info.java by hand.

When I run mvn package in my app it's failing with:

Error: Module tech.flexpoint.dashmancommon not found, required by tech.flexpoint.dashmanserver

The command line looks like this:

C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\classes --output C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image --launcher dashmanserver=tech.flexpoint.dashmanserver

I know tech.flexpoint.dashmancommon is a module and has a module-info.java because I built it myself. How do I make ModiTect/jlink find all the dependent modules in their original jars?

My under-construction ModiTect config looks like this:

<plugin>
    <groupId>org.moditect</groupId>
    <artifactId>moditect-maven-plugin</artifactId>
    <version>1.0.0.Beta1</version>
    <executions>
        <execution>
            <id>add-module-info-to-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>add-module-info</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/modules</outputDirectory>
                <overwriteExistingFiles>true</overwriteExistingFiles>
                <modules>
                    <module>
                        <artifact>
                            <groupId>org.bouncycastle</groupId>
                            <artifactId>bcprov-jdk15on</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module bcprov.jdk15on {
                            }
                        </moduleInfoSource>
                    </module> <!-- bcprov.jdk15on -->
                    <module>
                        <artifact>
                            <groupId>com.fasterxml.jackson.core</groupId>
                            <artifactId>jackson-core</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module com.fasterxml.jackson.core {
                            }
                        </moduleInfoSource>
                    </module> <!-- com.fasterxml.jackson.core -->
                    <module>
                        <artifact>
                            <groupId>com.fasterxml.jackson.core</groupId>
                            <artifactId>jackson-databind</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module com.fasterxml.jackson.databind {
                            }
                        </moduleInfoSource>
                    </module> <!-- com.fasterxml.jackson.databind -->
                    <module>
                        <artifact>
                            <groupId>org.hibernate</groupId>
                            <artifactId>hibernate-core</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module hibernate.core {
                            }
                        </moduleInfoSource>
                    </module> <!-- hibernate.core -->
                    <module>
                        <artifact>
                            <groupId>io.sentry</groupId>
                            <artifactId>sentry</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module io.sentry {
                            }
                        </moduleInfoSource>
                    </module> <!-- io.sentry -->
                    <module>
                        <artifact>
                            <groupId>org.hibernate.javax.persistence</groupId>
                            <artifactId>hibernate-jpa-2.1-api</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module java.persistence {
                            }
                        </moduleInfoSource>
                    </module> <!-- java.persistence -->
                    <module>
                        <artifact>
                            <groupId>javax.validation</groupId>
                            <artifactId>validation-api</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module java.validation {
                            }
                        </moduleInfoSource>
                    </module> <!-- java.validation -->
                    <module>
                        <artifact>
                            <groupId>org.apache.commons</groupId>
                            <artifactId>commons-lang3</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module org.apache.commons.lang3 {
                            }
                        </moduleInfoSource>
                    </module> <!-- org.apache.commons.lang3 -->
                    <module>
                        <artifact>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-core</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.core {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.core -->
                    <module>
                        <artifact>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-web</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.web {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.web -->
                    <module>
                        <artifact>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.boot {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.boot -->
                    <module>
                        <artifact>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-context</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.context {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.context -->
                    <module>
                        <artifact>
                            <groupId>org.springframework.data</groupId>
                            <artifactId>spring-data-commons</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.data.commons {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.data.commons -->
                    <module>
                        <artifact>
                            <groupId>org.springframework.data</groupId>
                            <artifactId>spring-data-jpa</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.data.jpa {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.data.jpa -->
                    <module>
                        <artifact>
                            <groupId>org.springframework.security</groupId>
                            <artifactId>spring-security-core</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.security.core {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.security.core -->
                    <module>
                        <artifact>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-tx</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.tx {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.tx -->
                    <module>
                        <artifact>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-webmvc</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module spring.webmvc {
                            }
                        </moduleInfoSource>
                    </module> <!-- spring.webmvc -->
                    <module>
                        <artifact>
                            <groupId>org.apache.tomcat.embed</groupId>
                            <artifactId>tomcat-embed-core</artifactId>
                        </artifact>
                        <moduleInfoSource>
                            module tomcat.embed.core {
                            }
                        </moduleInfoSource>
                    </module> <!-- tomcat.embed.core -->
                </modules>
            </configuration>
        </execution>
        <execution>
            <id>create-runtime-image</id>
            <phase>package</phase>
            <goals>
                <goal>create-runtime-image</goal>
            </goals>
            <configuration>
                <modulePath>
                    <path>${project.build.directory}/classes</path>
                    <path>${project.build.directory}/modules</path>
                </modulePath>
                <modules>
                    <module>tech.flexpoint.dashmanserver</module>
                </modules>
                <launcher>
                    <name>dashmanserver</name>
                    <module>tech.flexpoint.dashmanserver</module>
                </launcher>
                <outputDirectory>
                    ${project.build.directory}/jlink-image
                </outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

If I add

<path>c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11</path>

to my ModiTect config, it starts working, generating this command line:

C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\classes --output C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image --launcher dashmanserver=tech.flexpoint.dashmanserver

I guess this confirms the module works and it's installed. I'm just not sure how to make ModiTect find it (without a horrible hard-coded path).

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
  • "I know tech.flexpoint.dashmancommon is a module and has a module-info.java because I built it myself". Get a printout of the exact file location for the `dashmancommon` Jar and unzip it. Make sure the module-info file is indeed present. – flakes Jul 02 '18 at 22:22
  • 1
    @flakes: yes, it is present. If I add the actual path pointing to that jar, the module is successfully found, so, the module is fine. The problem is ModiTect not automatically adding the paths for each and every dependency (or something like that). – Pablo Fernandez Jul 02 '18 at 22:29
  • @pupeno please create the tag [maven-jlink-plugin], thanks. More questions incoming due to new release! – Benjamin Marwell Dec 19 '20 at 21:06

1 Answers1

0

I think your issue corresponds to this known issue with moditect.

Generating a module-path from the subset of maven dependencies that happen to already be modules is not currently supported. The workaround is to use the maven-dependency plugin to copy them to a known directory which can be added to the module path.

soru
  • 5,464
  • 26
  • 30