ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r566990 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs: compilers/Jikes.java optional/junit/JUnitTask.java
Date Fri, 17 Aug 2007 09:54:08 GMT
Author: peterreilly
Date: Fri Aug 17 02:54:07 2007
New Revision: 566990

URL: http://svn.apache.org/viewvc?view=rev&rev=566990
Log:
reduce method length

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java?view=diff&rev=566990&r1=566989&r2=566990
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java Fri Aug 17
02:54:07 2007
@@ -131,6 +131,36 @@
             cmd.createArgument().setValue(target);
         }
 
+        addPropertyParams(cmd);
+
+        if (attributes.getSource() != null) {
+            cmd.createArgument().setValue("-source");
+            String source = attributes.getSource();
+            if (source.equals("1.1") || source.equals("1.2")) {
+                // support for -source 1.1 and -source 1.2 has been
+                // added with JDK 1.4.2, Jikes doesn't like it
+                attributes.log("Jikes doesn't support '-source " + source
+                        + "', will use '-source 1.3' instead");
+                cmd.createArgument().setValue("1.3");
+            } else {
+                cmd.createArgument().setValue(source);
+            }
+        }
+        addCurrentCompilerArgs(cmd);
+
+        int firstFileName = cmd.size();
+
+        Path boot = getBootClassPath();
+        if (boot.size() > 0) {
+            cmd.createArgument().setValue("-bootclasspath");
+            cmd.createArgument().setPath(boot);
+        }
+        logAndAddFilesToCompile(cmd);
+
+        return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
+    }
+
+    private void addPropertyParams(Commandline cmd) {
         /**
          * XXX
          * Perhaps we shouldn't use properties for these
@@ -186,32 +216,6 @@
             && Project.toBoolean(fullDependProperty)) {
             cmd.createArgument().setValue("+F");
         }
-
-        if (attributes.getSource() != null) {
-            cmd.createArgument().setValue("-source");
-            String source = attributes.getSource();
-            if (source.equals("1.1") || source.equals("1.2")) {
-                // support for -source 1.1 and -source 1.2 has been
-                // added with JDK 1.4.2, Jikes doesn't like it
-                attributes.log("Jikes doesn't support '-source " + source
-                        + "', will use '-source 1.3' instead");
-                cmd.createArgument().setValue("1.3");
-            } else {
-                cmd.createArgument().setValue(source);
-            }
-        }
-        addCurrentCompilerArgs(cmd);
-
-        int firstFileName = cmd.size();
-
-        Path boot = getBootClassPath();
-        if (boot.size() > 0) {
-            cmd.createArgument().setValue("-bootclasspath");
-            cmd.createArgument().setPath(boot);
-        }
-        logAndAddFilesToCompile(cmd);
-
-        return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
     }
 
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?view=diff&rev=566990&r1=566989&r2=566990
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Fri
Aug 17 02:54:07 2007
@@ -926,34 +926,9 @@
         cmd.createArgument().setValue(Constants.HALT_ON_ERROR + test.getHaltonerror());
         cmd.createArgument().setValue(Constants.HALT_ON_FAILURE
                                       + test.getHaltonfailure());
-        if (includeAntRuntime) {
-            Vector v = Execute.getProcEnvironment();
-            Enumeration e = v.elements();
-            while (e.hasMoreElements()) {
-                String s = (String) e.nextElement();
-                if (s.startsWith(CLASSPATH)) {
-                    cmd.createClasspath(getProject()).createPath()
-                        .append(new Path(getProject(),
-                                         s.substring(CLASSPATH.length()
-                                                     )));
-                }
-            }
-            log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
-                Project.MSG_VERBOSE);
-            cmd.createClasspath(getProject()).createPath()
-                .append(antRuntimeClasses);
-        }
+        checkIncludeAntRuntime(cmd);
 
-        if (summary) {
-            String prefix = "";
-            if ("withoutanderr".equalsIgnoreCase(summaryValue)) {
-                prefix = "OutErr";
-            }
-            cmd.createArgument()
-                .setValue(Constants.FORMATTER
-                          + "org.apache.tools.ant.taskdefs.optional.junit."
-                          + prefix + "SummaryJUnitResultFormatter");
-        }
+        checkIncludeSummary(cmd);
 
         cmd.createArgument().setValue(Constants.SHOWOUTPUT
                                       + String.valueOf(showOutput));
@@ -1070,6 +1045,42 @@
         }
 
         return result;
+    }
+
+    /**
+     * Adding ant runtime.
+     */
+    private void checkIncludeAntRuntime(CommandlineJava cmd) {
+        if (includeAntRuntime) {
+            Vector v = Execute.getProcEnvironment();
+            Enumeration e = v.elements();
+            while (e.hasMoreElements()) {
+                String s = (String) e.nextElement();
+                if (s.startsWith(CLASSPATH)) {
+                    cmd.createClasspath(getProject()).createPath()
+                        .append(new Path(getProject(),
+                                         s.substring(CLASSPATH.length()
+                                                     )));
+                }
+            }
+            log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
+                Project.MSG_VERBOSE);
+            cmd.createClasspath(getProject()).createPath()
+                .append(antRuntimeClasses);
+        }
+    }
+
+    private void checkIncludeSummary(CommandlineJava cmd) {
+        if (summary) {
+            String prefix = "";
+            if ("withoutanderr".equalsIgnoreCase(summaryValue)) {
+                prefix = "OutErr";
+            }
+            cmd.createArgument()
+                .setValue(Constants.FORMATTER
+                          + "org.apache.tools.ant.taskdefs.optional.junit."
+                          + prefix + "SummaryJUnitResultFormatter");
+        }
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message