You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by ke...@apache.org on 2023/11/22 00:58:08 UTC
(groovy) 01/01: GROOVY-11194: Add missing options
This is an automated email from the ASF dual-hosted git repository.
keegan pushed a commit to branch GROOVY-11194_groovy40
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 05de4a220aa9fe7b256a01f50e7e2bc5de047f62
Author: Keegan Witt <ke...@gmail.com>
AuthorDate: Tue Nov 21 19:57:50 2023 -0500
GROOVY-11194: Add missing options
---
.../codehaus/groovy/tools/FileSystemCompiler.java | 35 +++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java b/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
index 0de934a3ae..4a735d75bb 100644
--- a/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
+++ b/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
@@ -357,9 +357,15 @@ public class FileSystemCompiler {
@Option(names = "-d", paramLabel = "<dir>", description = "Specify where to place generated class files")
private File targetDir;
+ @Option(names = {"-de", "--debug"}, description = "If set, outputs a little more information during compilation when errors occur.")
+ private boolean debug;
+
@Option(names = {"-e", "--exception"}, description = "Print stack trace on error")
private boolean printStack;
+ @Option(names = {"-w", "--warningLevel"}, description = "The amount of warnings to print. Set to 0 for none, 1 for likely errors, 2 for possible errors, and 3 for as many warnings as possible.", defaultValue = "1")
+ private String warningLevel;
+
@Option(names = {"-pa", "--parameters"}, description = "Generate metadata for reflection on method parameter names (jdk8+ only)")
private boolean parameterMetadata;
@@ -369,6 +375,12 @@ public class FileSystemCompiler {
@Option(names = {"-j", "--jointCompilation"}, description = "Attach javac compiler to compile .java files")
private boolean jointCompilation;
+ @Option(names = {"-s", "--stubDirectory"}, description = "The directory into which the Java source stub files should be generated")
+ private String stubDirectory;
+
+ @Option(names = {"-ks", "--keepStubs"}, description = "Whether to keep the generated stubs rather than deleting them")
+ private boolean keepStubs;
+
@Option(names = {"-b", "--basescript"}, paramLabel = "<class>", description = "Base class name for scripts (must derive from Script)")
private String scriptBaseClass;
@@ -378,9 +390,12 @@ public class FileSystemCompiler {
@Option(names = "-F", paramLabel = "<flag>", description = "Passed to javac for joint compilation")
private List<String> flags;
- @Option(names = {"--configscript"}, paramLabel = "<script>", description = "A script for tweaking the configuration options")
+ @Option(names = {"-cf", "--configscript"}, paramLabel = "<script>", description = "A script for tweaking the configuration options")
private String configScript;
+ @Option(names = {"-t", "--tolerance"}, description = "The number of non-fatal errors to allow before bailing")
+ private int tolerance;
+
@Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message and exit")
private boolean helpRequested;
@@ -413,12 +428,30 @@ public class FileSystemCompiler {
configuration.setPreviewFeatures(previewFeatures);
configuration.setSourceEncoding(encoding);
configuration.setScriptBaseClass(scriptBaseClass);
+ if (tolerance > 0) {
+ configuration.setTolerance(tolerance);
+ }
+
+ if (Integer.parseInt(warningLevel) == WarningMessage.NONE
+ || Integer.parseInt(warningLevel) == WarningMessage.LIKELY_ERRORS
+ || Integer.parseInt(warningLevel) == WarningMessage.POSSIBLE_ERRORS
+ || Integer.parseInt(warningLevel) == WarningMessage.PARANOIA) {
+ configuration.setWarningLevel(Integer.parseInt(warningLevel));
+ } else {
+ System.err.println("error: warning level not recognized: " + warningLevel);
+ }
// joint compilation parameters
if (jointCompilation) {
Map<String, Object> compilerOptions = new HashMap<>();
compilerOptions.put("flags", javacFlags());
compilerOptions.put("namedValues", javacNamedValues());
+ if (stubDirectory != null) {
+ compilerOptions.put("stubDir", stubDirectory);
+ }
+ if (keepStubs) {
+ compilerOptions.put("keepStubs", true);
+ }
configuration.setJointCompilationOptions(compilerOptions);
}