diff --git a/src/main/java/rife/bld/BaseProject.java b/src/main/java/rife/bld/BaseProject.java
index 3fd1f10..5a93f86 100644
--- a/src/main/java/rife/bld/BaseProject.java
+++ b/src/main/java/rife/bld/BaseProject.java
@@ -61,6 +61,13 @@ public class BaseProject extends BuildExecutor {
* @since 1.5
*/
protected String mainClass = null;
+ /**
+ * The project's module.
+ *
+ * @see #module()
+ * @since 2.1
+ */
+ protected String module = null;
/**
* The project's repositories for dependency resolution.
@@ -1399,12 +1406,18 @@ public VersionNumber version() {
* @since 1.5
*/
public String mainClass() {
- if (mainClass == null) {
- throw new IllegalStateException("The mainClass variable has to be set.");
- }
return mainClass;
}
+ /**
+ * Returns the project's module.
+ *
+ * @since 2.1
+ */
+ public String module() {
+ return module;
+ }
+
/**
* Returns the list of repositories for this project.
*
@@ -1520,7 +1533,14 @@ public String uberJarFileName() {
* @since 1.5
*/
public String uberJarMainClass() {
- return Objects.requireNonNullElseGet(uberJarMainClass, this::mainClass);
+ if (uberJarMainClass != null) {
+ return uberJarMainClass;
+ }
+ if (mainClass() != null) {
+ return mainClass();
+ }
+
+ throw new IllegalStateException("The mainClass variable has to be set.");
}
/**
diff --git a/src/main/java/rife/bld/operations/AbstractProcessOperation.java b/src/main/java/rife/bld/operations/AbstractProcessOperation.java
index acc49a1..dd4c012 100644
--- a/src/main/java/rife/bld/operations/AbstractProcessOperation.java
+++ b/src/main/java/rife/bld/operations/AbstractProcessOperation.java
@@ -29,6 +29,7 @@ public abstract class AbstractProcessOperation classpath_ = new ArrayList<>();
protected final List modulePath_ = new ArrayList<>();
protected String mainClass_;
+ protected String module_;
protected Function outputProcessor_;
protected Function errorProcessor_;
protected Process process_;
@@ -252,6 +253,18 @@ public T mainClass(String name) {
return (T) this;
}
+ /**
+ * Provides the module to launch with the java tool.
+ *
+ * @param name the module to launch
+ * @return this operation instance
+ * @since 2.1
+ */
+ public T module(String name) {
+ module_ = name;
+ return (T) this;
+ }
+
/**
* Provides the processor that will be used to handle the process output.
*
@@ -346,6 +359,16 @@ public String mainClass() {
return mainClass_;
}
+ /**
+ * Retrieves the module to launch with the java tool.
+ *
+ * @return the module to launch
+ * @since 2.1
+ */
+ public String module() {
+ return module_;
+ }
+
/**
* Retrieves the processor that is used to handle the process output.
*
diff --git a/src/main/java/rife/bld/operations/JavaOptions.java b/src/main/java/rife/bld/operations/JavaOptions.java
index 5e4ab59..8659bba 100644
--- a/src/main/java/rife/bld/operations/JavaOptions.java
+++ b/src/main/java/rife/bld/operations/JavaOptions.java
@@ -4,9 +4,11 @@
*/
package rife.bld.operations;
+import rife.tools.FileUtils;
import rife.tools.StringUtils;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@@ -38,8 +40,8 @@ public JavaOptions truffle() {
* @return this list of options
* @since 1.5.18
*/
- public JavaOptions modulePath(File... modules) {
- return modulePath(List.of(modules));
+ public JavaOptions modulePath(File... paths) {
+ return modulePath(List.of(paths));
}
/**
@@ -48,9 +50,49 @@ public JavaOptions modulePath(File... modules) {
* @return this list of options
* @since 1.5.18
*/
- public JavaOptions modulePath(List modules) {
+ public JavaOptions modulePath(List paths) {
+ return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
+ }
+
+ /**
+ * A list of directories, each directory is a directory of modules.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions modulePath(Path... paths) {
+ return modulePathPaths(List.of(paths));
+ }
+
+ /**
+ * A list of directories, each directory is a directory of modules.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions modulePathPaths(List paths) {
+ return modulePath(paths.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * A list of directories, each directory is a directory of modules.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions modulePath(String... paths) {
+ return modulePathStrings(List.of(paths));
+ }
+
+ /**
+ * A list of directories, each directory is a directory of modules.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions modulePathStrings(List paths) {
add("--module-path");
- add(StringUtils.join(modules, ":"));
+ add(FileUtils.joinPaths(paths));
return this;
}
@@ -61,8 +103,8 @@ public JavaOptions modulePath(List modules) {
* @return this list of options
* @since 1.5.18
*/
- public JavaOptions upgradeModulePath(File... modulePath) {
- return upgradeModulePath(List.of(modulePath));
+ public JavaOptions upgradeModulePath(File... paths) {
+ return upgradeModulePath(List.of(paths));
}
/**
@@ -72,9 +114,53 @@ public JavaOptions upgradeModulePath(File... modulePath) {
* @return this list of options
* @since 1.5.18
*/
- public JavaOptions upgradeModulePath(List modulePath) {
+ public JavaOptions upgradeModulePath(List paths) {
+ return upgradeModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
+ }
+
+ /**
+ * List of directories, each directory is a directory of modules
+ * that replace upgradeable modules in the runtime image
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions upgradeModulePath(Path... paths) {
+ return upgradeModulePathPaths(List.of(paths));
+ }
+
+ /**
+ * List of directories, each directory is a directory of modules
+ * that replace upgradeable modules in the runtime image
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions upgradeModulePathPaths(List paths) {
+ return upgradeModulePath(paths.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * List of directories, each directory is a directory of modules
+ * that replace upgradeable modules in the runtime image
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions upgradeModulePath(String... paths) {
+ return upgradeModulePathStrings(List.of(paths));
+ }
+
+ /**
+ * List of directories, each directory is a directory of modules
+ * that replace upgradeable modules in the runtime image
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions upgradeModulePathStrings(List paths) {
add("--upgrade-module-path");
- add(StringUtils.join(modulePath, ":"));
+ add(FileUtils.joinPaths(paths));
return this;
}
@@ -256,7 +342,7 @@ public JavaOptions agentLib(String libName, List options) {
* @since 1.5.18
*/
public JavaOptions agentPath(File pathName) {
- return agentPath(pathName, (String)null);
+ return agentPath(pathName.getAbsolutePath(), (String)null);
}
/**
@@ -266,8 +352,7 @@ public JavaOptions agentPath(File pathName) {
* @since 1.5.18
*/
public JavaOptions agentPath(File pathName, String options) {
- add("-agentpath:" + pathName + (options == null ? "" : "=" + options));
- return this;
+ return agentPath(pathName.getAbsolutePath(), options);
}
/**
@@ -277,7 +362,7 @@ public JavaOptions agentPath(File pathName, String options) {
* @since 1.7.1
*/
public JavaOptions agentPath(File pathName, String... options) {
- return agentPath(pathName, List.of(options));
+ return agentPath(pathName.getAbsolutePath(), List.of(options));
}
/**
@@ -287,6 +372,87 @@ public JavaOptions agentPath(File pathName, String... options) {
* @since 1.7.1
*/
public JavaOptions agentPath(File pathName, List options) {
+ return agentPath(pathName.getAbsolutePath(), options);
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(Path pathName) {
+ return agentPath(pathName.toFile(), (String)null);
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(Path pathName, String options) {
+ return agentPath(pathName.toFile(), options);
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(Path pathName, String... options) {
+ return agentPath(pathName.toFile(), List.of(options));
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(Path pathName, List options) {
+ return agentPath(pathName.toFile(), options);
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(String pathName) {
+ return agentPath(pathName, (String)null);
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(String pathName, String options) {
+ add("-agentpath:" + pathName + (options == null ? "" : "=" + options));
+ return this;
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(String pathName, String... options) {
+ return agentPath(pathName, List.of(options));
+ }
+
+ /**
+ * Load native agent library by full pathname.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions agentPath(String pathName, List options) {
add("-agentpath:" + pathName + (options == null || options.isEmpty() ? "" : "=" + StringUtils.join(options, ",")));
return this;
}
@@ -298,7 +464,7 @@ public JavaOptions agentPath(File pathName, List options) {
* @since 1.5.18
*/
public JavaOptions javaAgent(File jarPath) {
- return javaAgent(jarPath, (String)null);
+ return javaAgent(jarPath.getAbsolutePath(), (String)null);
}
/**
@@ -308,8 +474,7 @@ public JavaOptions javaAgent(File jarPath) {
* @since 1.5.18
*/
public JavaOptions javaAgent(File jarPath, String options) {
- add("-javaagent:" + jarPath + (options == null ? "" : "=" + options));
- return this;
+ return javaAgent(jarPath.getAbsolutePath(), options);
}
/**
@@ -319,7 +484,7 @@ public JavaOptions javaAgent(File jarPath, String options) {
* @since 1.7.1
*/
public JavaOptions javaAgent(File jarPath, String... options) {
- return javaAgent(jarPath, List.of(options));
+ return javaAgent(jarPath.getAbsolutePath(), List.of(options));
}
/**
@@ -329,6 +494,87 @@ public JavaOptions javaAgent(File jarPath, String... options) {
* @since 1.7.1
*/
public JavaOptions javaAgent(File jarPath, List options) {
+ return javaAgent(jarPath.getAbsolutePath(), options);
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(Path jarPath) {
+ return javaAgent(jarPath.toFile(), (String)null);
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(Path jarPath, String options) {
+ return javaAgent(jarPath.toFile(), options);
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(Path jarPath, String... options) {
+ return javaAgent(jarPath.toFile(), List.of(options));
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(Path jarPath, List options) {
+ return javaAgent(jarPath.toFile(), options);
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(String jarPath) {
+ return javaAgent(jarPath, (String)null);
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(String jarPath, String options) {
+ add("-javaagent:" + jarPath + (options == null ? "" : "=" + options));
+ return this;
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(String jarPath, String... options) {
+ return javaAgent(jarPath, List.of(options));
+ }
+
+ /**
+ * Load Java programming language agent.
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavaOptions javaAgent(String jarPath, List options) {
add("-javaagent:" + jarPath + (options == null || options.isEmpty() ? "" : "=" + StringUtils.join(options, ",")));
return this;
}
diff --git a/src/main/java/rife/bld/operations/JavacOptions.java b/src/main/java/rife/bld/operations/JavacOptions.java
index bc2412f..9a88c64 100644
--- a/src/main/java/rife/bld/operations/JavacOptions.java
+++ b/src/main/java/rife/bld/operations/JavacOptions.java
@@ -9,10 +9,10 @@
import rife.tools.StringUtils;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
/**
* Options for the standard javac tool.
@@ -121,8 +121,48 @@ public JavacOptions endorsedDirs(File... dirs) {
* @since 1.5.18
*/
public JavacOptions endorsedDirs(List dirs) {
+ return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
+ }
+
+ /**
+ * Override location of endorsed standards path
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions endorsedDirs(Path... dirs) {
+ return endorsedDirsPaths(Arrays.asList(dirs));
+ }
+
+ /**
+ * Override location of endorsed standards path
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions endorsedDirsPaths(List dirs) {
+ return endorsedDirs(dirs.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * Override location of endorsed standards path
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions endorsedDirs(String... dirs) {
+ return endorsedDirsStrings(Arrays.asList(dirs));
+ }
+
+ /**
+ * Override location of endorsed standards path
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions endorsedDirsStrings(List dirs) {
add("-endorseddirs");
- add(dirs.stream().map(File::getAbsolutePath).collect(Collectors.joining(",")));
+ add(String.join(",", dirs));
return this;
}
@@ -143,8 +183,48 @@ public JavacOptions extDirs(File... dirs) {
* @since 1.5.18
*/
public JavacOptions extDirs(List dirs) {
+ return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions extDirs(Path... dirs) {
+ return extDirsPaths(Arrays.asList(dirs));
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions extDirsPaths(List dirs) {
+ return extDirs(dirs.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions extDirs(String... dirs) {
+ return extDirsStrings(Arrays.asList(dirs));
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions extDirsStrings(List dirs) {
add("-extdirs");
- add(dirs.stream().map(File::getAbsolutePath).collect(Collectors.joining(",")));
+ add(String.join(",", dirs));
return this;
}
@@ -193,8 +273,28 @@ public JavacOptions debuggingInfo(DebuggingInfo option) {
* @since 1.5.18
*/
public JavacOptions nativeHeaders(File path) {
+ return nativeHeaders(path.getAbsolutePath());
+ }
+
+ /**
+ * Specify where to place generated native header files
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions nativeHeaders(Path path) {
+ return nativeHeaders(path.toFile());
+ }
+
+ /**
+ * Specify where to place generated native header files
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions nativeHeaders(String path) {
add("-h");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
@@ -270,8 +370,48 @@ public JavacOptions modulePath(File... paths) {
* @since 1.6.2
*/
public JavacOptions modulePath(List paths) {
+ return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions modulePath(Path... paths) {
+ return modulePathPaths(Arrays.asList(paths));
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions modulePathPaths(List paths) {
+ return modulePath(paths.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions modulePath(String... paths) {
+ return modulePathStrings(Arrays.asList(paths));
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions modulePathStrings(List paths) {
add("--module-path");
- add(FileUtils.joinPaths(paths.stream().map(File::getAbsolutePath).toList()));
+ add(FileUtils.joinPaths(paths));
return this;
}
@@ -282,8 +422,28 @@ public JavacOptions modulePath(List paths) {
* @since 1.5.18
*/
public JavacOptions moduleSourcePath(File path) {
+ return moduleSourcePath(path.getAbsolutePath());
+ }
+
+ /**
+ * Specify where to find input source files for multiple modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions moduleSourcePath(Path path) {
+ return moduleSourcePath(path.toFile());
+ }
+
+ /**
+ * Specify where to find input source files for multiple modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions moduleSourcePath(String path) {
add("--module-source-path");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
@@ -361,8 +521,28 @@ public JavacOptions processors(List classnames) {
* @since 1.5.18
*/
public JavacOptions processorModulePath(File path) {
+ return processorModulePath(path.getAbsolutePath());
+ }
+
+ /**
+ * Specify a module path where to find annotation processors
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions processorModulePath(Path path) {
+ return processorModulePath(path.toFile());
+ }
+
+ /**
+ * Specify a module path where to find annotation processors
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions processorModulePath(String path) {
add("--processor-module-path");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
@@ -373,8 +553,28 @@ public JavacOptions processorModulePath(File path) {
* @since 1.5.18
*/
public JavacOptions processorPath(File path) {
+ return processorPath(path.getAbsolutePath());
+ }
+
+ /**
+ * Specify where to find annotation processors
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions processorPath(Path path) {
+ return processorPath(path.toFile());
+ }
+
+ /**
+ * Specify where to find annotation processors
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions processorPath(String path) {
add("--processor-path");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
@@ -409,8 +609,28 @@ public JavacOptions system(String option) {
* @since 1.5.18
*/
public JavacOptions upgradeModulePath(File path) {
+ return upgradeModulePath(path.getAbsolutePath());
+ }
+
+ /**
+ * Override location of upgradeable modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions upgradeModulePath(Path path) {
+ return upgradeModulePath(path.toFile());
+ }
+
+ /**
+ * Override location of upgradeable modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavacOptions upgradeModulePath(String path) {
add("--upgrade-module-path");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
diff --git a/src/main/java/rife/bld/operations/JavadocOptions.java b/src/main/java/rife/bld/operations/JavadocOptions.java
index dcc25ca..bd882eb 100644
--- a/src/main/java/rife/bld/operations/JavadocOptions.java
+++ b/src/main/java/rife/bld/operations/JavadocOptions.java
@@ -9,10 +9,10 @@
import rife.tools.StringUtils;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
/**
* Options for the standard javadoc tool.
@@ -178,8 +178,48 @@ public JavadocOptions extDirs(File... dirs) {
* @since 1.5.18
*/
public JavadocOptions extDirs(List dirs) {
+ return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions extDirs(Path... dirs) {
+ return extDirsPaths(Arrays.asList(dirs));
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions extDirsPaths(List dirs) {
+ return extDirs(dirs.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions extDirs(String... dirs) {
+ return extDirsStrings(Arrays.asList(dirs));
+ }
+
+ /**
+ * Override location of installed extensions
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions extDirsStrings(List dirs) {
add("-extdirs");
- add(dirs.stream().map(File::getAbsolutePath).collect(Collectors.joining(",")));
+ add(String.join(",", dirs));
return this;
}
@@ -256,8 +296,48 @@ public JavadocOptions modulePath(File... paths) {
* @since 1.6.3
*/
public JavadocOptions modulePath(List paths) {
+ return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions modulePath(Path... paths) {
+ return modulePathPaths(Arrays.asList(paths));
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions modulePathPaths(List paths) {
+ return modulePath(paths.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions modulePath(String... paths) {
+ return modulePathStrings(Arrays.asList(paths));
+ }
+
+ /**
+ * Specify where to find application modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions modulePathStrings(List paths) {
add("--module-path");
- add(FileUtils.joinPaths(paths.stream().map(File::getAbsolutePath).toList()));
+ add(FileUtils.joinPaths(paths));
return this;
}
@@ -268,8 +348,28 @@ public JavadocOptions modulePath(List paths) {
* @since 1.6.3
*/
public JavadocOptions moduleSourcePath(File path) {
+ return moduleSourcePath(path.getAbsolutePath());
+ }
+
+ /**
+ * Specify where to find input source files for multiple modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions moduleSourcePath(Path path) {
+ return moduleSourcePath(path.toFile());
+ }
+
+ /**
+ * Specify where to find input source files for multiple modules
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions moduleSourcePath(String path) {
add("--module-source-path");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
@@ -425,9 +525,29 @@ public JavadocOptions showTypes(Level option) {
* @return this list of options
* @since 1.5.12
*/
- public JavadocOptions addScript(File file) {
+ public JavadocOptions addScript(File path) {
+ return addScript(path.getAbsolutePath());
+ }
+
+ /**
+ * Add a script file to the generated documentation
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions addScript(Path path) {
+ return addScript(path.toFile());
+ }
+
+ /**
+ * Add a script file to the generated documentation
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions addScript(String path) {
add("--add-script");
- add(file.getAbsolutePath());
+ add(path);
return this;
}
@@ -437,9 +557,29 @@ public JavadocOptions addScript(File file) {
* @return this list of options
* @since 1.5.12
*/
- public JavadocOptions addStylesheet(File file) {
+ public JavadocOptions addStylesheet(File path) {
+ return addStylesheet(path.getAbsolutePath());
+ }
+
+ /**
+ * Add a stylesheet file to the generated documentation
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions addStylesheet(Path path) {
+ return addStylesheet(path.toFile());
+ }
+
+ /**
+ * Add a stylesheet file to the generated documentation
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions addStylesheet(String path) {
add("--add-stylesheet");
- add(file.getAbsolutePath());
+ add(path);
return this;
}
@@ -578,9 +718,29 @@ public JavadocOptions linkSource() {
* @return this list of options
* @since 1.5.12
*/
- public JavadocOptions stylesheet(File file) {
+ public JavadocOptions stylesheet(File path) {
+ return stylesheet(path.getAbsolutePath());
+ }
+
+ /**
+ * File to change style of the generated documentation
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions stylesheet(Path path) {
+ return stylesheet(path.toFile());
+ }
+
+ /**
+ * File to change style of the generated documentation
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions stylesheet(String path) {
add("--main-stylesheet");
- add(file.getAbsolutePath());
+ add(path);
return this;
}
@@ -735,9 +895,29 @@ public JavadocOptions overrideMethods(Override option) {
* @return this list of options
* @since 1.5.18
*/
- public JavadocOptions overview(File htmlFile) {
+ public JavadocOptions overview(File path) {
+ return overview(path.getAbsolutePath());
+ }
+
+ /**
+ * Read overview documentation from HTML file
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions overview(Path path) {
+ return overview(path.toFile());
+ }
+
+ /**
+ * Read overview documentation from HTML file
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions overview(String path) {
add("-overview");
- add(htmlFile.getAbsolutePath());
+ add(path);
return this;
}
@@ -793,8 +973,28 @@ public JavadocOptions sinceLabel(String text) {
* @since 1.5.12
*/
public JavadocOptions snippetPath(File path) {
+ return snippetPath(path.getAbsolutePath());
+ }
+
+ /**
+ * The path for external snippets
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions snippetPath(Path path) {
+ return snippetPath(path.toFile());
+ }
+
+ /**
+ * The path for external snippets
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions snippetPath(String path) {
add("--snippet-path");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
@@ -852,8 +1052,28 @@ public JavadocOptions taglet(String name) {
* @since 1.5.12
*/
public JavadocOptions tagletPath(File path) {
+ return tagletPath(path.getAbsolutePath());
+ }
+
+ /**
+ * The path to Taglets
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions tagletPath(Path path) {
+ return tagletPath(path.toFile());
+ }
+
+ /**
+ * The path to Taglets
+ *
+ * @return this list of options
+ * @since 2.1
+ */
+ public JavadocOptions tagletPath(String path) {
add("-tagletpath");
- add(path.getAbsolutePath());
+ add(path);
return this;
}
diff --git a/src/main/java/rife/bld/operations/RunOperation.java b/src/main/java/rife/bld/operations/RunOperation.java
index e59f6e2..49e9a76 100644
--- a/src/main/java/rife/bld/operations/RunOperation.java
+++ b/src/main/java/rife/bld/operations/RunOperation.java
@@ -31,16 +31,27 @@ protected List executeConstructProcessCommandList() {
var args = new ArrayList();
args.add(javaTool());
args.addAll(javaOptions());
+
if (!classpath().isEmpty()) {
args.add("-cp");
args.add(FileUtils.joinPaths(classpath()));
}
+
if (!modulePath().isEmpty()) {
args.add("-p");
args.add(FileUtils.joinPaths(modulePath()));
}
- args.add(mainClass());
+
+ if (module() != null && !module().isEmpty()) {
+ args.add("-m");
+ args.add(module());
+ }
+ else if (mainClass() != null && !mainClass().isEmpty()){
+ args.add(mainClass());
+ }
+
args.addAll(runOptions());
+
return args;
}
@@ -55,7 +66,8 @@ public RunOperation fromProject(BaseProject project) {
.javaTool(project.javaTool())
.classpath(project.runClasspath())
.modulePath(project.runModulePath())
- .mainClass(project.mainClass());
+ .mainClass(project.mainClass())
+ .module(project.module());
if (project.usesRife2Agent()) {
operation.javaOptions().javaAgent(project.getRife2AgentFile());
}
diff --git a/src/test/java/rife/bld/TestProject.java b/src/test/java/rife/bld/TestProject.java
index 6b3da04..7bade12 100644
--- a/src/test/java/rife/bld/TestProject.java
+++ b/src/test/java/rife/bld/TestProject.java
@@ -35,7 +35,7 @@ void testInstantiation() {
assertNull(project.version);
assertThrows(IllegalStateException.class, project::version);
assertNull(project.mainClass);
- assertThrows(IllegalStateException.class, project::mainClass);
+ assertNull(project.module);
assertNotNull(project.repositories);
assertTrue(project.repositories.isEmpty());
diff --git a/src/test/java/rife/bld/TestWebProject.java b/src/test/java/rife/bld/TestWebProject.java
index 79816c9..cfbb484 100644
--- a/src/test/java/rife/bld/TestWebProject.java
+++ b/src/test/java/rife/bld/TestWebProject.java
@@ -33,7 +33,7 @@ void testInstantiation() {
assertNull(project.version);
assertThrows(IllegalStateException.class, project::version);
assertNull(project.mainClass);
- assertThrows(IllegalStateException.class, project::mainClass);
+ assertNull(project.module);
assertNotNull(project.repositories);
assertTrue(project.repositories.isEmpty());
diff --git a/src/test/java/rife/bld/operations/TestRunOperation.java b/src/test/java/rife/bld/operations/TestRunOperation.java
index 6073ee6..5be7391 100644
--- a/src/test/java/rife/bld/operations/TestRunOperation.java
+++ b/src/test/java/rife/bld/operations/TestRunOperation.java
@@ -5,12 +5,14 @@
package rife.bld.operations;
import org.junit.jupiter.api.Test;
+import rife.bld.NamedFile;
import rife.tools.FileUtils;
import java.io.File;
import java.nio.file.Files;
import java.util.List;
import java.util.function.Function;
+import java.util.jar.Attributes;
import static org.junit.jupiter.api.Assertions.*;
@@ -26,6 +28,7 @@ void testInstantiation() {
assertTrue(operation.javaOptions().isEmpty());
assertTrue(operation.classpath().isEmpty());
assertNull(operation.mainClass());
+ assertNull(operation.module());
assertTrue(operation.runOptions().isEmpty());
assertNull(operation.outputProcessor());
assertNull(operation.errorProcessor());
@@ -45,6 +48,7 @@ void testPopulation()
var run_option1 = "runOption1";
var run_option2 = "runOption2";
var main_class = "mainClass";
+ var module = "module";
Function run_output_consumer = (String) -> true;
Function run_error_consumer = (String) -> true;
@@ -55,6 +59,7 @@ void testPopulation()
.javaOptions(List.of(run_java_option1, run_java_option2))
.classpath(List.of(run_classpath1, run_classpath2))
.mainClass(main_class)
+ .module(module)
.runOptions(List.of(run_option1, run_option2))
.outputProcessor(run_output_consumer)
.errorProcessor(run_error_consumer);
@@ -66,6 +71,7 @@ void testPopulation()
assertTrue(operation1.classpath().contains(run_classpath1));
assertTrue(operation1.classpath().contains(run_classpath2));
assertEquals(main_class, operation1.mainClass());
+ assertEquals(module, operation1.module());
assertTrue(operation1.runOptions().contains(run_option1));
assertTrue(operation1.runOptions().contains(run_option2));
assertSame(run_output_consumer, operation1.outputProcessor());
@@ -79,6 +85,7 @@ void testPopulation()
operation2.classpath().add(run_classpath1);
operation2.classpath().add(run_classpath2);
operation2.mainClass(main_class);
+ operation2.module(module);
operation2.runOptions().add(run_option1);
operation2.runOptions().add(run_option2);
operation2.outputProcessor(run_output_consumer);
@@ -91,6 +98,7 @@ void testPopulation()
assertTrue(operation2.classpath().contains(run_classpath1));
assertTrue(operation2.classpath().contains(run_classpath2));
assertEquals(main_class, operation2.mainClass());
+ assertEquals(module, operation2.module());
assertTrue(operation2.runOptions().contains(run_option1));
assertTrue(operation2.runOptions().contains(run_option2));
assertSame(run_output_consumer, operation2.outputProcessor());
@@ -155,6 +163,71 @@ public static void main(String[] arguments)
}
}
+ @Test
+ void testExecuteModule()
+ throws Exception {
+ var tmp = Files.createTempDirectory("test").toFile();
+ try {
+ var pkg = new File(tmp, "pkg");
+ pkg.mkdirs();
+ var source_file1 = new File(pkg, "Source1.java");
+ var source_file2 = new File(pkg, "module-info.java");
+
+ FileUtils.writeString("""
+ package pkg;
+
+ public class Source1 {
+ public final String name_;
+ public Source1() {
+ name_ = "source1";
+ }
+
+ public static void main(String[] arguments)
+ throws Exception {
+ System.out.print(new Source1().name_);
+ }
+ }
+ """, source_file1);
+
+ FileUtils.writeString("""
+ module pkg {
+ requires java.desktop;
+ }
+ """, source_file2);
+ var build_main = new File(tmp, "buildMain");
+
+ var compile_operation = new CompileOperation()
+ .buildMainDirectory(build_main)
+ .compileMainClasspath(List.of(build_main.getAbsolutePath()))
+ .mainSourceFiles(List.of(source_file1, source_file2));
+ compile_operation.execute();
+ assertTrue(compile_operation.diagnostics().isEmpty());
+
+ var destination_dir = new File(tmp, "destination");
+ var destination_name = "pkg.jar";
+ new JarOperation()
+ .sourceDirectories(List.of(build_main))
+ .destinationDirectory(destination_dir)
+ .destinationFileName(destination_name)
+ .manifestAttribute(Attributes.Name.MAIN_CLASS, "pkg.Source1")
+ .execute();
+
+ var output = new StringBuilder();
+ var run_operation = new RunOperation()
+ .module("pkg/pkg.Source1")
+ .modulePath(new File(destination_dir, destination_name).getAbsolutePath())
+ .outputProcessor(s -> {
+ output.append(s);
+ return true;
+ });
+ run_operation.execute();
+
+ assertEquals("source1", output.toString());
+ } finally {
+ FileUtils.deleteDirectory(tmp);
+ }
+ }
+
@Test
void testFromProject()
throws Exception {