mojohaus / mojohaus/exec-maven-plugin

"Module path" needs additional documentation!

Open
#448 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
191
Forks
111
Avg merge
1d 21h
Merged PRs (30d)
4

Description

Trying to run a JavaFX program with the exec-maven-plugin, rather than the javafx-maven-plugin.

The latter works flawlessly, for anyone interested the declaration is

   <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.8</version>

            <configuration>
                 <mainClass>org.openjfx.App</mainClass>
            </configuration>

   </plugin>

But I thought, why not try exec-maven-plugin too, maybe you can get it to work, too.

So I need to inject the module path into the java command line.

So I achieved this:

<plugin>

     <groupId>org.codehaus.mojo</groupId>
     <artifactId>exec-maven-plugin</artifactId>
     <version>3.4.1</version>

     <configuration>
         <executable>java</executable>
         <arguments>
             <argument>--module-path</argument> <!-- inject string into the command line -->
             <modulepath/> <!-- inject the module path based on what's in the local maven .m2 repo  -->
             <argument>--add-modules</argument> <!-- inject string into the command line -->
             <argument>javafx.controls,javafx.fxml,javafx.web,javafx.graphics,javafx.media</argument> <!-- inject string into the command line -->
             <argument>-classpath</argument> <!-- inject string into the command line -->
             <classpath/> <!-- inject dependencies from the local maven .m2 repo  -->
             <argument>org.openjfx.App</argument> <!-- the program -->
          </arguments>
     </configuration>

</plugin>

Running mvn -X exec:exec reveals that the generated command line is

java
@/home/aloy/IdeaProjects/compile_javafx/target/modulepath 
--add-modules
javafx.controls,javafx.fxml,javafx.web,javafx.graphics,javafx.media
-classpath [correct classpath]
org.openjfx.App

This means the --module-path string was not injected.

Instead java is told to look for file @/home/aloy/IdeaProjects/compile_javafx/target/modulepath which has indeed been created.

This behavior is not documented at https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html

But the JavaFX program can actually run!

Note that if one removes

<argument>--module-path</argument> <!-- inject string into the command line -->

then the module path is injected into the command line directly (instead of the reference to the file modulepath) but without option -p prepended, leading to failure. Really weird, it would be much better for the plugin to bail out at once with a clear message here.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the exec-for-Java-programs documentation page linked in the issue and reproduce the behavior using the shown exec-maven-plugin configuration and mvn -X exec:exec. Document how <modulepath/> is rendered when used with --module-path, including the observed @.../modulepath output and the behavior without that option. Done means the example or reference clearly explains the generated command line and its limitations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.