Add support for --add-reads, --default-module-for-created-files and --patch-module in JavacOptions

This commit is contained in:
Erik C. Thauvin 2025-12-27 18:39:05 -08:00
parent db2adfaf7f
commit e1765804e0
No known key found for this signature in database
GPG key ID: 776702A6A2DA330E

View file

@ -72,6 +72,30 @@ public class JavacOptions extends ArrayList<String> {
return this; return this;
} }
/**
* Specifies additional modules to be considered as required by a given
* module
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addReads(String... modules) {
return addReads(Arrays.asList(modules));
}
/**
* Specifies additional modules to be considered as required by a given
* module
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addReads(List<String> modules) {
add("--add-reads");
add(StringUtils.join(modules, ","));
return this;
}
/** /**
* Root modules to resolve in addition to the initial modules, * Root modules to resolve in addition to the initial modules,
* or all modules on the module path if a module is * or all modules on the module path if a module is
@ -110,6 +134,19 @@ public class JavacOptions extends ArrayList<String> {
return this; return this;
} }
/**
* Fallback target module for files created by annotation processors,
* if none specified or inferred
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions defaultModuleForCreatedFiles(String module) {
add("--default-module-for-created-files");
add(module);
return this;
}
/** /**
* Output source locations where deprecated APIs are used * Output source locations where deprecated APIs are used
* *
@ -267,6 +304,18 @@ public class JavacOptions extends ArrayList<String> {
return contains("-release"); return contains("-release");
} }
/**
* Overrides or augments a module with classes and resources in JAR files or directories
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions patchModule(String module) {
add("--patch-module");
add(module);
return this;
}
/** /**
* Compile for the specified Java SE release. * Compile for the specified Java SE release.
* *