You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2016/03/21 12:21:15 UTC

[4/5] ant git commit: some cosmetic changes

some cosmetic changes


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/b2558bc9
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/b2558bc9
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/b2558bc9

Branch: refs/heads/master
Commit: b2558bc972d8edaf6fc59bda833669b19d5233d4
Parents: ea99177
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon Mar 21 12:11:33 2016 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon Mar 21 12:11:33 2016 +0100

----------------------------------------------------------------------
 .../org/apache/tools/ant/taskdefs/Javac.java    | 80 +++++++++++---------
 1 file changed, 44 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/b2558bc9/src/main/org/apache/tools/ant/taskdefs/Javac.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java
index 1b6f340..92a938f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@ -1061,42 +1061,10 @@ public class Javac extends MatchingTask {
         // scan source directories and dest directory to build up
         // compile list
         if (hasPath(src)) {
-            final String[] list = src.list();
-            for (int i = 0; i < list.length; i++) {
-                final File srcDir = getProject().resolveFile(list[i]);
-                if (!srcDir.exists()) {
-                    throw new BuildException("srcdir \""
-                                             + srcDir.getPath()
-                                             + "\" does not exist!", getLocation());
-                }
-
-                final DirectoryScanner ds = this.getDirectoryScanner(srcDir);
-                final String[] files = ds.getIncludedFiles();
-
-                scanDir(srcDir, destDir != null ? destDir : srcDir, files);
-            }
+            collectFileListFromSourcePath();
         } else {
             assert hasPath(moduleSourcepath) : "Either srcDir or moduleSourcepath must be given";
-            final FileUtils fu = FileUtils.getFileUtils();
-            for (String pathElement : moduleSourcepath.list()) {
-                boolean valid = false;
-                for (Map.Entry<String,Collection<File>> modules : resolveModuleSourcePathElement(getProject().getBaseDir(), pathElement).entrySet()) {
-                    final String moduleName = modules.getKey();
-                    for (File srcDir : modules.getValue()) {
-                        if (srcDir.exists()) {
-                            valid = true;
-                            final DirectoryScanner ds = getDirectoryScanner(srcDir);
-                            final String[] files = ds.getIncludedFiles();
-                            scanDir(srcDir, fu.resolveFile(destDir, moduleName), files);
-                        }
-                    }
-                }
-                if (!valid) {
-                    throw new BuildException("modulesourcepath \""
-                                             + pathElement
-                                             + "\" does not exist!", getLocation());
-                }
-            }
+            collectFileListFromModulePath();
         }
 
         compile();
@@ -1146,6 +1114,46 @@ public class Javac extends MatchingTask {
         }
     }
 
+    private void collectFileListFromSourcePath() {
+        final String[] list = src.list();
+        for (int i = 0; i < list.length; i++) {
+            final File srcDir = getProject().resolveFile(list[i]);
+            if (!srcDir.exists()) {
+                throw new BuildException("srcdir \""
+                                         + srcDir.getPath()
+                                         + "\" does not exist!", getLocation());
+            }
+
+            final DirectoryScanner ds = this.getDirectoryScanner(srcDir);
+            final String[] files = ds.getIncludedFiles();
+
+            scanDir(srcDir, destDir != null ? destDir : srcDir, files);
+        }
+    }
+    
+    private void collectFileListFromModulePath() {
+        final FileUtils fu = FileUtils.getFileUtils();
+        for (String pathElement : moduleSourcepath.list()) {
+            boolean valid = false;
+            for (Map.Entry<String,Collection<File>> modules : resolveModuleSourcePathElement(getProject().getBaseDir(), pathElement).entrySet()) {
+                final String moduleName = modules.getKey();
+                for (File srcDir : modules.getValue()) {
+                    if (srcDir.exists()) {
+                        valid = true;
+                        final DirectoryScanner ds = getDirectoryScanner(srcDir);
+                        final String[] files = ds.getIncludedFiles();
+                        scanDir(srcDir, fu.resolveFile(destDir, moduleName), files);
+                    }
+                }
+            }
+            if (!valid) {
+                throw new BuildException("modulesourcepath \""
+                                         + pathElement
+                                         + "\" does not exist!", getLocation());
+            }
+        }
+    }
+
     private String[] findSupportedFileExtensions() {
         final String compilerImpl = getCompiler();
         final CompilerAdapter adapter =
@@ -1601,10 +1609,10 @@ public class Javac extends MatchingTask {
             if (pattern.indexOf(MODULE_MARKER, endIndex) != -1) {
                 throw new BuildException("The modulesourcepath entry must contain at most one module mark");
             }
-            final String pathToModule = pattern.substring(0,startIndex);
+            final String pathToModule = pattern.substring(0, startIndex);
             final String pathInModule = endIndex == pattern.length() ?
                     null :
-                    pattern.substring(endIndex+1);  //+1 the separator
+                    pattern.substring(endIndex + 1);  //+1 the separator
             findModules(root, pathToModule, pathInModule, collector);
         }
     }