Author: xavier
Date: Tue Jul 8 09:16:00 2008
New Revision: 674868
URL: http://svn.apache.org/viewvc?rev=674868&view=rev
Log:
IMPROVEMENT: Allow to set the branch at deliver/publish time (IVY-859)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/doc/use/deliver.html
ant/ivy/core/trunk/doc/use/publish.html
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.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/core/module/id/ModuleRevisionId.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.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
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPublishTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Jul 8 09:16:00 2008
@@ -77,6 +77,7 @@
- NEW: Add transitive dependency version and branch override mechanism
(IVY-784)
- NEW: Add new packager resolver (IVY-829) (thanks to Archie Cobbs)
+- IMPROVEMENT: Allow to set the branch at deliver/publish time (IVY-859)
- IMPROVEMENT: Add defaultconf in publications tag of ivy file (IVY-801)
- IMPROVEMENT: Support atomic publish with sub directory structure (IVY-856)
- IMPROVEMENT: Provide ant task to retrieve information from published ivy
modules (IVY-838) (thanks to David Maplesden)
Modified: ant/ivy/core/trunk/doc/use/deliver.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/deliver.html?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/deliver.html (original)
+++ ant/ivy/core/trunk/doc/use/deliver.html Tue Jul 8 09:16:00 2008
@@ -87,6 +87,8 @@
<td>No. Defaults to ${ivy.deliver.ivy.pattern}</td></tr>
<tr><td>pubrevision</td><td>the revision to use for the publication</td>
<td>No. Defaults to ${ivy.deliver.revision} if set, or the revision
resolved if set, or a timestamp</td></tr>
+ <tr><td>pubbranch</td><td>the branch to use for the publication</td>
+ <td>No. Defaults to ${ivy.deliver.branch} if set, or the branch
resolved if set, or nothing (branch info won't be updated)</td></tr>
<tr><td>pubdate</td><td>the publication date to use for the publication.
This date should be either 'now', or a date given with the following pattern:
yyyyMMddHHmmss</td>
<td>No. Defaults to 'now'</td></tr>
<tr><td>status</td><td>the status to use for the publication</td>
Modified: ant/ivy/core/trunk/doc/use/publish.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/publish.html?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/publish.html (original)
+++ ant/ivy/core/trunk/doc/use/publish.html Tue Jul 8 09:16:00 2008
@@ -51,9 +51,11 @@
<td>Yes</td></tr>
<tr><td>pubrevision</td><td>the revision to use for the publication</td>
<td>No. Defaults to the ${ivy.deliver.revision}</td></tr>
+ <tr><td>pubbranch</td><td>the branch to use for the publication</td>
+ <td>No. Defaults to the ${ivy.deliver.branch}</td></tr>
<tr><td>forcedeliver</td><td>true to force the implicit call to deliver,
false to do it only if the ivy file to publish doesn't exist yet <span
class="since">since 1.4</span></td>
<td>No. Defaults to false</td></tr>
- <tr><td>update</td><td>true to update ivy file metadata (revision,
publication date and status) before publishing, false otherwise. This is
usually not necessary when using deliver before publish.</td>
+ <tr><td>update</td><td>true to update ivy file metadata (revision, branch,
publication date and status) before publishing, false otherwise. This is
usually not necessary when using deliver before publish.</td>
<td>No. Defaults to false</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 settings file]])</td></tr>
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=674868&r1=674867&r2=674868&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 Tue Jul 8
09:16:00 2008
@@ -203,6 +203,8 @@
private String conf;
+ private String pubBranch;
+
public void setCache(File cache) {
cacheAttributeNotSupported();
}
@@ -247,6 +249,14 @@
this.pubRevision = pubRevision;
}
+ public String getPubbranch() {
+ return pubBranch;
+ }
+
+ public void setPubbranch(String pubBranch) {
+ this.pubBranch = pubBranch;
+ }
+
public String getRevision() {
return revision;
}
@@ -302,6 +312,7 @@
organisation = getProperty(organisation, settings, "ivy.organisation",
resolveId);
module = getProperty(module, settings, "ivy.module", resolveId);
revision = getProperty(revision, settings, "ivy.revision", resolveId);
+ pubBranch = getProperty(pubBranch, settings, "ivy.deliver.branch");
pubRevision = getProperty(pubRevision, settings,
"ivy.deliver.revision");
deliverpattern = getProperty(deliverpattern, settings,
"ivy.deliver.ivy.pattern");
status = getProperty(status, settings, "ivy.status");
@@ -370,8 +381,9 @@
}
DeliverOptions options = new DeliverOptions(status, pubdate,
- drResolver, doValidate(settings), replacedynamicrev,
- splitConfs(conf)).setResolveId(resolveId);
+ drResolver, doValidate(settings), replacedynamicrev,
splitConfs(conf))
+ .setResolveId(resolveId)
+ .setPubBranch(pubBranch);
if (mrid == null) {
ivy.deliver(pubRevision, deliverpattern, options);
} else {
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java Tue Jul 8
09:16:00 2008
@@ -81,6 +81,8 @@
private Collection artifacts = new ArrayList();
+ private String pubBranch;
+
public void setCache(File cache) {
cacheAttributeNotSupported();
}
@@ -139,6 +141,14 @@
this.pubRevision = pubRevision;
}
+ public String getPubbranch() {
+ return pubBranch;
+ }
+
+ public void setPubbranch(String pubBranch) {
+ this.pubBranch = pubBranch;
+ }
+
public String getRevision() {
return revision;
}
@@ -207,6 +217,7 @@
organisation = getProperty(organisation, settings, "ivy.organisation");
module = getProperty(module, settings, "ivy.module");
revision = getProperty(revision, settings, "ivy.revision");
+ pubBranch = getProperty(pubBranch, settings, "ivy.deliver.branch");
pubRevision = getProperty(pubRevision, settings,
"ivy.deliver.revision");
if (artifactspattern.isEmpty()) {
String p = getProperty(null, settings,
"ivy.publish.src.artifacts.pattern");
@@ -277,6 +288,7 @@
deliver.setOrganisation(getOrganisation());
deliver.setPubdate(Ivy.DATE_FORMAT.format(pubdate));
deliver.setPubrevision(getPubrevision());
+ deliver.setPubbranch(getPubbranch());
deliver.setRevision(getRevision());
deliver.setStatus(getStatus());
deliver.setValidate(doValidate(settings));
@@ -289,6 +301,7 @@
Collection missing = ivy.publish(mrid, artifactspattern,
publishResolverName,
new PublishOptions()
.setPubrevision(getPubrevision())
+ .setPubbranch(getPubbranch())
.setSrcIvyPattern(publishivy ? srcivypattern : null)
.setStatus(getStatus())
.setPubdate(pubdate)
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=674868&r1=674867&r2=674868&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
Tue Jul 8 09:16:00 2008
@@ -118,7 +118,9 @@
ivyFileURL = ivyFile.toURL();
md =
XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFileURL,
options.isValidate());
- md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid,
revision));
+ md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid,
+ options.getPubBranch() == null ? mrid.getBranch() :
options.getPubBranch(),
+ revision));
md.setResolvedPublicationDate(options.getPubdate());
} catch (MalformedURLException e) {
throw new RuntimeException("malformed url obtained for file " +
ivyFile, e);
@@ -187,6 +189,7 @@
.setResolvedRevisions(resolvedDependencies)
.setStatus(options.getStatus())
.setRevision(revision)
+ .setBranch(options.getPubBranch())
.setPubdate(options.getPubdate())
.setConfsToExclude((String[]) confsToRemove
.toArray(new String[confsToRemove.size()])));
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=674868&r1=674867&r2=674868&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
Tue Jul 8 09:16:00 2008
@@ -39,6 +39,8 @@
private String[] confs;
+ private String pubBranch;
+
/**
* Returns an instance of DeliverOptions with options corresponding to
default values taken from
* the given settings.
@@ -197,10 +199,34 @@
return this;
}
+ /**
+ * Returns the branch with which the Ivy file should be delivered, or
<code>null</code> if
+ * branch info shouldn't be changed.
+ *
+ * @return the branch with which the Ivy file should be delivered
+ */
+ public String getPubBranch() {
+ return pubBranch;
+ }
+
+ /**
+ * Sets the branch with which the Ivy file should be delivered.
+ *
+ * @param pubBranch
+ * the branch with which the Ivy file should be delivered
+ * @return the instance of DeliverOptions on which the method has been
called, for easy method
+ * chaining
+ */
+ public DeliverOptions setPubBranch(String pubBranch) {
+ this.pubBranch = pubBranch;
+ return this;
+ }
+
public String toString() {
return "status=" + status + " pubdate=" + pubdate + " validate=" +
validate
+ " resolveDynamicRevisions=" + resolveDynamicRevisions
- + " resolveId=" + resolveId;
+ + " resolveId=" + resolveId
+ + " pubBranch=" + pubBranch;
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
Tue Jul 8 09:16:00 2008
@@ -127,6 +127,12 @@
new ModuleRevisionId(mrid.getModuleId(),
mrid.getBranch(), rev, mrid.getQualifiedExtraAttributes()));
}
+
+ public static ModuleRevisionId newInstance(ModuleRevisionId mrid, String
branch, String rev) {
+ return intern(
+ new ModuleRevisionId(mrid.getModuleId(),
+ branch, rev, mrid.getQualifiedExtraAttributes()));
+ }
/**
* Returns an intern instance of the given ModuleRevisionId if any, or put
the given
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java
Tue Jul 8 09:16:00 2008
@@ -79,10 +79,14 @@
long start = System.currentTimeMillis();
options.setSrcIvyPattern(settings.substitute(options.getSrcIvyPattern()));
+ if (options.getPubBranch() == null) {
+ options.setPubbranch(mrid.getBranch());
+ }
if (options.getPubrevision() == null) {
options.setPubrevision(mrid.getRevision());
}
- ModuleRevisionId pubmrid = ModuleRevisionId.newInstance(mrid,
options.getPubrevision());
+ ModuleRevisionId pubmrid = ModuleRevisionId.newInstance(
+ mrid, options.getPubBranch(), options.getPubrevision());
File ivyFile;
if (options.getSrcIvyPattern() != null) {
ivyFile = new
File(IvyPatternHelper.substitute(options.getSrcIvyPattern(),
@@ -123,6 +127,7 @@
.setStatus(options.getStatus() == null
? md.getStatus() : options.getStatus())
.setRevision(options.getPubrevision())
+ .setBranch(options.getPubBranch())
.setPubdate(options.getPubdate() == null ? new
Date()
: options.getPubdate())
.setConfsToExclude((String[]) confsToRemove
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java
Tue Jul 8 09:16:00 2008
@@ -57,6 +57,8 @@
private boolean haltonmissing;
+ private String pubBranch;
+
public String[] getConfs() {
return confs;
}
@@ -147,4 +149,13 @@
return this;
}
+ public String getPubBranch() {
+ return pubBranch;
+ }
+
+ public PublishOptions setPubbranch(String pubbranch) {
+ this.pubBranch = pubbranch;
+ return this;
+ }
+
}
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=674868&r1=674867&r2=674868&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
Tue Jul 8 09:16:00 2008
@@ -62,6 +62,7 @@
* it as is.
*/
private boolean updateBranch = true;
+ private String branch;
public ParserSettings getSettings() {
return settings;
@@ -126,4 +127,11 @@
this.updateBranch = updateBranch;
return this;
}
+ public String getBranch() {
+ return branch;
+ }
+ public UpdateOptions setBranch(String pubBranch) {
+ this.branch = pubBranch;
+ 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=674868&r1=674867&r2=674868&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
Tue Jul 8 09:16:00 2008
@@ -520,7 +520,11 @@
if (rev == null) {
rev = substitute(settings, attributes.getValue("revision"));
}
- ModuleRevisionId localMid =
ModuleRevisionId.newInstance(organisation, module, null,
+ String branch = options.getBranch();
+ if (branch == null) {
+ branch = substitute(settings, attributes.getValue("branch"));
+ }
+ ModuleRevisionId localMid =
ModuleRevisionId.newInstance(organisation, module, branch,
rev, ExtendableItemHelper.getExtraAttributes(settings,
attributes,
new String[] {"organisation", "module", "revision",
"status", "publication",
"namespace"}));
@@ -529,6 +533,9 @@
write("<info organisation=\"" +
XMLHelper.escape(systemMid.getOrganisation())
+ "\" module=\"" + XMLHelper.escape(systemMid.getName()) +
"\"");
+ if (systemMid.getBranch() != null) {
+ write(" branch=\"" + XMLHelper.escape(systemMid.getBranch()) +
"\"");
+ }
if (systemMid.getRevision() != null) {
write(" revision=\"" +
XMLHelper.escape(systemMid.getRevision()) + "\"");
}
@@ -543,7 +550,7 @@
write(" publication=\""
+ substitute(settings,
attributes.getValue("publication")) + "\"");
}
- Collection stdAtts = Arrays.asList(new String[] {"organisation",
"module",
+ Collection stdAtts = Arrays.asList(new String[] {"organisation",
"module", "branch",
"revision", "status", "publication", "namespace"});
if (attributes.getValue("namespace") != null) {
write(" namespace=\"" + substitute(settings,
attributes.getValue("namespace"))
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=674868&r1=674867&r2=674868&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 Tue Jul
8 09:16:00 2008
@@ -180,6 +180,26 @@
.getDependencyRevisionId());
}
+ public void testReplaceBranchInfo() 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.setPubbranch("BRANCH1");
+ deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
+ 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",
"BRANCH1", "1.2"),
+ md.getModuleRevisionId());
+ }
+
public void testWithBranch() throws Exception {
// test case for IVY-404
project.setProperty("ivy.dep.file",
"test/java/org/apache/ivy/ant/ivy-latest-branch.xml");
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPublishTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPublishTest.java?rev=674868&r1=674867&r2=674868&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPublishTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyPublishTest.java Tue Jul
8 09:16:00 2008
@@ -298,6 +298,42 @@
.getRevision());
}
+ public void testNoDeliverWithBranch() 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();
+
+ publish.setUpdate(true);
+ publish.setPubrevision("1.3");
+ publish.setPubbranch("BRANCH1");
+ publish.setResolver("1");
+ publish.setSrcivypattern("build/test/publish/ivy-1.3.xml");
+
+ FileUtil.copy(new
File("test/java/org/apache/ivy/ant/ivy-publish.xml"), new File(
+ "build/test/publish/ivy-1.3.xml"), null);
+
+ File art = new File("build/test/publish/resolve-latest-1.3.jar");
+ FileUtil.copy(new
File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), art, null);
+ publish.execute();
+
+ // should have published the files with "1" resolver
+ assertTrue(new
File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").exists());
+ assertTrue(new
File("test/repositories/1/apache/resolve-latest/jars/resolve-latest-1.3.jar")
+ .exists());
+
+ // the published ivy version should be ok (ok in ivy-publish file)
+ ModuleDescriptor md =
XmlModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(),
+ new
File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").toURL(),
false);
+ assertEquals("BRANCH1", md.getModuleRevisionId().getBranch());
+ assertEquals("1.3", md.getModuleRevisionId().getRevision());
+
+ // should not have done delivery (replace dynamic revisions with
static ones)
+ assertEquals("latest.integration",
md.getDependencies()[0].getDependencyRevisionId()
+ .getRevision());
+ }
+
public void testForceDeliver() throws Exception {
project.setProperty("ivy.dep.file",
"test/java/org/apache/ivy/ant/ivy-latest.xml");
IvyResolve res = new IvyResolve();