Author: maartenc
Date: Thu Aug 23 22:32:04 2012
New Revision: 1376745
URL: http://svn.apache.org/viewvc?rev=1376745&view=rev
Log:
FIX: Ivy descriptors are merged incorrectly when there is an <exclude> element
(IVY-1356) (merged from trunk)
Added:
ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/plugins/parser/xml/test-extends-dependencies-exclude.xml
- copied unchanged from r1376743,
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-extends-dependencies-exclude.xml
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/osgi/core/OsgiLatestStrategy.java
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
Propchange: ant/ivy/core/branches/2.3.x/
------------------------------------------------------------------------------
Merged /ant/ivy/core/trunk:r1376738-1376743
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=1376745&r1=1376744&r2=1376745&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/CHANGES.txt (original)
+++ ant/ivy/core/branches/2.3.x/CHANGES.txt Thu Aug 23 22:32:04 2012
@@ -129,6 +129,7 @@ for detailed view of each issue, please
2.3.x
=====================================
+- FIX: Ivy descriptors are merged incorrectly when there is an <exclude>
element (IVY-1356)
- FIX: SimpleDateFormat is not thread safe (IVY-1373)
- FIX: Maven 'hk2-jar' packaging is now supported (IVY-1357)
- FIX: Maven 'orbit' and 'pear' packaging is now supported (IVY-899)
Modified:
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java?rev=1376745&r1=1376744&r2=1376745&view=diff
==============================================================================
---
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java
(original)
+++
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java
Thu Aug 23 22:32:04 2012
@@ -71,6 +71,7 @@ public class OsgiLatestStrategy extends
VersionMatcher vmatcher =
IvyContext.getContext().getSettings().getVersionMatcher();
ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("", "",
rev1);
ModuleRevisionId mrid2 = ModuleRevisionId.newInstance("", "",
rev2);
+
if (vmatcher.isDynamic(mrid1)) {
int c = vmatcher.compare(mrid1, mrid2, mridComparator);
return c >= 0 ? 1 : -1;
Modified:
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java?rev=1376745&r1=1376744&r2=1376745&view=diff
==============================================================================
---
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
(original)
+++
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/latest/LatestRevisionStrategy.java
Thu Aug 23 22:32:04 2012
@@ -108,6 +108,7 @@ public class LatestRevisionStrategy exte
VersionMatcher vmatcher =
IvyContext.getContext().getSettings().getVersionMatcher();
ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("", "",
rev1);
ModuleRevisionId mrid2 = ModuleRevisionId.newInstance("", "",
rev2);
+
if (vmatcher.isDynamic(mrid1)) {
int c = vmatcher.compare(mrid1, mrid2, mridComparator);
return c >= 0 ? 1 : -1;
Modified:
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java?rev=1376745&r1=1376744&r2=1376745&view=diff
==============================================================================
---
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
(original)
+++
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
Thu Aug 23 22:32:04 2012
@@ -271,6 +271,20 @@ public final class XmlModuleDescriptorUp
}
flushMergedElementsBefore(qName);
+
+ // according to ivy.xsd, all <dependency> elements must occur
before
+ // the <exclude>, <override> or <conflict> elements
+ if (options.isMerge()
+ && ("exclude".equals(localName)
+ || "override".equals(localName)
+ || "conflict".equals(localName))
+ && "ivy-module/dependencies".equals(getContext())) {
+ ModuleDescriptor merged = options.getMergedDescriptor();
+ writeInheritedDependencies(merged);
+ out.println();
+ out.print(getIndent());
+ }
+
context.push(qName);
String path = getContext();
@@ -360,7 +374,7 @@ public final class XmlModuleDescriptorUp
writeInheritedDescription(merged);
}
}
-
+
// copy
write("<" + qName);
for (int i = 0; i < attributes.getLength(); i++) {
Modified:
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java?rev=1376745&r1=1376744&r2=1376745&view=diff
==============================================================================
---
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
(original)
+++
ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
Thu Aug 23 22:32:04 2012
@@ -55,7 +55,7 @@ public interface DependencyResolver {
/**
* Resolve a module by id, getting its module descriptor and resolving the
revision if it's a
* latest one (i.e. a revision uniquely identifying the revision of a
module in the current
- * environment - If this revision is not able to identify uniquelely the
revision of the module
+ * environment - If this revision is not able to identify uniquely the
revision of the module
* outside of the current environment, then the resolved revision must
begin by ##)
*
* @throws ParseException
Modified:
ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java?rev=1376745&r1=1376744&r2=1376745&view=diff
==============================================================================
---
ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
(original)
+++
ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
Thu Aug 23 22:32:04 2012
@@ -46,6 +46,12 @@ import org.apache.ivy.util.FileUtil;
import org.xml.sax.SAXParseException;
public class XmlModuleUpdaterTest extends TestCase {
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ XmlModuleDescriptorUpdater.LINE_SEPARATOR =
System.getProperty("line.separator");
+ }
public void testUpdate() throws Exception {
/*
@@ -320,6 +326,35 @@ public class XmlModuleUpdaterTest extend
.getDependencyArtifacts("myconf2").length);
}
}
+
+ // IVY-1356
+ public void testMergedUpdateWithExtendsAndExcludes() throws Exception {
+ URL url =
XmlModuleUpdaterTest.class.getResource("test-extends-dependencies-exclude.xml");
+
+ XmlModuleDescriptorParser parser =
XmlModuleDescriptorParser.getInstance();
+ ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url,
true);
+
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ XmlModuleDescriptorUpdater.update(url, buffer,
+ getUpdateOptions("release", "mynewrev")
+ .setMerge(true)
+ .setMergedDescriptor(md));
+
+ ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
+ new ByteArrayInputStream(buffer.toByteArray()), new
BasicResource("test", false, 0, 0,
+ false), true);
+
+ DependencyDescriptor[] deps = updatedMd.getDependencies();
+ assertNotNull("Dependencies shouldn't be null", deps);
+ assertEquals("Number of dependencies is incorrect", 2, deps.length);
+
+ // test indentation
+ String updatedXml = buffer.toString();
+ System.out.println(updatedXml);
+
assertTrue(updatedXml.indexOf(XmlModuleDescriptorUpdater.LINE_SEPARATOR
+ + "\t\t<dependency org=\"myorg\" name=\"mymodule1\" rev=\"1.0\"
conf=\"default->default\"/>"
+ + XmlModuleDescriptorUpdater.LINE_SEPARATOR) != -1);
+ }
private UpdateOptions getUpdateOptions(String status, String revision) {
return getUpdateOptions(new IvySettings(), new HashMap(), status,
revision, new Date());