Skip to content

Commit

Permalink
Added JavacOptions, JavadocOptions and JavaOptions File argument alte…
Browse files Browse the repository at this point in the history
…rnatives with Path and String.

Relaxed the requirement to specify mainClass in a project and added support for module.
  • Loading branch information
gbevin committed Aug 25, 2024
1 parent 126daec commit 9f9e8a9
Show file tree
Hide file tree
Showing 9 changed files with 861 additions and 47 deletions.
28 changes: 24 additions & 4 deletions src/main/java/rife/bld/BaseProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
* <p>
Expand Down Expand Up @@ -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.");
}

/**
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/rife/bld/operations/AbstractProcessOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
protected final List<String> classpath_ = new ArrayList<>();
protected final List<String> modulePath_ = new ArrayList<>();
protected String mainClass_;
protected String module_;
protected Function<String, Boolean> outputProcessor_;
protected Function<String, Boolean> errorProcessor_;
protected Process process_;
Expand Down Expand Up @@ -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.
* <p>
Expand Down Expand Up @@ -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.
*
Expand Down
Loading

0 comments on commit 9f9e8a9

Please sign in to comment.