Author: maartenc
Date: Wed Feb 10 22:13:09 2010
New Revision: 908679
URL: http://svn.apache.org/viewvc?rev=908679&view=rev
Log:
IMPROVEMENT: Enhance <info/> task to access the 'publication', 'branch' and
published artifacts as ant propeties (IVY-395) (thanks to Carl Quinn)
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-artifact-info.xml
(with props)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/doc/use/info.html
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=908679&r1=908678&r2=908679&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Feb 10 22:13:09 2010
@@ -75,6 +75,7 @@
Emmanuel Pellereau
Roshan Punnoose
Jean-Baptiste Quenot
+ Carl Quinn
Damon Rand
Geoff Reedy
Christian Riege
@@ -102,6 +103,7 @@
- NEW: Make ivy.xml <conf description> available (IVY-1158)
+- IMPROVEMENT: Enhance <info/> task to access the 'publication', 'branch' and
published artifacts as ant propeties (IVY-395) (thanks to Carl Quinn)
- IMPROVEMENT: Ivy doesn't support Maven 2.0.9 'import' scope (IVY-807)
- IMPROVEMENT: resolver attribute for listmodules task (IVY-1057)
- IMPROVEMENT: discover 'src' sources in maven repos (IVY-1138)
Modified: ant/ivy/core/trunk/doc/use/info.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/info.html?rev=908679&r1=908678&r2=908679&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/info.html (original)
+++ ant/ivy/core/trunk/doc/use/info.html Wed Feb 10 22:13:09 2010
@@ -15,12 +15,12 @@
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
- under the License.
+ under the License.
-->
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
- <script type="text/javascript">var xookiConfig = {level: 1};</script>
+ <script type="text/javascript">var xookiConfig = {level: 1};</script>
<script type="text/javascript" src="../xooki/xooki.js"></script>
</head>
<body>
@@ -34,15 +34,21 @@
<tr><th class="ant-prop">Property</th><th
class="ant-desc">Description</th></tr>
</thead>
<tbody>
-<tr><td>ivy.organisation</td><td>The organisation of the module, as found in
the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
-<tr><td>ivy.module</td><td>The name of the module, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
-<tr><td>ivy.branch</td><td>The branch of the module if any, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
-<tr><td>ivy.revision</td><td>The revision of the module, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
-<tr><td>ivy.status</td><td>The status of the module, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
+<tr><td>ivy.organisation</td><td>The organisation of the module, as found in
the <a href="../ivyfile/info.html">info</a> tag of the ivy file
parsed.</td></tr>
+<tr><td>ivy.module</td><td>The name of the module, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed.</td></tr>
+<tr><td>ivy.branch</td><td>The branch of the module if any, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed.</td></tr>
+<tr><td>ivy.revision</td><td>The revision of the module, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed.</td></tr>
+<tr><td>ivy.status</td><td>The status of the module, as found in the <a
href="../ivyfile/info.html">info</a> tag of the ivy file parsed.</td></tr>
+<tr><td>ivy.publication</td><td>The publication time of the module, as found
in the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed.
<span class="since">(Since 2.2)</span></td></tr>
<tr><td>ivy.extra.<i>[any extra attribute]</i></td><td>Corresponding extra
attribute value, as found in the <a href="../ivyfile/info.html">info</a> tag of
the ivy file parsed</td></tr>
<tr><td>ivy.configurations</td><td>A comma separated list of configurations of
the module, as declared in the <a
href="../ivyfile/configurations.html">configurations</a> section</td></tr>
<tr><td>ivy.public.configurations</td><td>A comma separated list of public
configurations of the module, as declared in the <a
href="../ivyfile/configurations.html">configurations</a> section</td></tr>
<tr><td>ivy.configuration.<i>[config name]</i>.desc</td><td>For each
configuration with a description, a property is created containing this
description. <span class="since">(Since 2.2)</span></td></tr>
+<tr><td>ivy.artifact.<i>[index]</i>.name</td><td>For each published artifact,
a property is created containing its name. <span class="since">(Since
2.2)</span></td></tr>
+<tr><td>ivy.artifact.<i>[index]</i>.type</td><td>For each published artifact,
a property is created containing its type. <span class="since">(Since
2.2)</span></td></tr>
+<tr><td>ivy.artifact.<i>[index]</i>.ext</td><td>For each published artifact, a
property is created containing its ext. <span class="since">(Since
2.2)</span></td></tr>
+<tr><td>ivy.artifact.<i>[index]</i>.conf</td><td>For each published artifact,
a property is created containing its conf. <span class="since">(Since
2.2)</span></td></tr>
+<tr><td>ivy.artifact.<i>[index]</i>.extra.<i>[any extra
attribute]</i></td><td>For each extra attribute of the published artifact, a
property is created containing its name. <span class="since">(Since
2.2)</span></td></tr>
</tbody>
</table>
<br/>
@@ -56,6 +62,10 @@
You may now also set the property attribute to change the first part of the
property names that are set by this task e.g. if you set the property attribute
to 'mymodule' this task will set the ant properties
<i>mymodule.organisation</i>, <i>mymodule.module</i>, <i>mymodule.revision</i>
etc.
+<span class="since">since 2.2</span>
+
+Since Ivy 2.2 this task has been enhanced to also retrieve detailed
information about the module's published artifacts, as well as the publication
time.
+
<h1>Attributes</h1>
<table class="ant">
<thead>
@@ -79,7 +89,7 @@
<h1>Examples</h1>
Given this ivy.xml file:
<code>
-<ivy-module version="1.0" xmlns:e="http://ant.apache.org/ivy/extra">
+<ivy-module version="1.0" xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="apache"
module="info-all"
branch="trunk"
@@ -92,6 +102,10 @@
<conf name="test" />
<conf name="private" visibility="private"/>
</configurations>
+ <publications>
+ <artifact name="thing1" type="jar" ext="jar" conf="default"
e:data="main"/>
+ <artifact name="thing2" type="jar" ext="jar" conf="default"
e:data="client"/>
+ </publications>
<dependencies>
<dependency org="org1" name="mod1.2" rev="2.0"/>
</dependencies>
@@ -110,6 +124,16 @@
ivy.extra.myextraatt=myvalue
ivy.configurations=default, test, private
ivy.public.configurations=default, test
+ivy.artifact.1.name=thing1
+ivy.artifact.1.type=jar
+ivy.artifact.1.ext=jar
+ivy.artifact.1.conf=default
+ivy.artifact.1.extra.data=main
+ivy.artifact.2.name=thing2
+ivy.artifact.2.type=jar
+ivy.artifact.2.ext=jar
+ivy.artifact.2.conf=default
+ivy.artifact.2.extra.data=client
</code>
Given the same ivy module in a repository:
<code>
@@ -129,6 +153,16 @@
infotest.extra.myextraatt=myvalue
infotest.configurations=default, test, private
infotest.public.configurations=default, test
+infotest.artifact.1.name=thing1
+infotest.artifact.1.type=jar
+infotest.artifact.1.ext=jar
+infotest.artifact.1.conf=default
+infotest.artifact.1.extra.data=main
+infotest.artifact.2.name=thing2
+infotest.artifact.2.type=jar
+infotest.artifact.2.ext=jar
+infotest.artifact.2.conf=default
+infotest.artifact.2.extra.data=client
</code>
</textarea>
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java?rev=908679&r1=908678&r2=908679&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java Wed Feb 10
22:13:09 2010
@@ -27,6 +27,7 @@
import java.util.Map.Entry;
import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.descriptor.Configuration.Visibility;
@@ -147,8 +148,8 @@
throw new BuildException("impossible to resolve dependencies: " +
e, e);
}
}
-
- private void setProperties(ModuleDescriptor md, ModuleRevisionId mrid) {
+
+ private void setProperties(ModuleDescriptor md, ModuleRevisionId mrid) {
getProject().setProperty(property + ".organisation",
mrid.getOrganisation());
getProject().setProperty(property + ".module", mrid.getName());
if (mrid.getBranch() != null) {
@@ -156,16 +157,20 @@
}
getProject().setProperty(property + ".revision", mrid.getRevision());
getProject().setProperty(property + ".status", md.getStatus());
-
+ if (md.getPublicationDate() != null) {
+ getProject().setProperty(property + ".publication",
+
Long.toString(md.getPublicationDate().getTime()));
+ }
+
Map extra = mrid.getExtraAttributes();
for (Iterator iter = extra.entrySet().iterator(); iter.hasNext();) {
Entry entry = (Entry) iter.next();
getProject().setProperty(
property + ".extra." + entry.getKey(), (String)
entry.getValue());
}
-
+
getProject().setProperty(
- property + ".configurations",
mergeConfs(md.getConfigurationsNames()));
+ property + ".configurations",
mergeConfs(md.getConfigurationsNames()));
// store the public configurations in a separate property
Configuration[] configs = md.getConfigurations();
@@ -175,14 +180,31 @@
if (Visibility.PUBLIC.equals(configs[i].getVisibility())) {
publicConfigsList.add(name);
}
-
+
if (configs[i].getDescription() != null) {
getProject().setProperty(property + ".configuration." + name +
".desc",
configs[i].getDescription());
}
}
- String[] publicConfigs = (String[]) publicConfigsList
- .toArray(new String[publicConfigsList.size()]);
+ String[] publicConfigs =
+ (String[]) publicConfigsList.toArray(new
String[publicConfigsList.size()]);
getProject().setProperty(property + ".public.configurations",
mergeConfs(publicConfigs));
+
+ Artifact[] artifacts = md.getAllArtifacts();
+ for (int i = 0; i < artifacts.length; i++) {
+ int id = i + 1;
+ getProject().setProperty(property + ".artifact." + id + ".name",
artifacts[i].getName());
+ getProject().setProperty(property + ".artifact." + id + ".type",
artifacts[i].getType());
+ getProject().setProperty(property + ".artifact." + id + ".ext",
artifacts[i].getExt());
+ getProject().setProperty(property + ".artifact." + id + ".conf",
+
mergeConfs(artifacts[i].getConfigurations()));
+
+ Map artiExtra = artifacts[i].getExtraAttributes();
+ for (Iterator iter = artiExtra.entrySet().iterator();
iter.hasNext();) {
+ Entry entry = (Entry) iter.next();
+ getProject().setProperty(property + ".artifact." + id +
".extra." + entry.getKey(),
+ (String) entry.getValue());
+ }
+ }
}
}
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java?rev=908679&r1=908678&r2=908679&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java Wed Feb 10
22:13:09 2010
@@ -36,7 +36,7 @@
public void testSimple() throws Exception {
info.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
info.execute();
-
+
assertEquals("apache",
info.getProject().getProperty("ivy.organisation"));
assertEquals("resolve-simple",
info.getProject().getProperty("ivy.module"));
assertEquals("1.0", info.getProject().getProperty("ivy.revision"));
@@ -47,7 +47,7 @@
public void testAll() throws Exception {
info.setFile(new
File("test/java/org/apache/ivy/ant/ivy-info-all.xml"));
info.execute();
-
+
assertEquals("apache",
info.getProject().getProperty("ivy.organisation"));
assertEquals("info-all", info.getProject().getProperty("ivy.module"));
assertEquals("1.0", info.getProject().getProperty("ivy.revision"));
@@ -56,7 +56,7 @@
assertEquals("default, test",
info.getProject().getProperty("ivy.public.configurations"));
assertEquals("trunk", info.getProject().getProperty("ivy.branch"));
assertEquals("myvalue",
info.getProject().getProperty("ivy.extra.myextraatt"));
-
+
// test the configuration descriptions
assertEquals("The default dependencies",
info.getProject().getProperty("ivy.configuration.default.desc"));
assertEquals("Dependencies used for testing",
info.getProject().getProperty("ivy.configuration.test.desc"));
@@ -66,8 +66,30 @@
public void testIVY726() throws Exception {
info.setFile(new
File("test/java/org/apache/ivy/ant/ivy-info-all.xml"));
info.execute();
-
+
assertTrue(info.getProject().getProperty("ivy.extra.branch") == null);
}
-}
\ No newline at end of file
+ public void testIVY395() throws Exception {
+ info.setFile(new
File("test/java/org/apache/ivy/ant/ivy-artifact-info.xml"));
+ info.execute();
+
+ assertEquals("test",
info.getProject().getProperty("ivy.artifact.1.name"));
+ assertEquals("jar",
info.getProject().getProperty("ivy.artifact.1.type"));
+ assertEquals("jar",
info.getProject().getProperty("ivy.artifact.1.ext"));
+ assertEquals("master, alt",
info.getProject().getProperty("ivy.artifact.1.conf"));
+ assertEquals("main",
info.getProject().getProperty("ivy.artifact.1.extra.data"));
+
+ assertEquals("test-a",
info.getProject().getProperty("ivy.artifact.2.name"));
+ assertEquals("jar",
info.getProject().getProperty("ivy.artifact.2.type"));
+ assertEquals("jar",
info.getProject().getProperty("ivy.artifact.2.ext"));
+ assertEquals("alt",
info.getProject().getProperty("ivy.artifact.2.conf"));
+ assertEquals("client",
info.getProject().getProperty("ivy.artifact.2.extra.data"));
+
+ assertEquals("stuff",
info.getProject().getProperty("ivy.artifact.3.name"));
+ assertEquals("javadoc",
info.getProject().getProperty("ivy.artifact.3.type"));
+ assertEquals("zip",
info.getProject().getProperty("ivy.artifact.3.ext"));
+ assertEquals("doc",
info.getProject().getProperty("ivy.artifact.3.conf"));
+ }
+
+}
Added: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-artifact-info.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-artifact-info.xml?rev=908679&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-artifact-info.xml
(added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-artifact-info.xml Wed
Feb 10 22:13:09 2010
@@ -0,0 +1,36 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ivy-module version="1.0" xmlns:e="http://ant.apache.org/ivy/extra">
+ <info organisation="org.apache"
+ module="test"
+ revision="1.0"
+ status="integration"
+ publication="20060119075801"
+ />
+ <configurations>
+ <conf name="master" description="Master dependencies" />
+ <conf name="alt" description="Alternate dependencies" />
+ <conf name="doc" description="Documentation dependencies" />
+ </configurations>
+ <publications>
+ <artifact name="test" type="jar" ext="jar" conf="master,alt"
e:data="main"/>
+ <artifact name="test-a" type="jar" ext="jar" conf="alt"
e:data="client"/>
+ <artifact name="stuff" type="javadoc" ext="zip" conf="doc"/>
+ </publications>
+</ivy-module>
Propchange:
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-artifact-info.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain