You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2012/08/13 22:56:52 UTC
svn commit: r1372609 - in /ant/ivy/core/branches/2.3.x: ./
src/java/org/apache/ivy/core/settings/
src/java/org/apache/ivy/plugins/parser/xml/ test/buildlists/
test/java/org/apache/ivy/ant/
Author: hibou
Date: Mon Aug 13 20:56:52 2012
New Revision: 1372609
URL: http://svn.apache.org/viewvc?rev=1372609&view=rev
Log:
merging IVY-1363,IVY-1359,IVY-1364: r1364410,1372594
Added:
ant/ivy/core/branches/2.3.x/test/buildlists/
- copied from r1364410, ant/ivy/core/trunk/test/buildlists/
Modified:
ant/ivy/core/branches/2.3.x/ (props changed)
ant/ivy/core/branches/2.3.x/CHANGES.txt
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/core/settings/IvySettings.java
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/ant/IvyBuildListTest.java
Propchange: ant/ivy/core/branches/2.3.x/
------------------------------------------------------------------------------
Merged /ant/ivy/core/trunk:r1364410,1372594
Modified: ant/ivy/core/branches/2.3.x/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/CHANGES.txt?rev=1372609&r1=1372608&r2=1372609&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/CHANGES.txt (original)
+++ ant/ivy/core/branches/2.3.x/CHANGES.txt Mon Aug 13 20:56:52 2012
@@ -46,6 +46,7 @@ for detailed view of each issue, please
Benjamin Francisoud
Jacob Grydholt Jensen
John Gibson
+ Mitch Gitman
Scott Goldstein
Pierre Hägnestrand
Scott Hebert
@@ -129,6 +130,9 @@ for detailed view of each issue, please
- FIX: NullPointerExeption in AbstractOSGiResolver (IVY-1343) (thanks to Thomas Kurpick)
- FIX: Delivered ivy descriptor inconsistent with resolve report / retrieve and other post-resolve actions (IVY-1300) (thanks to Ed Burcher)
- FIX: The Updatesite resolver is downloading Eclipse features instead of Eclipse bundle/plugin
+- FIX: ivy:buildlist task confused by extends feature using two parents (IVY-1363) (thanks to Mitch Gitman and Jean-Louis Boudart)
+- FIX: ivy.xml extends feature complains about Windows filesystem path (IVY-1359) (thanks to Mitch Gitman and Jean-Louis Boudart)
+- FIX: buildlist task chokes on absolute path to parent Ivy module (IVY-1364) (thanks to Mitch Gitman and Jean-Louis Boudart)
2.3.0-rc1
=====================================
Modified: ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/core/settings/IvySettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/core/settings/IvySettings.java?rev=1372609&r1=1372608&r2=1372609&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/core/settings/IvySettings.java (original)
+++ ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/core/settings/IvySettings.java Mon Aug 13 20:56:52 2012
@@ -875,6 +875,10 @@ public class IvySettings implements Sort
return getResolver(resolverName);
}
+ public boolean hasResolver(String resolverName) {
+ return resolversMap.containsKey(resolverName);
+ }
+
public DependencyResolver getResolver(String resolverName) {
if (dictatorResolver != null) {
return dictatorResolver;
Modified: ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=1372609&r1=1372608&r2=1372609&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (original)
+++ ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java Mon Aug 13 20:56:52 2012
@@ -230,30 +230,6 @@ public class XmlModuleDescriptorParser e
public Parser(ModuleDescriptorParser parser, ParserSettings ivySettings) {
super(parser);
settings = ivySettings;
- configureModuleInheritanceRepository();
- }
- /**
- * Configure module inheritance repository (repository containning all path references
- * to parent modules). Basicaly it checks if module inheritance repository exist
- * in current ivy context, otherwise it will create one as a {@link URLResolver}
- */
- protected void configureModuleInheritanceRepository() {
- IvySettings ivysettings = IvyContext.getContext().getSettings();
- DependencyResolver parentModuleResolver=null;
- //Does module-inheritance-repository exists ?
- for (Iterator iterator = ivysettings.getResolvers().iterator(); iterator.hasNext();) {
- DependencyResolver resolver = (DependencyResolver) iterator.next();
- if (resolver.getName().equals(MODULE_INHERITANCE_REPOSITORY)) {
- parentModuleResolver=resolver;
- break;
- }
- }
- //if does not exist create one
- if (parentModuleResolver == null) {
- parentModuleResolver= new URLResolver();
- parentModuleResolver.setName(MODULE_INHERITANCE_REPOSITORY);
- ivysettings.addResolver(parentModuleResolver);
- }
}
public void setInput(InputStream descriptorInput) {
@@ -428,13 +404,13 @@ public class XmlModuleDescriptorParser e
//check on filesystem based on location attribute (for dev ONLY)
try {
- checkParentModuleOnFilesystem(location);
+ checkParentModuleOnFilesystem(location, parentMrid);
} catch (IOException e) {
Message.warn("Unable to parse included ivy file " + location + ": "
+ e.getMessage());
}
- // resolve parent from module inheritance repository
+ // Resolve parent module descriptor from module inheritance repository
parent = resolveParentFromModuleInheritanceRepository(parentMrid);
// if not found, tries to resolve using repositories
@@ -616,22 +592,30 @@ public class XmlModuleDescriptorParser e
* Check if parent module is reachable using location attribute (for dev purpose).
* If parent module is reachable it will be registered in module inheritance repository
* @param location a given location
+ * @param parentMrid
* @throws IOException
* @throws ParseException
*/
- protected void checkParentModuleOnFilesystem(String location) throws IOException, ParseException {
- URL url =getSettings().getRelativeUrlResolver().getURL(descriptorURL, location);
- //is parent module reachable using location attribute ?
- if (url.openConnection().getContentLength() >0 ) {
- IvySettings ivysettings = IvyContext.getContext().getSettings();
- URLResolver urlResolver= (URLResolver) ivysettings.getResolver(MODULE_INHERITANCE_REPOSITORY);
- if (urlResolver == null) {
- throw new ParseException("Unable to find module inheritance repository", 0);
- }
-
- if (!urlResolver.getIvyPatterns().contains(url.toExternalForm())) {
- Message.debug("Registering parent module into module inheritance repository, parent module location is "+url.toExternalForm());
- urlResolver.addIvyPattern(url.toExternalForm());
+ protected void checkParentModuleOnFilesystem(String location, ModuleRevisionId parentMrid) throws IOException, ParseException {
+ IvyContext ivyContext = IvyContext.getContext();
+ File file = new File(location);
+ URL url = null;
+ if (file.isAbsolute()) {
+ url = getSettings().getRelativeUrlResolver().getURL(descriptorURL,
+ file.getAbsolutePath(), location);
+ } else {
+ url = getSettings().getRelativeUrlResolver().getURL(descriptorURL, location);
+ }
+ // Is parent module reachable using location attribute?
+ if (url.openConnection().getContentLength() > 0) {
+ String urlString = url.toExternalForm();
+ if (!ivyContext.getSettings().hasResolver(getModuleInheritanceRepositoryParentResolverName(parentMrid))) {
+ Message.debug("Registering parent module into module inheritance repository map. Parent module location: " + urlString);
+ URLResolver parentModuleResolver = new URLResolver();
+ parentModuleResolver.setName(getModuleInheritanceRepositoryParentResolverName(parentMrid));
+ parentModuleResolver.addIvyPattern(url.toExternalForm());
+ // Do we even need to be adding this resolver to the Ivy settings considering that it's being placed in the map and not being used elsewhere?
+ ivyContext.getSettings().addResolver(parentModuleResolver);
}
}
}
@@ -665,13 +649,13 @@ public class XmlModuleDescriptorParser e
}
/**
- * Resolve parent module from module inhertance repository
+ * Resolve parent module from module inheritance repository
* @param parentMrid a given {@link ModuleRevisionId} to find
* @return a {@link ModuleDescriptor} if found. Return null if no {@link ModuleDescriptor} was found
* @throws ParseException
*/
protected ModuleDescriptor resolveParentFromModuleInheritanceRepository(ModuleRevisionId parentMrid) throws ParseException {
- Message.debug("Trying to load included ivy file from module inheritance repository " );
+ Message.debug("Trying to resolve included ivy file from module inheritance repository " );
DependencyDescriptor dd = new DefaultDependencyDescriptor(parentMrid, true);
ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
ResolveOptions options = new ResolveOptions();
@@ -679,7 +663,11 @@ public class XmlModuleDescriptorParser e
options.setDownload(false);
ResolveData data = new ResolveData(engine, options);
- DependencyResolver resolver = IvyContext.getContext().getSettings().getResolver(MODULE_INHERITANCE_REPOSITORY);
+ DependencyResolver resolver = IvyContext.getContext().getSettings().getResolver(getModuleInheritanceRepositoryParentResolverName(parentMrid));
+ // The parent resolver will be null if its dev-only filesystem path hasn't been specified via the location attribute of the extends element.
+ if (resolver == null) {
+ return null;
+ }
dd = NameSpaceHelper.toSystem(dd, getSettings().getContextNamespace());
ResolvedModuleRevision otherModule = resolver.getDependency(dd, data);
if (otherModule != null) {
@@ -688,6 +676,10 @@ public class XmlModuleDescriptorParser e
return null;
}
}
+
+ private static String getModuleInheritanceRepositoryParentResolverName(ModuleRevisionId parentMrid) {
+ return MODULE_INHERITANCE_REPOSITORY + "-" + parentMrid.toString();
+ }
protected void publicationsStarted(Attributes attributes) {
state = State.PUB;
Modified: ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/ant/IvyBuildListTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/ant/IvyBuildListTest.java?rev=1372609&r1=1372608&r2=1372609&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/ant/IvyBuildListTest.java (original)
+++ ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/ant/IvyBuildListTest.java Mon Aug 13 20:56:52 2012
@@ -24,579 +24,435 @@ import java.util.List;
import junit.framework.TestCase;
+import org.apache.ivy.util.FileUtil;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
+// CheckStyle:MagicNumber| OFF
+// The test very often use MagicNumber. Using a constant is less expressive.
+
public class IvyBuildListTest extends TestCase {
- /*
- * Those tests use the ivy files A , B , C , D , E in test/buildlist
- * The dependencies are :
- * A -> C
- * B has no dependency
- * C -> B
- * D -> A , B
- * E has no dependency
- * F -> G
- * G -> F
- */
+ private File cache;
- //CheckStyle:MagicNumber| OFF
- //The test very often use MagicNumber. Using a constant is less expressive.
+ private Project project;
-
- public void testSimple() {
- Project p = new Project();
+ private IvyBuildList buildlist;
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
+ protected void setUp() throws Exception {
+ createCache();
- FileSet fs = new FileSet();
- fs.setDir(new File("test/buildlist"));
- fs.setIncludes("**/build.xml");
- fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml");
- buildlist.addFileset(fs);
- buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
+ project = new Project();
+ project.init();
+
+ buildlist = new IvyBuildList();
+ buildlist.setProject(project);
+
+ System.setProperty("ivy.cache.dir", cache.getAbsolutePath());
+ }
+
+ protected void tearDown() throws Exception {
+ cleanCache();
+ }
+
+ private void cleanCache() {
+ FileUtil.forceDelete(cache);
+ }
+
+ private void createCache() {
+ cache = new File("build/cache");
+ cache.mkdirs();
+ }
+ private String[] getFiles(IvyBuildList buildlist) {
+ buildlist.setReference("ordered.build.files");
buildlist.execute();
- Object o = p.getReference("ordered.build.files");
+ Object o = buildlist.getProject().getReference("ordered.build.files");
assertNotNull(o);
assertTrue(o instanceof Path);
Path path = (Path) o;
String[] files = path.list();
assertNotNull(files);
-
- assertEquals(5, files.length);
-
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/A/build.xml").getAbsolutePath(), new File(files[2])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/D/build.xml").getAbsolutePath(), new File(files[3])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/E/build.xml").getAbsolutePath(), new File(files[4])
- .getAbsolutePath());
+ return files;
}
- public void testReverse() {
- Project p = new Project();
+ private void assertListOfFiles(String prefix, String[] expected, String[] actual) {
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(new File(prefix + expected[i] + "/build.xml").getAbsolutePath(), new File(
+ actual[i]).getAbsolutePath());
+ }
+ }
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setReverse(true);
+ /*
+ * Those tests use the ivy files A , B , C , D , E in test/buildlist The dependencies are : A ->
+ * C B has no dependency C -> B D -> A , B E has no dependency F -> G G -> F
+ */
+ public void testSimple() {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml");
+
buildlist.addFileset(fs);
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("reverse.ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("reverse.ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
-
assertEquals(5, files.length);
- assertEquals(new File("test/buildlist/E/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/D/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/A/build.xml").getAbsolutePath(), new File(files[2])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[3])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[4])
- .getAbsolutePath());
-
+ assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E"}, files);
}
- public void testWithRoot() {
- Project p = new Project();
+ public void testReverse() {
+ FileSet fs = new FileSet();
+ fs.setDir(new File("test/buildlist"));
+ fs.setIncludes("**/build.xml");
+ fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml");
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setRoot("C");
+ buildlist.addFileset(fs);
+ buildlist.setReverse(true);
+ buildlist.setOnMissingDescriptor("skip");
+
+ String[] files = getFiles(buildlist);
+ assertEquals(5, files.length);
+
+ assertListOfFiles("test/buildlist/", new String[] {"E", "D", "A", "C", "B"}, files);
+ }
+
+ public void testWithRoot() {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
+ buildlist.setRoot("C");
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
-
- buildlist.execute();
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
+ String[] files = getFiles(buildlist);
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
assertEquals(2, files.length); // A and D should be filtered out
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
+ assertListOfFiles("test/buildlist/", new String[] {"B", "C"}, files);
}
public void testWithRootCircular() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setRoot("F");
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
+
buildlist.addFileset(fs);
+ buildlist.setRoot("F");
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
assertEquals(2, files.length); // F and G should be in the list
}
public void testWithTwoRoots() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setRoot("C,E");
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
+ buildlist.setRoot("C,E");
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
-
assertEquals(3, files.length); // A and D should be filtered out
-
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/E/build.xml").getAbsolutePath(), new File(files[2])
- .getAbsolutePath());
+ assertListOfFiles("test/buildlist/", new String[] {"B", "C", "E"}, files);
}
public void testWithRootExclude() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setRoot("C");
- buildlist.setExcludeRoot(true);
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
+ buildlist.setRoot("C");
+ buildlist.setExcludeRoot(true);
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
assertEquals(1, files.length); // A, D and C should be filtered out
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
+ assertListOfFiles("test/buildlist/", new String[] {"B"}, files);
}
-
public void testWithRootAndOnlyDirectDep() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setRoot("A");
- buildlist.setOnlydirectdep(true);
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
+ buildlist.setRoot("A");
+ buildlist.setOnlydirectdep(true);
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
assertEquals(2, files.length); // We should have only A and C
- 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());
+ assertListOfFiles("test/buildlist/", new String[] {"C", "A"}, files);
}
-
public void testWithLeaf() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setLeaf("C");
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
+ buildlist.setLeaf("C");
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
-
assertEquals(3, files.length); // B should be filtered out
-
- 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());
+ assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D"}, files);
}
public void testWithLeafCircular() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setLeaf("F");
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
+
buildlist.addFileset(fs);
+ buildlist.setLeaf("F");
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
-
- buildlist.execute();
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
+ String[] files = getFiles(buildlist);
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
-
- assertEquals(2, files.length);
+ assertEquals(2, files.length);
}
public void testWithTwoLeafs() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setLeaf("C,E");
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
+ buildlist.setLeaf("C,E");
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
-
- buildlist.execute();
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
+ String[] files = getFiles(buildlist);
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
-
assertEquals(4, files.length); // B should be filtered out
- 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());
-
+ assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D", "E"}, files);
}
public void testWithLeafExclude() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setLeaf("C");
- buildlist.setExcludeLeaf(true);
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
+ buildlist.setLeaf("C");
+ buildlist.setExcludeLeaf(true);
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
assertEquals(2, files.length); // B and C should be filtered out
- assertEquals(new File("test/buildlist/A/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/D/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
+ assertListOfFiles("test/buildlist/", new String[] {"A", "D"}, files);
}
-
public void testWithLeafAndOnlyDirectDep() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
- buildlist.setLeaf("C");
- buildlist.setOnlydirectdep(true);
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
+
buildlist.addFileset(fs);
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
-
- buildlist.execute();
+ buildlist.setLeaf("C");
+ buildlist.setOnlydirectdep(true);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
+ String[] files = getFiles(buildlist);
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
assertEquals(2, files.length); // We must have only A and C
- 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());
+ assertListOfFiles("test/buildlist/", new String[] {"C", "A"}, files);
}
-
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");
fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml");
+
buildlist.addFileset(fs);
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
-
- buildlist.execute();
+ buildlist.setRestartFrom("C");
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
+ String[] files = getFiles(buildlist);
- 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());
+ assertListOfFiles("test/buildlist/", new String[] {"C", "A", "D", "E"}, files);
}
-
- public void testOnMissingDescriptor() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
+ public void testOnMissingDescriptor() {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml");
+
buildlist.addFileset(fs);
buildlist.setOnMissingDescriptor(new String("tail")); // IVY-805: new String instance
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
+ String[] files = getFiles(buildlist);
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
-
assertEquals(6, files.length);
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/A/build.xml").getAbsolutePath(), new File(files[2])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/D/build.xml").getAbsolutePath(), new File(files[3])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/E/build.xml").getAbsolutePath(), new File(files[4])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/H/build.xml").getAbsolutePath(), new File(files[5])
- .getAbsolutePath());
-
+ assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E", "H"}, files);
+ }
+
+ public void testOnMissingDescriptor2() {
+ FileSet fs = new FileSet();
+ fs.setDir(new File("test/buildlist"));
+ fs.setIncludes("**/build.xml");
+ fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml");
+
+ buildlist.addFileset(fs);
buildlist.setOnMissingDescriptor(new String("skip")); // IVY-805: new String instance
- buildlist.execute();
- o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
+ String[] files = getFiles(buildlist);
- path = (Path) o;
- files = path.list();
- assertNotNull(files);
-
assertEquals(5, files.length);
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/A/build.xml").getAbsolutePath(), new File(files[2])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/D/build.xml").getAbsolutePath(), new File(files[3])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/E/build.xml").getAbsolutePath(), new File(files[4])
- .getAbsolutePath());
+ assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D", "E"}, files);
}
public void testWithModuleWithSameNameAndDifferentOrg() {
- Project p = new Project();
-
- IvyBuildList buildlist = new IvyBuildList();
- buildlist.setProject(p);
-
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("F/build.xml,G/build.xml");
+
buildlist.addFileset(fs);
buildlist.setOnMissingDescriptor("skip");
- buildlist.setReference("ordered.build.files");
- buildlist.execute();
+ String[] files = getFiles(buildlist);
- Object o = p.getReference("ordered.build.files");
- assertNotNull(o);
- assertTrue(o instanceof Path);
-
- Path path = (Path) o;
- String[] files = path.list();
- assertNotNull(files);
-
assertEquals(6, files.length);
- assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[1])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/A/build.xml").getAbsolutePath(), new File(files[2])
- .getAbsolutePath());
- assertEquals(new File("test/buildlist/D/build.xml").getAbsolutePath(), new File(files[3])
- .getAbsolutePath());
-
+ assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D"}, files);
+
// the order of E and E2 is undefined
List other = new ArrayList();
other.add(new File(files[4]).getAbsoluteFile().toURI());
other.add(new File(files[5]).getAbsoluteFile().toURI());
Collections.sort(other);
-
+
assertEquals(new File("test/buildlist/E/build.xml").getAbsoluteFile().toURI(), other.get(0));
- assertEquals(new File("test/buildlist/E2/build.xml").getAbsoluteFile().toURI(), other.get(1));
+ assertEquals(new File("test/buildlist/E2/build.xml").getAbsoluteFile().toURI(),
+ other.get(1));
}
-
+
+ public void testNoParents() {
+ FileSet fs = new FileSet();
+ fs.setDir(new File("test/buildlists/testNoParents"));
+ fs.setIncludes("**/build.xml");
+
+ buildlist.addFileset(fs);
+ buildlist.setOnMissingDescriptor("skip");
+ buildlist.setHaltonerror(false);
+
+ String[] files = getFiles(buildlist);
+
+ assertEquals(5, files.length);
+
+ assertListOfFiles("test/buildlists/testNoParents/", new String[] {"bootstrap-parent",
+ "ireland", "germany", "master-parent", "croatia"}, files);
+ }
+
+ public void testOneParent() {
+ FileSet fs = new FileSet();
+ fs.setDir(new File("test/buildlists/testOneParent"));
+ fs.setIncludes("**/build.xml");
+
+ buildlist.addFileset(fs);
+ buildlist.setOnMissingDescriptor("skip");
+ buildlist.setHaltonerror(false);
+
+ String[] files = getFiles(buildlist);
+
+ assertEquals(5, files.length);
+
+ assertListOfFiles("test/buildlists/testOneParent/", new String[] {"bootstrap-parent",
+ "master-parent", "croatia", "ireland", "germany"}, files);
+ }
+
+ public void testTwoParents() {
+ FileSet fs = new FileSet();
+ fs.setDir(new File("test/buildlists/testTwoParents"));
+ fs.setIncludes("**/build.xml");
+
+ buildlist.addFileset(fs);
+ buildlist.setOnMissingDescriptor("skip");
+ buildlist.setHaltonerror(false);
+
+ String[] files = getFiles(buildlist);
+
+ assertEquals(5, files.length);
+
+ assertListOfFiles("test/buildlists/testTwoParents/", new String[] {"bootstrap-parent",
+ "master-parent", "croatia", "ireland", "germany"}, files);
+ }
+
+ public void testRelativePathToParent() {
+ FileSet fs = new FileSet();
+ fs.setDir(new File("test/buildlists/testRelativePathToParent"));
+ fs.setIncludes("**/build.xml");
+
+ buildlist.addFileset(fs);
+ buildlist.setOnMissingDescriptor("skip");
+ buildlist.setHaltonerror(false);
+
+ String[] files = getFiles(buildlist);
+
+ assertEquals(5, files.length);
+
+ assertListOfFiles("test/buildlists/testRelativePathToParent/", new String[] {
+ "bootstrap-parent", "master-parent", "croatia", "ireland", "germany"}, files);
+ }
+
+ public void testAbsolutePathToParent() {
+ project.setProperty("master-parent.dir", new File("test/buildlists/testAbsolutePathToParent/master-parent").getAbsolutePath());
+
+ FileSet fs = new FileSet();
+ fs.setDir(new File("test/buildlists/testAbsolutePathToParent"));
+ fs.setIncludes("**/build.xml");
+
+ buildlist.addFileset(fs);
+ buildlist.setOnMissingDescriptor("skip");
+ buildlist.setHaltonerror(false);
+
+ String[] files = getFiles(buildlist);
+
+ assertEquals(5, files.length);
+
+ assertListOfFiles("test/buildlists/testAbsolutePathToParent/", new String[] {
+ "bootstrap-parent", "master-parent", "croatia", "ireland", "germany"}, files);
+ }
+
}
-//CheckStyle:MagicNumber| ON
\ No newline at end of file
+// CheckStyle:MagicNumber| ON
\ No newline at end of file