88import java .io .File ;
99import java .io .IOException ;
1010import java .nio .file .Files ;
11+ import java .nio .file .Path ;
1112import java .security .MessageDigest ;
1213import java .security .NoSuchAlgorithmException ;
14+ import java .util .ArrayList ;
1315import java .util .Arrays ;
1416import java .util .List ;
1517import java .util .stream .Collectors ;
@@ -112,7 +114,7 @@ public abstract class Jpackage extends DefaultTask {
112114 public abstract DirectoryProperty getDestination ();
113115
114116 /**
115- * To copy resources before adding them. This allows ressource filtering via Gradle
117+ * To copy resources before adding them. This allows resource filtering via Gradle
116118 * FileCollection and FileTree APIs.
117119 */
118120 @ Internal
@@ -235,15 +237,15 @@ private void performAppImageStep(String jpackage, Directory resourcesDir) {
235237 }
236238
237239 private void configureJPackageArguments (ExecSpec e , Directory resourcesDir ) {
240+ String argsFile = createArgsFile (getModulePath ().getAsPath ());
238241 e .args (
239242 "--module" ,
240243 getMainModule ().get (),
241244 "--resource-dir" ,
242245 resourcesDir .getAsFile ().getPath (),
243246 "--app-version" ,
244247 getVersion ().get (),
245- "--module-path" ,
246- getModulePath ().getAsPath (),
248+ argsFile ,
247249 "--name" ,
248250 getApplicationName ().get ());
249251 if (getApplicationDescription ().isPresent ()) {
@@ -269,6 +271,18 @@ private void configureJPackageArguments(ExecSpec e, Directory resourcesDir) {
269271 }
270272 }
271273
274+ private String createArgsFile (String modulePathAsPath ) {
275+ Path argsFile = getTemporaryDir ().toPath ().resolve ("args.txt" );
276+ List <String > lines = new ArrayList <>(1 );
277+ lines .add ("--module-path " + modulePathAsPath );
278+ try {
279+ Files .write (argsFile , lines );
280+ } catch (IOException e ) {
281+ throw new RuntimeException (e );
282+ }
283+ return "@" + argsFile .toString ();
284+ }
285+
272286 private void generateChecksums () throws NoSuchAlgorithmException , IOException {
273287 File destination = getDestination ().get ().getAsFile ();
274288 List <File > allFiles = Arrays .stream (requireNonNull (destination .listFiles ()))
0 commit comments