@@ -30,6 +30,9 @@ public abstract class JlinkTask extends DefaultTask {
3030 @ Input
3131 public abstract ListProperty <@ NotNull String > getModules ();
3232
33+ @ Input
34+ public abstract Property <@ NotNull Boolean > getIncludeModulePath ();
35+
3336 @ OutputDirectory
3437 public abstract DirectoryProperty getOutputDirectory ();
3538
@@ -46,6 +49,7 @@ public abstract class JlinkTask extends DefaultTask {
4649 public JlinkTask (ProjectLayout layout , JavaToolchainService javaToolchain ) {
4750 getOptions ().convention (List .of ());
4851 getModules ().convention (List .of ("ALL-MODULE-PATH" ));
52+ getIncludeModulePath ().convention (true );
4953 getOutputDirectory ().convention (layout .getBuildDirectory ().dir ("jlink" ));
5054
5155 var toolchain = getProject ().getExtensions ().getByType (JavaPluginExtension .class ).getToolchain ();
@@ -71,8 +75,10 @@ public void createJre() {
7175 var commandLine = new ArrayList <String >();
7276 commandLine .add (jlink .toString ());
7377 commandLine .addAll (getOptions ().get ());
74- commandLine .add ("--module-path" );
75- commandLine .add (jmods .toString ());
78+ if (getIncludeModulePath ().get ()) {
79+ commandLine .add ("--module-path" );
80+ commandLine .add (jmods .toString ());
81+ }
7682 commandLine .add ("--add-modules" );
7783 commandLine .add (String .join ("," , getModules ().get ()));
7884 commandLine .add ("--output" );
0 commit comments