Author: xavier
Date: Fri Jun 6 03:07:18 2008
New Revision: 663878
URL: http://svn.apache.org/viewvc?rev=663878&view=rev
Log:
IMPROVEMENT: declare source and javadoc artifacts in maven2 modules (IVY-325)
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-m2-with-sources-and-javadoc-auto.xml
(with props)
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources/1.0/test-sources-1.0-javadoc.jar
(with props)
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0-sources.jar
(with props)
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.jar
(with props)
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.pom
(with props)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=663878&r1=663877&r2=663878&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Jun 6 03:07:18 2008
@@ -71,6 +71,7 @@
- NEW: Add a new resolve mode (optionally per module) to utilize dynamic
constraint rule metadata (IVY-740)
- NEW: Add transitive dependency version and branch override mechanism
(IVY-784)
+- IMPROVEMENT: declare source and javadoc artifacts in maven2 modules (IVY-325)
- IMPROVEMENT: Set the last modified attribute of files downloaded from
repositories (IVY-823)
- IMPROVEMENT: If DNS is playing up, Ivy takes a lot longer to sort project
dependencies (IVY-817)
- IMPROVEMENT: make it possible to specify permissions of published files for
the SSH resolver (IVY-764)
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java?rev=663878&r1=663877&r2=663878&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
Fri Jun 6 03:07:18 2008
@@ -19,6 +19,7 @@
import java.text.ParseException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
@@ -28,6 +29,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.DefaultArtifact;
import
org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor;
@@ -35,6 +37,7 @@
import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.MDArtifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import
org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator;
import org.apache.ivy.core.module.descriptor.Configuration.Visibility;
@@ -90,6 +93,12 @@
+ "which contains it explicitly. The artifact is always
available and is not "
+ "looked up in a repository.",
new String[0], true, null),
+ new Configuration("sources", Visibility.PUBLIC,
+ "this configuration contains the source artifact of this module,
if any.",
+ new String[0], true, null),
+ new Configuration("javadoc", Visibility.PUBLIC,
+ "this configuration contains the javadoc artifact of this module,
if any.",
+ new String[0], true, null),
new Configuration("optional", Visibility.PUBLIC,
"contains all optional dependencies", new String[0], true,
null)
};
@@ -470,5 +479,25 @@
addExtraInfo(getPropertyExtraInfoKey(propertyName), value);
}
+
+ public Artifact getSourceArtifact() {
+ return new MDArtifact(
+ ivyModuleDescriptor, mrid.getName(), "source", "jar",
+ null, Collections.singletonMap("classifier", "sources"));
+ }
+
+ public Artifact getJavadocArtifact() {
+ return new MDArtifact(
+ ivyModuleDescriptor, mrid.getName(), "javadoc", "jar",
+ null, Collections.singletonMap("classifier", "javadoc"));
+ }
+
+ public void addSourceArtifact() {
+ ivyModuleDescriptor.addArtifact("sources", getSourceArtifact());
+ }
+
+ public void addJavadocArtifact() {
+ ivyModuleDescriptor.addArtifact("javadoc", getJavadocArtifact());
+ }
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?rev=663878&r1=663877&r2=663878&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
Fri Jun 6 03:07:18 2008
@@ -242,6 +242,8 @@
}
mdBuilder.addArtifact(artifactId , domReader.getPackaging());
+
+ addSourcesAndJavadocArtifactsIfPresent(mdBuilder, ivySettings);
}
} catch (SAXException e) {
throw newParserException(e);
@@ -250,6 +252,34 @@
return mdBuilder.getModuleDescriptor();
}
+ private void addSourcesAndJavadocArtifactsIfPresent(
+ PomModuleDescriptorBuilder mdBuilder, ParserSettings ivySettings) {
+ ModuleDescriptor md = mdBuilder.getModuleDescriptor();
+ ModuleRevisionId mrid = md.getModuleRevisionId();
+ DependencyResolver resolver = ivySettings.getResolver(
+ mrid);
+
+ if (resolver == null) {
+ Message.debug("no resolver found for " + mrid
+ + ": no source or javadoc artifact lookup");
+ } else {
+ Artifact sourceArtifact = mdBuilder.getSourceArtifact();
+ if (resolver.exists(sourceArtifact)) {
+ Message.debug("source artifact found for " + mrid);
+ mdBuilder.addSourceArtifact();
+ } else {
+ Message.debug("no source artifact found for " + mrid);
+ }
+ Artifact javadocArtifact = mdBuilder.getJavadocArtifact();
+ if (resolver.exists(javadocArtifact)) {
+ Message.debug("javadoc artifact found for " + mrid);
+ mdBuilder.addJavadocArtifact();
+ } else {
+ Message.debug("no javadoc artifact found for " + mrid);
+ }
+ }
+ }
+
private ResolvedModuleRevision parseOtherPom(ParserSettings ivySettings,
ModuleRevisionId parentModRevID) throws ParseException {
DependencyDescriptor dd = new
DefaultDependencyDescriptor(parentModRevID, true);
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=663878&r1=663877&r2=663878&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
Fri Jun 6 03:07:18 2008
@@ -3563,6 +3563,30 @@
assertTrue(jarFileInCache.length() != sourceFileInCache.length());
}
+ public void testResolveMaven2GetSourcesAndJavadocAuto() throws Exception {
+ Ivy ivy = new Ivy();
+ ivy.configure(new
File("test/repositories/m2/ivysettings.xml").toURL());
+ ResolveReport report = ivy.resolve(
+
ResolveTest.class.getResource("ivy-m2-with-sources-and-javadoc-auto.xml"),
+ getResolveOptions(new String[] {"*"}));
+ assertNotNull(report);
+ assertFalse(report.hasError());
+
+ assertTrue(getIvyFileInCache(
+ ModuleRevisionId.newInstance("org.apache", "test-sources",
"1.0")).exists());
+ File jarFileInCache = getArchiveFileInCache(ivy, "org.apache",
"test-sources",
+ "1.0", "test-sources", "jar", "jar");
+ assertTrue(jarFileInCache.exists());
+ File sourceFileInCache = getArchiveFileInCache(ivy, "org.apache",
"test-sources",
+ "1.0", "test-sources", "source", "jar");
+ assertTrue(sourceFileInCache.exists());
+ assertTrue(jarFileInCache.length() != sourceFileInCache.length());
+ File javadocFileInCache = getArchiveFileInCache(ivy, "org.apache",
"test-sources",
+ "1.0", "test-sources", "javadoc", "jar");
+ assertTrue(javadocFileInCache.exists());
+ assertTrue(jarFileInCache.length() != javadocFileInCache.length());
+ }
+
public void testResolveMaven2WithVersionProperty() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new
File("test/repositories/m2/ivysettings.xml").toURL());
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-m2-with-sources-and-javadoc-auto.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-m2-with-sources-and-javadoc-auto.xml?rev=663878&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-m2-with-sources-and-javadoc-auto.xml
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-m2-with-sources-and-javadoc-auto.xml
Fri Jun 6 03:07:18 2008
@@ -0,0 +1,24 @@
+<!--
+ 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="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
+ <info organisation="apache" module="test-m2-with-sources-auto"
revision="1.0" />
+ <dependencies>
+ <dependency org="org.apache" name="test-sources" rev="1.0"
conf="default->sources,javadoc,master" />
+ </dependencies>
+</ivy-module>
Propchange:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-m2-with-sources-and-javadoc-auto.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-m2-with-sources-and-javadoc-auto.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources/1.0/test-sources-1.0-javadoc.jar
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources/1.0/test-sources-1.0-javadoc.jar?rev=663878&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources/1.0/test-sources-1.0-javadoc.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0-sources.jar
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0-sources.jar?rev=663878&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0-sources.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.jar
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.jar?rev=663878&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.pom
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.pom?rev=663878&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.pom
(added)
+++
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.pom
Fri Jun 6 03:07:18 2008
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache</groupId>
+ <artifactId>test-sources2</artifactId>
+ <name>Test Module for Ivy M2 parsing</name>
+ <version>1.0</version>
+ <url>http://ivy.jayasoft.org/</url>
+ <organization>
+ <name>Jayasoft</name>
+ <url>http://www.jayasoft.org/</url>
+ </organization>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache</groupId>
+ <artifactId>test-sources</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange:
ant/ivy/core/trunk/test/repositories/m2/org/apache/test-sources2/1.0/test-sources2-1.0.pom
------------------------------------------------------------------------------
svn:eol-style = native