You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gs...@apache.org on 2008/01/10 16:14:57 UTC

svn commit: r610812 - in /ant/ivy/core/trunk: CHANGES.txt doc/use/buildlist.html src/java/org/apache/ivy/ant/IvyBuildList.java test/java/org/apache/ivy/ant/IvyBuildListTest.java

Author: gscokart
Date: Thu Jan 10 07:14:57 2008
New Revision: 610812

URL: http://svn.apache.org/viewvc?rev=610812&view=rev
Log:
NEW: Add ability for buildlist task to start build from specified module in the list (IVY-697) (thanks to Mirko Bulovic)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/use/buildlist.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyBuildListTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=610812&r1=610811&r2=610812&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Jan 10 07:14:57 2008
@@ -18,6 +18,7 @@
 	Jeffrey Blattman
 	Jim Bonanno
 	Matthieu Brouillard
+	Mirko Bulovic
 	Kristian Cibulskis
 	Andrea Bernardo Ciddio
 	Jacob Grydholt Jensen
@@ -60,6 +61,7 @@
 =====================================
 - NEW: Introduce RepositoryManagementEngine (IVY-665 - not completed yet)
 - NEW: Add support for importing environment variables (IVY-608)
+- NEW: Add ability for buildlist task to start build from specified module in the list (IVY-697) (thanks to Mirko Bulovic)
 
 - IMPROVEMENT: Make IBiblio resolver compatible with maven proxy (IVY-466)
 - IMPROVEMENT: Use namespace aware validation (IVY-553)

Modified: ant/ivy/core/trunk/doc/use/buildlist.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/buildlist.html?rev=610812&r1=610811&r2=610812&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/buildlist.html (original)
+++ ant/ivy/core/trunk/doc/use/buildlist.html Thu Jan 10 07:14:57 2008
@@ -45,6 +45,8 @@
 
 <span class="since">since 2.0</span> When you are specifying root or leaf modules you can limit the resulting list to only direct dependencies of the roots modules or to modules that directly depends on your leaf modules.
 
+<span class="since">since 2.0</span> You can also specify a restartFrom modules.  The difference with root or leaf,  is that you get a list starting at the restartFrom module followed by all the modules that would be after if the parameter would not be there (even if there is no dependency between the restartFrom and the following module).
+
 
 <table class="ant">
 <thead>
@@ -66,6 +68,7 @@
     <tr><td>haltonerror</td><td>true to halt the build when an invalid ivy file is encountered, false to continue</td><td>No. Defaults to true</td></tr>
     <tr><td>skipbuildwithoutivy</td><td>true to skip files of the fileset with no corresponding ivy file, false otherwise. If false the file with no corresponding ivy file will be considered as independent of the other and put at the beginning of the built filelist.</td><td>No. Defaults to false</td></tr>
     <tr><td>reverse</td><td>true to obtain the list in the reverse order, i.e. from the most dependent to the least one</td><td>No. Defaults to default false</td></tr>
+    <tr><td>restartFrom</td><td><span class="since">since 2.0</span> The name of the module which should be considered as the starting point in the buildlist. This allows for the build to be started at any point in the dependency chain. <br/></td><td>No. Defaults to no restart point (all modules are used in the build list).</td></tr>
     <tr><td>settingsRef</td><td><span class="since">since 2.0</span> A reference to the ivy settings that must be used by this task</td><td>No, 'ivy.instance' is taken by default.</td></tr>
 </tbody>
 </table>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java?rev=610812&r1=610811&r2=610812&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java Thu Jan 10 07:14:57 2008
@@ -72,7 +72,9 @@
     private boolean excludeLeaf = false;
 
     private boolean onlydirectdep = false;
-    
+
+    private String restartFrom = "*";
+        
     public void addFileset(FileSet buildFiles) {
         buildFileSets.add(buildFiles);
     }
@@ -170,6 +172,13 @@
             }
         }
 
+        Set restartFromModuleNames = new LinkedHashSet();
+        if (!"*".equals(restartFrom)) {
+            StringTokenizer st = new StringTokenizer(restartFrom, delimiter);
+            // Only accept one (first) module
+            restartFromModuleNames.add(st.nextToken());
+        }
+        
         for (ListIterator iter = buildFileSets.listIterator(); iter.hasNext();) {
             FileSet fs = (FileSet) iter.next();
             DirectoryScanner ds = fs.getDirectoryScanner(getProject());
@@ -214,6 +223,8 @@
             "leaf");
         List rootModuleDescriptors = convertModuleNamesToModuleDescriptors(mdsMap, rootModuleNames,
             "root");
+        List restartFromModuleDescriptors = convertModuleNamesToModuleDescriptors(mdsMap, restartFromModuleNames,
+            "restartFrom");
 
         Collection mds = new ArrayList(mdsMap.values());
         if (!rootModuleDescriptors.isEmpty()) {
@@ -236,6 +247,24 @@
         if (isReverse()) {
             Collections.reverse(sortedModules);
         }
+        // Remove modules that are before the restartFrom point
+        // Independant modules (without valid ivy file) can not be addressed
+        // so they are not removed from build path.
+        if (!restartFromModuleDescriptors.isEmpty()) {
+            boolean foundRestartFrom = false;
+            List keptModules = new ArrayList();
+            ModuleDescriptor restartFromModuleDescriptor = (ModuleDescriptor)restartFromModuleDescriptors.get(0);
+            for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
+                ModuleDescriptor md = (ModuleDescriptor) iter.next();
+                if (md.equals(restartFromModuleDescriptor)) {
+                    foundRestartFrom = true;
+                }
+                if (foundRestartFrom) {
+                    keptModules.add(md);
+                }
+            }
+            sortedModules = keptModules;
+        }
         StringBuffer order = new StringBuffer();
         for (ListIterator iter = sortedModules.listIterator(); iter.hasNext();) {
             ModuleDescriptor md = (ModuleDescriptor) iter.next();
@@ -448,4 +477,13 @@
         this.reverse = reverse;
     }
 
+    public String getRestartFrom() {
+        return restartFrom;
+    }
+
+    public void setRestartFrom(String restartFrom) {
+        this.restartFrom = restartFrom;
+    }
+
+    
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyBuildListTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyBuildListTest.java?rev=610812&r1=610811&r2=610812&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyBuildListTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyBuildListTest.java Thu Jan 10 07:14:57 2008
@@ -384,5 +384,44 @@
                 .getAbsolutePath());
     }
 
+    
+    public void testRestartFrom() {
+        Project p = new Project();
+
+        IvyBuildList buildlist = new IvyBuildList();
+        buildlist.setProject(p);
+        buildlist.setRestartFrom("C");
+
+        FileSet fs = new FileSet();
+        fs.setDir(new File("test/buildlist"));
+        fs.setIncludes("**/build.xml");
+        buildlist.addFileset(fs);
+
+        buildlist.setReference("ordered.build.files");
+
+        buildlist.execute();
+
+        Object o = p.getReference("ordered.build.files");
+        assertNotNull(o);
+        assertTrue(o instanceof Path);
+
+        Path path = (Path) o;
+        String[] files = path.list();
+        assertNotNull(files);
+        
+        assertEquals(4, files.length);
+
+        assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[0])
+                .getAbsolutePath());
+        assertEquals(new File("test/buildlist/A/build.xml").getAbsolutePath(), new File(files[1])
+                .getAbsolutePath());
+        assertEquals(new File("test/buildlist/D/build.xml").getAbsolutePath(), new File(files[2])
+                .getAbsolutePath());
+        assertEquals(new File("test/buildlist/E/build.xml").getAbsolutePath(), new File(files[3])
+                .getAbsolutePath());
+    }
+
+
+    
 }
 //CheckStyle:MagicNumber| ON