Uploaded image for project: 'Maven JMod Plugin'
  1. Maven JMod Plugin
  2. MJMOD-20

Main class is not being set by maven-jmod-plugin

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0-alpha-1
    • 3.0.0
    • None
    • Ubuntu Linux 18.04 LTS
      Java 11.0.1 OpenJDK
      Maven 3.6.0

    Description

      Hi!,

      I have created a project in and [https://github.com/andretadeu/maven-jigsaw-examples/tree/master/multi-modules-jmod-jlink|multi-modules-jmod-jlink] and I needed to set the parameter --main-class in jmod create command.

      Trying to add the <mainClass> tag:

       

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jmod-plugin</artifactId>
          <configuration>
              <mainClass>com.andretadeu.greetings.Main</mainClass> <!-- This-->
              <modulePath>target/jmods</modulePath>
              <moduleVersion>${project.version}</moduleVersion>
          </configuration>
      

       

      Maven gave the following error during the execution of maven-jlink-plugin:

      [ERROR]
      [ERROR] com.andretadeu.greetings file:///home/andre/workspaces/oss/maven-jigsaw-examples/multi-modules-jmod-jlink/greetings/target/jmods/com.andretadeu.greetings.jmod
      [ERROR] com.andretadeu.world file:///home/andre/workspaces/oss/maven-jigsaw-examples/multi-modules-jmod-jlink/world/target/jmods/com.andretadeu.world.jmod
      [ERROR] java.base file:///home/andre/.sdkman/candidates/java/11.0.1-open/jmods/java.base.jmod
      [ERROR]
      [ERROR] Providers:
      [ERROR] java.base provides java.nio.file.spi.FileSystemProvider used by java.base
      [ERROR] Error: java.lang.IllegalArgumentException: com.andretadeu.greetings doesn't contain main class & main not specified in command line
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary for multi-modules-jmod-jlink 1.0-SNAPSHOT:
      [INFO]
      [INFO] multi-modules-jmod-jlink ........................... SUCCESS [ 0.185 s]
      [INFO] com.andretadeu.world ............................... SUCCESS [ 3.974 s]
      [INFO] com.andretadeu.greetings ........................... SUCCESS [ 0.628 s]
      [INFO] greetings-jlink .................................... FAILURE [ 3.068 s]
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 8.916 s
      [INFO] Finished at: 2018-12-11T22:42:31-02:00
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jlink-plugin:3.0.0-alpha-2-SNAPSHOT:jlink (default-jlink) on project greetings-jlink:
      [ERROR] Exit code: 1
      [ERROR] Command line was: /bin/sh -c /home/andre/.sdkman/candidates/java/11.0.1-open/bin/jlink @/home/andre/workspaces/oss/maven-jigsaw-examples/multi-modules-jmod-jlink/greetings-jlink/target/jlinkArgs
      [ERROR]
      [ERROR]
      [ERROR] -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-jlink-plugin:3.0.0-alpha-2-SNAPSHOT:jlink (default-jlink) on project greetings-jlink:
      Exit code: 1
      Command line was: /bin/sh -c /home/andre/.sdkman/candidates/java/11.0.1-open/bin/jlink @/home/andre/workspaces/oss/maven-jigsaw-examples/multi-modules-jmod-jlink/greetings-jlink/target/jlinkArgs

       

      I noticed that the --main-class parameter was not set in **jmodCreateArgs:

      create
      --module-version
      1.0-SNAPSHOT
      --class-path
      /home/andre/workspaces/oss/maven-jigsaw-examples/multi-modules-jmod-jlink/greetings/target/classes
      --module-path
      "/home/andre/workspaces/oss/maven-jigsaw-examples/multi-modules-jmod-jlink/greetings/target/classes:/home/andre/.sdkman/candidates/java/11.0.1-open/jmods"
      /home/andre/workspaces/oss/maven-jigsaw-examples/multi-modules-jmod-jlink/greetings/target/jmods/com.andretadeu.greetings.jmod
      

      Debugging the plugin, I have found the root cause of the problem and I will make a pull request after publishing this issue.

       

      Thanks,

       

      André Tadeu de Carvalho

       

      Attachments

        Issue Links

          Activity

            People

              rfscholte Robert Scholte
              andretadeu Andre Tadeu de Carvalho
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Time Spent - 10m Remaining Estimate - 50m
                  50m
                  Logged:
                  Time Spent - 10m Remaining Estimate - 50m
                  10m