Recreated 2.2.0-rc1 tag.
git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/tags/2.2.0-rc1@959425 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java b/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java
index 78d4ad1..4fca796 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java
@@ -39,6 +39,10 @@
*/
private Map resolvedRevisions = Collections.EMPTY_MAP;
/**
+ * Map from ModuleId of dependencies to new branch (as String)
+ */
+ private Map resolvedBranches = Collections.EMPTY_MAP;
+ /**
* the new status, <code>null</code> to keep the old one
*/
private String status = null;
@@ -167,4 +171,11 @@
this.generateRevConstraint = generateRevConstraint;
return this;
}
+ public Map getResolvedBranches() {
+ return resolvedBranches;
+ }
+ public UpdateOptions setResolvedBranches(Map resolvedBranches) {
+ this.resolvedBranches = resolvedBranches;
+ return this;
+ }
}
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
index 58ef6a6..ac9a01a 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
@@ -183,6 +183,8 @@
private final PrintWriter out;
private final Map resolvedRevisions;
+
+ private final Map resolvedBranches;
private final String status;
@@ -209,6 +211,7 @@
this.settings = options.getSettings();
this.out = out;
this.resolvedRevisions = options.getResolvedRevisions();
+ this.resolvedBranches = options.getResolvedBranches();
this.status = options.getStatus();
this.revision = options.getRevision();
this.pubdate = options.getPubdate();
@@ -523,6 +526,8 @@
revision, extraAttributes);
ModuleRevisionId systemMrid = ns == null ? localMrid : ns.getToSystemTransformer()
.transform(localMrid);
+
+ String newBranch = (String) resolvedBranches.get(systemMrid);
for (int i = 0; i < attributes.getLength(); i++) {
String attName = attributes.getQName(i);
@@ -548,7 +553,16 @@
} else if ("name".equals(attName)) {
write(" name=\"" + systemMrid.getName() + "\"");
} else if ("branch".equals(attName)) {
- write(" branch=\"" + systemMrid.getBranch() + "\"");
+ if(newBranch != null) {
+ write(" branch=\"" + newBranch + "\"");
+ }
+ else if(!resolvedBranches.containsKey(systemMrid)) {
+ write(" branch=\"" + systemMrid.getBranch() + "\"");
+ }
+ else {
+ // if resolvedBranches contains the systemMrid, but the new branch is null,
+ // the branch attribute will be removed altogether
+ }
} else if ("branchConstraint".equals(attName)) {
write(" branchConstraint=\"" + branchConstraint + "\"");
} else if ("conf".equals(attName)) {
@@ -566,10 +580,17 @@
}
}
- if (options.isUpdateBranch()
- && systemMrid.getBranch() != null && attributes.getIndex("branch") == -1) {
- // this dependency is on a specific branch, we set it explicitly in the updated file
- write(" branch=\"" + systemMrid.getBranch() + "\"");
+ if(attributes.getIndex("branch") == -1)
+ {
+ if (newBranch != null) {
+ // erase an existing branch attribute if its new value is blank
+ if(!newBranch.trim().equals(""))
+ write(" branch=\"" + newBranch + "\"");
+ }
+ else if (options.isUpdateBranch() && systemMrid.getBranch() != null) {
+ // this dependency is on a specific branch, we set it explicitly in the updated file
+ write(" branch=\"" + systemMrid.getBranch() + "\"");
+ }
}
}
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
index 250e674..ca162e8 100644
--- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleUpdaterTest.java
@@ -61,6 +61,12 @@
"yourorg", "yourmodule2", "branch1", "2+"), "2.5");
resolvedRevisions.put(ModuleRevisionId.newInstance(
"yourorg", "yourmodule6", "trunk", "latest.integration"), "6.3");
+
+ Map resolvedBranches = new HashMap();
+ resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"),
+ "branch1");
+ resolvedBranches.put(ModuleRevisionId.newInstance(
+ "yourorg", "yourmodule2", "branch1", "2+"), null);
GregorianCalendar cal = new GregorianCalendar();
cal.set(2005, 2, 22, 14, 32, 54);
@@ -70,7 +76,7 @@
XmlModuleDescriptorUpdater.update(
XmlModuleUpdaterTest.class.getResource("test-update.xml"), dest,
getUpdateOptions(ivy.getSettings(), resolvedRevisions,
- "release", "mynewrev", cal.getTime()));
+ "release", "mynewrev", cal.getTime()).setResolvedBranches(resolvedBranches));
assertTrue(dest.exists());
String expected = FileUtil.readEntirely(new BufferedReader(new InputStreamReader(
@@ -110,7 +116,13 @@
"yourorg", "yourmodule2", "branch1", "2+"), "2.5");
resolvedRevisions.put(ModuleRevisionId.newInstance(
"yourorg", "yourmodule6", "trunk", "latest.integration"), "6.3");
-
+
+ Map resolvedBranches = new HashMap();
+ resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"),
+ "branch1");
+ resolvedBranches.put(ModuleRevisionId.newInstance(
+ "yourorg", "yourmodule2", "branch1", "2+"), null);
+
GregorianCalendar cal = new GregorianCalendar();
cal.set(2005, 2, 22, 14, 32, 54);
@@ -160,7 +172,7 @@
XmlModuleDescriptorUpdater.update(
XmlModuleUpdaterTest.class.getResource("test-update-withvar.xml"), dest,
getUpdateOptions(ivy.getSettings(), resolvedRevisions,
- "release", "mynewrev", cal.getTime()));
+ "release", "mynewrev", cal.getTime()).setResolvedBranches(resolvedBranches));
assertTrue(dest.exists());
String expected = FileUtil.readEntirely(new BufferedReader(new InputStreamReader(
diff --git a/test/java/org/apache/ivy/plugins/parser/xml/updated.xml b/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
index f9096f3..e0c2e32 100644
--- a/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
+++ b/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
@@ -57,8 +57,8 @@
<dependency name="mymodule2" rev="2.0"/>
<dependency name="mymodule3" rev="2.0" changing="true" transitive="false"/>
<dependency org="yourorg" name="yourmodule1" branch="trunk" rev="1.1" branchConstraint="branch1" revConstraint="1+" conf="myconf1"/>
- <dependency org="yourorg" name="yourmodule2" branch="branch1" rev="2.5" branchConstraint="branch1" revConstraint="2+" conf="myconf1->yourconf1"/>
- <dependency org="yourorg" name="yourmodule3" rev="3.1" conf="myconf1->yourconf1, yourconf2"/>
+ <dependency org="yourorg" name="yourmodule2" rev="2.5" branchConstraint="branch1" revConstraint="2+" conf="myconf1->yourconf1"/>
+ <dependency org="yourorg" name="yourmodule3" rev="3.1" conf="myconf1->yourconf1, yourconf2" branch="branch1"/>
<dependency org="yourorg" name="yourmodule4" rev="4.1" conf="myconf1, myconf2->yourconf1, yourconf2"/>
<dependency org="yourorg" name="yourmodule5" rev="5.1" conf="myconf1->yourconf1;myconf2->yourconf1, yourconf2"/>
diff --git a/version.properties b/version.properties
index aa5108a..e60ecd8 100644
--- a/version.properties
+++ b/version.properties
@@ -21,4 +21,4 @@
target.ivy.bundle.version=2.2.0
# in case we want to add a qualifier such as alpha, beta, etc...
# if non empty, add a '_' at the end of the qualifier, so the version would look like 1.2.3.alpha_200901011200
-target.ivy.bundle.version.qualifier=cr1
+target.ivy.bundle.version.qualifier=cr1_