ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r1062831 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/ant/IvyRetrieve.java src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
Date Mon, 24 Jan 2011 15:32:42 GMT
Author: maartenc
Date: Mon Jan 24 15:32:42 2011
New Revision: 1062831

URL: http://svn.apache.org/viewvc?rev=1062831&view=rev
Log:
IMPROVEMENT: ivy:retrieve can now convert 'dotted'-organisation names into a directory tree.

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1062831&r1=1062830&r2=1062831&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon Jan 24 15:32:42 2011
@@ -117,6 +117,8 @@ for detailed view of each issue, please 
 - NEW: ivy:resolve and post resole task can now have inlined dependencies declaration.
 - NEW: Import Bushel into Ivy core (IVY-1241)
 
+- IMPROVEMENT: ivy:retrieve can now convert 'dotted'-organisation names into a directory
tree.
+
 - FIX: Dynamic version resolution result can be incorrect when ivy metadata contains extra
attributes (IVY-1236)
 - FIX: NullPointerException in FileUtil#forceDelete.
 - FIX: XmlModuleDescriptorUpdater is a mess that produces broken xmls in many cases (IVY-1010)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java?rev=1062831&r1=1062830&r2=1062831&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java Mon Jan 24 15:32:42 2011
@@ -35,6 +35,10 @@ public class IvyRetrieve extends IvyPost
             RetrieveOptions.OVERWRITEMODE_NEWER, RetrieveOptions.OVERWRITEMODE_DIFFERENT
     });
 
+    private static final Collection DIRMODE_VALUES = Arrays.asList(new String[] {
+            RetrieveOptions.DIRMODE_FLAT, RetrieveOptions.DIRMODE_TREE
+    });
+
     private String pattern;
 
     private String ivypattern = null;
@@ -45,6 +49,8 @@ public class IvyRetrieve extends IvyPost
     
     private String overwriteMode = RetrieveOptions.OVERWRITEMODE_NEWER;
 
+    private String dirMode = RetrieveOptions.DIRMODE_FLAT;
+
     public String getPattern() {
         return pattern;
     }
@@ -74,6 +80,7 @@ public class IvyRetrieve extends IvyPost
                     .setArtifactFilter(artifactFilter)
                     .setSync(sync)
                     .setOverwriteMode(getOverwriteMode())
+                    .setDirMode(getDirMode())
                     .setUseOrigin(isUseOrigin())
                     .setMakeSymlinks(symlink)
                     .setResolveId(getResolveId()));
@@ -124,4 +131,16 @@ public class IvyRetrieve extends IvyPost
     public String getOverwriteMode() {
         return overwriteMode;
     }
+
+    public void setDirMode(String dirMode) {
+        if (!DIRMODE_VALUES.contains(dirMode)) {
+            throw new IllegalArgumentException("invalid dirMode value '" + dirMode + "'.
"
+                + "Valid values are " + DIRMODE_VALUES);
+        }
+        this.dirMode = dirMode;
+    }
+
+    public String getDirMode() {
+        return dirMode;
+    }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java?rev=1062831&r1=1062830&r2=1062831&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java Mon Jan 24
15:32:42 2011
@@ -304,9 +304,20 @@ public class RetrieveEngine {
                     continue; // skip this artifact, the filter didn't accept it!
                 }
 
-                String destFileName = IvyPatternHelper.substitute(destPattern, 
-                        artifact.getArtifact().getModuleRevisionId(), artifact.getArtifact(),

-                        conf, artifact.getArtifactOrigin());
+                String destFileName;
+                if (RetrieveOptions.DIRMODE_FLAT.equals(options.getDirMode())) {
+                    destFileName = IvyPatternHelper.substitute(destPattern,
+                            artifact.getArtifact().getModuleRevisionId(), artifact.getArtifact(),
+                            conf, artifact.getArtifactOrigin());
+                } else if (RetrieveOptions.DIRMODE_TREE.equals(options.getDirMode())) {
+                    ModuleRevisionId mRevId = artifact.getArtifact().getModuleRevisionId();
+                    String org = mRevId.getOrganisation() == null ? null : mRevId.getOrganisation().replace('.',
'/');
+                    destFileName = IvyPatternHelper.substitute(destPattern, org, mRevId.getName(),
mRevId.getBranch(),
+                            mRevId.getRevision(), artifact.getName(), artifact.getType(),
artifact.getExt(), conf,
+                            artifact.getArtifactOrigin(), mrid.getExtraAttributes(), artifact.getArtifact().getExtraAttributes());
+                } else {
+                    throw new IllegalArgumentException("Unsupported dirMode: " + options.getDirMode());
+                }
 
                 Set dest = (Set) artifactsToCopy.get(artifact);
                 if (dest == null) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java?rev=1062831&r1=1062830&r2=1062831&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java Mon Jan
24 15:32:42 2011
@@ -31,6 +31,9 @@ public class RetrieveOptions extends Log
     public static final String OVERWRITEMODE_ALWAYS = "always";
     public static final String OVERWRITEMODE_NEWER = "newer";
     public static final String OVERWRITEMODE_DIFFERENT = "different";
+
+    public static final String DIRMODE_FLAT = "flat";
+    public static final String DIRMODE_TREE = "tree";
     
     /**
      * The names of configurations to retrieve. If the array consists only of '*', then all
@@ -69,11 +72,22 @@ public class RetrieveOptions extends Log
      */
     private boolean makeSymlinks = false;
 
+    private String dirMode = DIRMODE_FLAT;
+
     /**
      * The id used to store the resolve information.
      */
     private String resolveId;
 
+    public String getDirMode() {
+        return dirMode == null ? DIRMODE_FLAT : dirMode;
+    }
+
+    public RetrieveOptions setDirMode(String dirMode) {
+        this.dirMode = dirMode;
+        return this;
+    }
+
     public Filter getArtifactFilter() {
         return artifactFilter;
     }



Mime
View raw message