Author: maartenc
Date: Sat Feb 14 21:04:19 2009
New Revision: 744568
URL: http://svn.apache.org/viewvc?rev=744568&view=rev
Log:
IMPROVEMENT: Ability to strip revConstraint attribute from delivered Ivy files
(IVY-989)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/doc/use/deliver.html
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDeliverTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sat Feb 14 21:04:19 2009
@@ -85,6 +85,7 @@
trunk
=====================================
+- IMPROVEMENT: Ability to strip revConstraint attribute from delivered Ivy
files (IVY-989)
- IMPROVEMENT: enhanced error message when defining an artifact for an unknown
configuration.
- IMPROVEMENT: display the revision of the resolved module in ivy-report.xsl
(IVY-1024) (thanks to Carlton Brown)
- IMPROVEMENT: resolver attribute for buildnumber task (IVY-1019) (thanks to
Martin Eigenbrodt)
Modified: ant/ivy/core/trunk/doc/use/deliver.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/deliver.html?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/deliver.html (original)
+++ ant/ivy/core/trunk/doc/use/deliver.html Sat Feb 14 21:04:19 2009
@@ -97,12 +97,14 @@
<td>No. No recursive delivery is done by default</td></tr>
<tr><td>validate</td><td>true to force ivy files validation against
ivy.xsd, false to force no validation</td>
<td>No. Defaults to default ivy value (as configured in configuration
file)</td></tr>
- <tr><td>replacedynamicrev</td><td>true to replace dynmic revisions by
static ones in the delivered file, false to avoid this replacement <span
class="since">since 1.3</span></td>
+ <tr><td>replacedynamicrev</td><td>true to replace dynmic revisions by
static ones in the delivered file, false to avoid this replacement <span
class="since">(since 1.3)</span></td>
<td>No. Defaults to true</td></tr>
<tr><td>settingsRef</td><td>A reference to the ivy settings that must
be used by this task <span class="since">(since 2.0)</span></td>
<td>No, 'ivy.instance' is taken by default.</td></tr>
- <tr><td>conf</td><td>comma-separated list of configurations to include
in the delivered file. Accepts wildcards. <span class="since">since
2.0</span></td>
+ <tr><td>conf</td><td>comma-separated list of configurations to include
in the delivered file. Accepts wildcards. <span class="since">(since
2.0)</span></td>
<td>No. Defaults to all configurations</td></tr>
+ <tr><td>generateRevConstraint</td><td>true to automatically generate a
'revConstraint' attribute in the deliverd file (see the [[ivyfile/dependency]]
page for more info about this attribute), false to never generate this
attribute <span class="since">(since 2.0.1)</span></td>
+ <td>No. Defaults to true</td></tr>
</tbody>
</table>
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java Sat Feb 14
21:04:19 2009
@@ -204,6 +204,8 @@
private String conf;
private String pubBranch;
+
+ private boolean generateRevConstraint = true;
public void setCache(File cache) {
cacheAttributeNotSupported();
@@ -305,6 +307,14 @@
conf = confs;
}
+ public boolean isGenerateRevConstraint() {
+ return generateRevConstraint;
+ }
+
+ public void setGenerateRevConstraint(boolean generateRevConstraint) {
+ this.generateRevConstraint = generateRevConstraint;
+ }
+
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
@@ -383,6 +393,7 @@
DeliverOptions options = new DeliverOptions(status, pubdate,
drResolver, doValidate(settings), replacedynamicrev,
splitConfs(conf))
.setResolveId(resolveId)
+ .setGenerateRevConstraint(generateRevConstraint)
.setPubBranch(pubBranch);
if (mrid == null) {
ivy.deliver(pubRevision, deliverpattern, options);
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
Sat Feb 14 21:04:19 2009
@@ -191,6 +191,7 @@
.setRevision(revision)
.setBranch(options.getPubBranch())
.setPubdate(options.getPubdate())
+
.setGenerateRevConstraint(options.isGenerateRevConstraint())
.setConfsToExclude((String[]) confsToRemove
.toArray(new String[confsToRemove.size()])));
} catch (SAXException ex) {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
Sat Feb 14 21:04:19 2009
@@ -40,6 +40,13 @@
private String[] confs;
private String pubBranch;
+
+ /**
+ * True to indicate that the revConstraint attribute should be generated if
+ * applicable, false to never generate the revConstraint attribute.
+ */
+ private boolean generateRevConstraint = true;
+
/**
* Returns an instance of DeliverOptions with options corresponding to
default values taken from
@@ -222,6 +229,15 @@
return this;
}
+ public boolean isGenerateRevConstraint() {
+ return generateRevConstraint;
+ }
+ public DeliverOptions setGenerateRevConstraint(boolean
generateRevConstraint) {
+ this.generateRevConstraint = generateRevConstraint;
+ return this;
+ }
+
+
public String toString() {
return "status=" + status + " pubdate=" + pubdate + " validate=" +
validate
+ " resolveDynamicRevisions=" + resolveDynamicRevisions
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/UpdateOptions.java
Sat Feb 14 21:04:19 2009
@@ -63,6 +63,11 @@
*/
private boolean updateBranch = true;
private String branch;
+ /**
+ * True to indicate that the revConstraint attribute should be generated if
+ * applicable, false to never generate the revConstraint attribute.
+ */
+ private boolean generateRevConstraint = true;
public ParserSettings getSettings() {
return settings;
@@ -134,4 +139,11 @@
this.branch = pubBranch;
return this;
}
+ public boolean isGenerateRevConstraint() {
+ return generateRevConstraint;
+ }
+ public UpdateOptions setGenerateRevConstraint(boolean
generateRevConstraint) {
+ this.generateRevConstraint = generateRevConstraint;
+ return this;
+ }
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
Sat Feb 14 21:04:19 2009
@@ -168,6 +168,8 @@
private final Namespace ns;
private final boolean replaceInclude;
+
+ private final boolean generateRevConstraint;
private boolean inHeader = true;
@@ -187,6 +189,7 @@
this.pubdate = options.getPubdate();
this.ns = options.getNamespace();
this.replaceInclude = options.isReplaceInclude();
+ this.generateRevConstraint = options.isGenerateRevConstraint();
this.relativePathCtx = relativePathCtx;
if (options.getConfsToExclude() != null) {
this.confs = Arrays.asList(options.getConfsToExclude());
@@ -390,7 +393,7 @@
&& branchConstraint != null) {
write(" branchConstraint=\"" + branchConstraint +
"\"");
}
- if (attributes.getIndex("revConstraint") == -1
+ if (generateRevConstraint &&
attributes.getIndex("revConstraint") == -1
&& !rev.equals(systemMrid.getRevision())) {
write(" revConstraint=\"" +
systemMrid.getRevision() + "\"");
}
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDeliverTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDeliverTest.java?rev=744568&r1=744567&r2=744568&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDeliverTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyDeliverTest.java Sat Feb
14 21:04:19 2009
@@ -112,6 +112,32 @@
dds[0].getDynamicConstraintDependencyRevisionId());
}
+ public void testNotGenerateRevConstraint() throws Exception {
+ project.setProperty("ivy.dep.file",
"test/java/org/apache/ivy/ant/ivy-latest.xml");
+ IvyResolve res = new IvyResolve();
+ res.setProject(project);
+ res.execute();
+
+ deliver.setPubrevision("1.2");
+ deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
+ deliver.setGenerateRevConstraint(false);
+ deliver.execute();
+
+ // should have done the ivy delivering
+ File deliveredIvyFile = new File("build/test/deliver/ivy-1.2.xml");
+ assertTrue(deliveredIvyFile.exists());
+ ModuleDescriptor md =
XmlModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(), deliveredIvyFile.toURL(), true);
+ assertEquals(ModuleRevisionId.newInstance("apache", "resolve-latest",
"1.2"), md
+ .getModuleRevisionId());
+ DependencyDescriptor[] dds = md.getDependencies();
+ assertEquals(1, dds.length);
+ assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2"),
+ dds[0].getDependencyRevisionId());
+ assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2"),
+ dds[0].getDynamicConstraintDependencyRevisionId());
+ }
+
public void testWithResolveId() throws Exception {
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);