Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Paths in --module-path not supported #1

Closed
brcolow opened this issue Aug 26, 2019 · 10 comments
Closed

Multiple Paths in --module-path not supported #1

brcolow opened this issue Aug 26, 2019 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@brcolow
Copy link

brcolow commented Aug 26, 2019

Hello,

I have two issues, actually.

1.) It seems that specifying more than one directory for --module-path is not supported. For example:

<modulePath>${jlink.jdk.path}${file.separator}jmods;target/</modulePath>

This is because in:

commandLineOptions.add("--module-path");
    if (this.modulePath != null) {
      log.debug("Detected non-empty module path in configuration: " + this.modulePath);

      final File modulePathFolder = new File(this.modulePath);

      if (!modulePathFolder.isDirectory()) {
        throw new MojoExecutionException("Can't find folder provided in 'modulePath': " + modulePathFolder.getAbsolutePath());
      }

It does not split the path on either : or ; (depending on if it's *nix or Windows) and check each element of the module path individually.

It would be nice if the plugin provided some property that is either ; or : depending on the OS running Maven (so that the POM is cross-platform) that could be used inside the module-path, but that's a secondary concern.

2.) Not sure if this is an issue with the plugin, but when trying to add the following option:

<option>--launcher bootstrap=com.dow.aws.lambda/com.dow.aws.lambda.Bootstrap</option>

I get the following error from jlink:

[ERROR] Error: unknown option: --launcher bootstrap=com.dow.aws.lambda/com.dow.aws.lambda.Bootstrap
Usage: jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...]
Use --help for a list of possible options

It maybe could be because of the space?

Thanks very much for your useful plugin!

@raydac
Copy link
Owner

raydac commented Aug 26, 2019

thank you very much for your report, I will investigate the first issue and what about the second one - try to split it as two option items

<options>
   <option>--launcher</option>
   <option>bootstrap=com.dow.aws.lambda/com.dow.aws.lambda.Bootstrap</option>
</options>

@raydac raydac self-assigned this Aug 26, 2019
@raydac raydac added the bug Something isn't working label Aug 26, 2019
@brcolow
Copy link
Author

brcolow commented Aug 26, 2019

That fixes the second issue. I thought Maven had an issue with spaces. Fixing the first should be relatively straight-forward (just need to split on the module-path separator which somewhat confusingly varies depending on if it's *nix or Windows). Thanks for your super quick response :).

@raydac
Copy link
Owner

raydac commented Aug 27, 2019

I made changes and have replaced single string modulePath parameter by string list modulePaths, so you can try snapshot with such snippet

<modulePaths>
   <path>JDK.PROVIDER.JMODS</path>
   <path>target/</path>
</modulePaths>

path to the provider's jmods folder can be marked through pseudo-path JDK.PROVIDER.JMODS

@brcolow
Copy link
Author

brcolow commented Aug 27, 2019

Thanks very much for your quick work on this. Is the snapshot available in a public repository?

@raydac
Copy link
Owner

raydac commented Aug 27, 2019

I don't public snapshots in any repository, just clone project and build it locally, snapshot will be represented in your local maven repository

@brcolow
Copy link
Author

brcolow commented Aug 27, 2019

Okay. For some reason it is stripping the module path:

<plugin>
 <groupId>com.igormaznitsa</groupId>
 <artifactId>mvn-jlink-wrapper</artifactId>
 <version>1.0.4-SNAPSHOT</version>
 <executions>
   <!-- Download AdoptOpenJDK for Linux, which we need to link against for a native Amazon Linux launcher. -->
   <execution>
     <id>cache-jdk11-linux</id>
     <goals>
       <goal>cache-jdk</goal>
     </goals>
     <configuration>
       <jdkPathProperty>jlink.jdk.path</jdkPathProperty>
       <jdkCachePath>${project.build.directory}/jdkCache</jdkCachePath>
       <provider>ADOPT</provider>
       <providerConfig>
         <os>linux</os>
         <release>jdk-12.0.2+10</release>
         <arch>x64</arch>
         <type>jdk</type>
         <impl>hotspot</impl>
       </providerConfig>
     </configuration>
   </execution>
   <!-- Run jlink (pointing it to the jmods of a Linux OpenJDK) to create the lambda bootstrap executable. -->
   <execution>
     <id>call-jlink</id>
     <goals>
       <goal>jlink</goal>
     </goals>
     <configuration>
       <output>${project.build.directory}/dist</output>
       <modulePaths>
         <path>JDK.PROVIDER.JMODS</path>
         <path>${project.build.directory}</path>
       </modulePaths>
       <addModules>
         <module>java.net.http</module>
         <module>com.dow.aws.lambda</module>
       </addModules>
       <options>
         <option>--launcher</option>
         <option>bootstrap=com.dow.aws.lambda/com.dow.aws.lambda.Bootstrap</option>
         <option>--compress=2</option>
         <option>--no-header-files</option>
         <option>--no-man-pages</option>
         <option>--strip-debug</option>
       </options>
     </configuration>
   </execution>
 </executions>
</plugin>

Result:

[INFO] --- mvn-jlink-wrapper:1.0.4-SNAPSHOT:jlink (call-jlink) @ project ---
[INFO] List of modules : java.net.http,com.dow.aws.lambda
[INFO] Formed module path: ;
[INFO] CLI arguments: --output C:\Users\brcolow\dev\dow\project\target\dist --launcher bootstrap=com.dow.aws.lambda/com.dow.aws.lambda.Bootstrap --compress=2 --no-header-files --no-man-pages --strip-debug --module-path ; --add-modules java.net.http,com.dow.aws.lambda
[ERROR] Error: Module com.dow.aws.lambda not found

Trying <path>./target</path> does the same thing.

@raydac
Copy link
Owner

raydac commented Aug 27, 2019

yes, sorry there was some bug, try now

@brcolow
Copy link
Author

brcolow commented Aug 27, 2019

It works :). Thanks a lot.

@brcolow
Copy link
Author

brcolow commented Aug 28, 2019

One thing to note is that using JDK.PROVIDER.JMODS doesn't seem to be using the Linux JVM I specified in cache-jdk. I have to use ${jlink.jdk.path}${file.separator}jmods in order for it to use the correct one.

@raydac
Copy link
Owner

raydac commented Aug 28, 2019

JDK.PROVIDER.JMODS uses path to jdk provider defined for jlink goal, if you use the pom which provided in the issue then your cache-jdk has downloaded one JDK and jlink uses default JDK which is same as maven uses. Usually cache-jdk is good if you make cross-platform java images, if you build for same host-os then you can avoid cache-jdk

@raydac raydac closed this as completed Sep 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants