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/10/25 03:15:43 UTC

[groovy] branch GROOVY-11194_groovy30 created (now 8ec47959b4)

This is an automated email from the ASF dual-hosted git repository.

keegan pushed a change to branch GROOVY-11194_groovy30
in repository https://gitbox.apache.org/repos/asf/groovy.git


      at 8ec47959b4 GROOVY-11194: Add missing options

This branch includes the following new commits:

     new 8ec47959b4 GROOVY-11194: Add missing options

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[groovy] 01/01: GROOVY-11194: Add missing options

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

keegan pushed a commit to branch GROOVY-11194_groovy30
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 8ec47959b46bc95b93a0298ba81ca864709be406
Author: Keegan Witt <ke...@gmail.com>
AuthorDate: Mon Oct 23 22:08:20 2023 -0400

    GROOVY-11194: Add missing options
---
 .../codehaus/groovy/tools/FileSystemCompiler.java  | 31 +++++++++++++++++++++-
 1 file changed, 30 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 9b41c2b39e..d6318c1075 100644
--- a/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
+++ b/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
@@ -22,6 +22,7 @@ import groovy.lang.GroovySystem;
 import org.codehaus.groovy.control.CompilationUnit;
 import org.codehaus.groovy.control.CompilerConfiguration;
 import org.codehaus.groovy.control.ConfigurationException;
+import org.codehaus.groovy.control.messages.WarningMessage;
 import org.codehaus.groovy.runtime.DefaultGroovyStaticMethods;
 import org.codehaus.groovy.runtime.StringGroovyMethods;
 import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit;
@@ -357,12 +358,21 @@ 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;
 
+        @Option(names = {"-pl", "--parallel-parsing"}, description = "Enable parallel parsing")
+        private boolean parallelParsing;
+
         @Option(names = {"-pr", "--enable-preview"}, description = "Enable preview Java features (jdk12+ only) - must be after classpath but before other arguments")
         private boolean previewFeatures;
 
@@ -381,9 +391,12 @@ public class FileSystemCompiler {
         @Option(names = {"--indy"}, description = "Enables compilation using invokedynamic")
         private boolean indy;
 
-        @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;
 
@@ -416,6 +429,18 @@ 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) {
@@ -430,6 +455,10 @@ public class FileSystemCompiler {
                 configuration.getOptimizationOptions().put("indy", Boolean.TRUE);
             }
 
+            if (parallelParsing) {
+                configuration.getOptimizationOptions().put("parallelParse", true);
+            }
+
             final List<String> transformations = new ArrayList<>();
             if (compileStatic) {
                 transformations.add("ast(groovy.transform.CompileStatic)");