db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1325093 - /db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java
Date Thu, 12 Apr 2012 01:30:03 GMT
Author: tfischer
Date: Thu Apr 12 01:30:02 2012
New Revision: 1325093

URL: http://svn.apache.org/viewvc?rev=1325093&view=rev
Log:
- Bugfix: Process excludes also if no includes are defined
- improve trace logging for excludes
- sort path names so the generation order is the same for all systems

Modified:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java?rev=1325093&r1=1325092&r2=1325093&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java
Thu Apr 12 01:30:02 2012
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
@@ -158,60 +159,87 @@ public class Fileset
         if (includes == null || includes.isEmpty())
         {
             getAllFiles(basedir, result);
-            return result;
         }
-        // process includes
-        for (String includePattern : includes)
+        else
         {
-            int wildcardFreeSeparatorPos
-                    = getWildcardFreeSeparatorPos(includePattern);
-            String wildcardFreeIncludePart = getPathPartBefore(
-                    includePattern,
-                    wildcardFreeSeparatorPos);
-            if (log.isTraceEnabled())
+            // process includes
+            for (String includePattern : includes)
             {
-                log.trace("getFiles() : traversing directory "
-                        + wildcardFreeIncludePart
-                        + " in base dir "
-                        + basedir);
-            }
-            File wildcardFreeBaseDir = new File(
-                    basedir,
-                    wildcardFreeIncludePart);
-            String wildcardPattern
-                = getPathPartAfter(includePattern, wildcardFreeSeparatorPos);
-            String[] wildcardParts = StringUtils.split(wildcardPattern, "\\/");
-            List<String> wildcardPartList = Arrays.asList(wildcardParts);
-
-            List<File> includeFiles = getFiles(
-                    wildcardFreeBaseDir,
-                    wildcardPartList);
-            result.addAll(includeFiles);
+                int wildcardFreeSeparatorPos
+                        = getWildcardFreeSeparatorPos(includePattern);
+                String wildcardFreeIncludePart = getPathPartBefore(
+                        includePattern,
+                        wildcardFreeSeparatorPos);
+                if (log.isTraceEnabled())
+                {
+                    log.trace("getFiles() : traversing directory "
+                            + wildcardFreeIncludePart
+                            + " in base dir "
+                            + basedir);
+                }
+                File wildcardFreeBaseDir = new File(
+                        basedir,
+                        wildcardFreeIncludePart);
+                String wildcardPattern
+                    = getPathPartAfter(includePattern, wildcardFreeSeparatorPos);
+                String[] wildcardParts = StringUtils.split(wildcardPattern, "\\/");
+                List<String> wildcardPartList = Arrays.asList(wildcardParts);
+
+                List<File> includeFiles = getFiles(
+                        wildcardFreeBaseDir,
+                        wildcardPartList);
+                result.addAll(includeFiles);
+            }
         }
         // process excludes
         if (excludes == null)
         {
+            if (log.isTraceEnabled())
+            {
+                log.trace("getFiles() : no excludes are defined.");
+            }
             return result;
         }
         Iterator<File> fileIt = result.iterator();
         while (fileIt.hasNext())
         {
             File file = fileIt.next();
+            if (log.isTraceEnabled())
+            {
+                log.trace("getFiles() : checking excludes for file "
+                        + file.getPath());
+            }
             boolean excluded = false;
             for (String excludePattern : excludes)
             {
                 File excludePatternFile = new File(basedir, excludePattern);
                 if (matchesPattern(file, excludePatternFile.getPath()))
                 {
+                    if (log.isTraceEnabled())
+                    {
+                        log.trace("getFiles() : exclude pattern "
+                                + excludePatternFile.getPath()
+                                + " matches, file is excluded");
+                    }
                     excluded = true;
                     break;
                 }
+                else if (log.isTraceEnabled())
+                {
+                    log.trace("getFiles() : exclude pattern "
+                            + excludePatternFile.getPath()
+                            + " does not match");
+                }
             }
             if (excluded)
             {
                 fileIt.remove();
             }
         }
+
+        // make file order reproducable
+        Collections.sort(result);
+
         return result;
     }
 



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


Mime
View raw message