Index: test/java/org/apache/ivy/ant/IvyInfoTest.java =================================================================== --- test/java/org/apache/ivy/ant/IvyInfoTest.java (revision 908304) +++ test/java/org/apache/ivy/ant/IvyInfoTest.java (working copy) @@ -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")); + } + +} Index: test/java/org/apache/ivy/ant/ivy-artifact-info.xml =================================================================== --- test/java/org/apache/ivy/ant/ivy-artifact-info.xml (revision 0) +++ test/java/org/apache/ivy/ant/ivy-artifact-info.xml (revision 0) @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + Index: src/java/org/apache/ivy/ant/IvyInfo.java =================================================================== --- src/java/org/apache/ivy/ant/IvyInfo.java (revision 908304) +++ src/java/org/apache/ivy/ant/IvyInfo.java (working copy) @@ -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()); + } + } } } Index: doc/use/info.html =================================================================== --- doc/use/info.html (revision 908304) +++ doc/use/info.html (working copy) @@ -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. --> - + @@ -34,15 +34,21 @@ PropertyDescription -ivy.organisationThe organisation of the module, as found in the info tag of the ivy file parsed -ivy.moduleThe name of the module, as found in the info tag of the ivy file parsed -ivy.branchThe branch of the module if any, as found in the info tag of the ivy file parsed -ivy.revisionThe revision of the module, as found in the info tag of the ivy file parsed -ivy.statusThe status of the module, as found in the info tag of the ivy file parsed +ivy.organisationThe organisation of the module, as found in the info tag of the ivy file parsed. +ivy.moduleThe name of the module, as found in the info tag of the ivy file parsed. +ivy.branchThe branch of the module if any, as found in the info tag of the ivy file parsed. +ivy.revisionThe revision of the module, as found in the info tag of the ivy file parsed. +ivy.statusThe status of the module, as found in the info tag of the ivy file parsed. +ivy.publicationThe publication time of the module, as found in the info tag of the ivy file parsed. (Since 2.2) ivy.extra.[any extra attribute]Corresponding extra attribute value, as found in the info tag of the ivy file parsed ivy.configurationsA comma separated list of configurations of the module, as declared in the configurations section ivy.public.configurationsA comma separated list of public configurations of the module, as declared in the configurations section ivy.configuration.[config name].descFor each configuration with a description, a property is created containing this description. (Since 2.2) +ivy.artifact.[index].nameFor each published artifact, a property is created containing its name. (Since 2.2) +ivy.artifact.[index].typeFor each published artifact, a property is created containing its type. (Since 2.2) +ivy.artifact.[index].extFor each published artifact, a property is created containing its ext. (Since 2.2) +ivy.artifact.[index].confFor each published artifact, a property is created containing its conf. (Since 2.2) +ivy.artifact.[index].extra.[any extra attribute]For each extra attribute of the published artifact, a property is created containing its name. (Since 2.2)
@@ -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 mymodule.organisation, mymodule.module, mymodule.revision etc. +since 2.2 + +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. +

Attributes

@@ -79,7 +89,7 @@

Examples

Given this ivy.xml file: - + + + + + @@ -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 Given the same ivy module in a repository: @@ -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