Author: maartenc
Date: Thu Aug 11 21:32:39 2011
New Revision: 1156840
URL: http://svn.apache.org/viewvc?rev=1156840&view=rev
Log:
IMPROVEMENT: ivy:makepom ignores the artifact type in generated dependencies
(IVY-1229) (thanks to Andreas Mandel)
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-classifier.xml
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-type.xml
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1156840&r1=1156839&r2=1156840&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Aug 11 21:32:39 2011
@@ -77,6 +77,7 @@ for detailed view of each issue, please
Stephen Nesbitt
Joshua Nichols
Bernard Niset
+ Andreas Mandel
David Maplesden
Glen Marchesani
Phil Messenger
@@ -126,6 +127,7 @@ for detailed view of each issue, please
- NEW: Import Bushel into Ivy core (IVY-1241)
- NEW: An new resolver 'mirroredurl' which can handle a list of mirrored URL
repositories
+- IMPROVEMENT: ivy:makepom ignores the artifact type in generated dependencies
(IVY-1229) (thanks to Andreas Mandel)
- IMPROVEMENT: ivy:makepom now honors exclusion of artifacts in generated pom
files (IVY-1294) (thanks to Jens Rohloff)
- IMPROVEMENT: Added support for dynamic revisions in <extends> tag (IVY-1281)
(thanks to Jean-Louis Boudart)
- IMPROVEMENT: ivy:makepom child element dependency should support the type
and classifier attributes (IVY-1262)
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java?rev=1156840&r1=1156839&r2=1156840&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
Thu Aug 11 21:32:39 2011
@@ -35,6 +35,7 @@ import org.apache.ivy.Ivy;
import org.apache.ivy.core.IvyContext;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ExcludeRule;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
@@ -217,41 +218,16 @@ public final class PomModuleDescriptorWr
// print the extra dependencies first
for (Iterator it = extraDeps.iterator(); it.hasNext(); ) {
PomWriterOptions.ExtraDependency dep = (ExtraDependency)
it.next();
-
- indent(out, indent * 2);
- out.println("<dependency>");
String groupId = dep.getGroup();
if (groupId == null) {
groupId = md.getModuleRevisionId().getOrganisation();
}
- indent(out, indent * 3);
- out.println("<groupId>" + groupId + "</groupId>");
- indent(out, indent * 3);
- out.println("<artifactId>" + dep.getArtifact() +
"</artifactId>");
String version = dep.getVersion();
if (version == null) {
version = md.getModuleRevisionId().getRevision();
}
- indent(out, indent * 3);
- out.println("<version>" + version + "</version>");
- if (dep.getType() != null) {
- indent(out, indent * 3);
- out.println("<type>" + dep.getType() + "</type>");
- }
- if (dep.getClassifier() != null) {
- indent(out, indent * 3);
- out.println("<classifier>" + dep.getClassifier() +
"</classifier>");
- }
- if (dep.getScope() != null) {
- indent(out, indent * 3);
- out.println("<scope>" + dep.getScope() + "</scope>");
- }
- if (dep.isOptional()) {
- indent(out, indent * 3);
- out.println("<optional>true</optional>");
- }
- indent(out, indent * 2);
- out.println("</dependency>");
+ printDependency(out, indent, groupId, dep.getArtifact(),
version, dep.getType(),
+ dep.getClassifier(), dep.getScope(), dep.isOptional(),
null);
}
// now print the dependencies listed in the ModuleDescriptor
@@ -262,29 +238,27 @@ public final class PomModuleDescriptorWr
for (int i = 0; i < dds.length; i++) {
ModuleRevisionId mrid = dds[i].getDependencyRevisionId();
- indent(out, indent * 2);
- out.println("<dependency>");
- indent(out, indent * 3);
- out.println("<groupId>" + mrid.getOrganisation() +
"</groupId>");
- indent(out, indent * 3);
- out.println("<artifactId>" + mrid.getName() + "</artifactId>");
- indent(out, indent * 3);
- out.println("<version>" + mrid.getRevision() + "</version>");
- String scope =
mapping.getScope(dds[i].getModuleConfigurations());
- if (scope != null) {
- indent(out, indent * 3);
- out.println("<scope>" + scope + "</scope>");
- }
- if (mapping.isOptional(dds[i].getModuleConfigurations())) {
- indent(out, indent * 3);
- out.println("<optional>true</optional>");
- }
-
+ ExcludeRule[] excludes = null;
if(dds[i].canExclude()){
- printExclusions(dds[i].getAllExcludeRules(), out, indent);
+ excludes = dds[i].getAllExcludeRules();
+ }
+ DependencyArtifactDescriptor[] dads =
dds[i].getAllDependencyArtifacts();
+ if(dads.length > 0) {
+ for (int j = 0; j < dads.length; j++) {
+ String type = dads[j].getType();
+ String classifier =
dads[j].getExtraAttribute("classifier");
+ String scope =
mapping.getScope(dds[i].getModuleConfigurations());
+ boolean optional =
mapping.isOptional(dds[i].getModuleConfigurations());
+ printDependency(out, indent, mrid.getOrganisation(),
mrid.getName(),
+ mrid.getRevision(), type, classifier, scope,
optional, excludes);
+ }
+ }
+ else {
+ String scope =
mapping.getScope(dds[i].getModuleConfigurations());
+ boolean optional =
mapping.isOptional(dds[i].getModuleConfigurations());
+ printDependency(out, indent, mrid.getOrganisation(),
mrid.getName(),
+ mrid.getRevision(), null, null, scope, optional,
excludes);
}
- indent(out, indent * 2);
- out.println("</dependency>");
}
if (printDependencies) {
@@ -294,7 +268,41 @@ public final class PomModuleDescriptorWr
}
}
- private static void printExclusions(ExcludeRule[] exclusions, PrintWriter
out, int indent ){
+ private static void printDependency(PrintWriter out, int indent, String
groupId,
+ String artifactId, String version, String type, String classifier,
String scope,
+ boolean isOptional, ExcludeRule[] excludes) {
+ indent(out, indent * 2);
+ out.println("<dependency>");
+ indent(out, indent * 3);
+ out.println("<groupId>" + groupId + "</groupId>");
+ indent(out, indent * 3);
+ out.println("<artifactId>" + artifactId + "</artifactId>");
+ indent(out, indent * 3);
+ out.println("<version>" + version + "</version>");
+ if (type != null && !"jar".equals(type)) {
+ indent(out, indent * 3);
+ out.println("<type>" + type + "</type>");
+ }
+ if (classifier != null) {
+ indent(out, indent * 3);
+ out.println("<classifier>" + classifier + "</classifier>");
+ }
+ if (scope != null) {
+ indent(out, indent * 3);
+ out.println("<scope>" + scope + "</scope>");
+ }
+ if (isOptional) {
+ indent(out, indent * 3);
+ out.println("<optional>true</optional>");
+ }
+ if (excludes != null) {
+ printExclusions(excludes, out, indent);
+ }
+ indent(out, indent * 2);
+ out.println("</dependency>");
+ }
+
+ private static void printExclusions(ExcludeRule[] exclusions, PrintWriter
out, int indent) {
indent(out, indent * 3);
out.println("<exclusions>");
@@ -314,8 +322,6 @@ public final class PomModuleDescriptorWr
out.println("</exclusions>");
}
-
-
private static DependencyDescriptor[] getDependencies(ModuleDescriptor md,
PomWriterOptions options) {
String[] confs =
ConfigurationUtils.replaceWildcards(options.getConfs(), md);
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java?rev=1156840&r1=1156839&r2=1156840&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
Thu Aug 11 21:32:39 2011
@@ -80,6 +80,32 @@ public class PomModuleDescriptorWriterTe
assertEquals(expected, wrote);
}
+ public void testDependenciesWithType() throws Exception {
+ ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(),
getClass().getResource("test-dependencies-with-type.pom"), false);
+ PomModuleDescriptorWriter.write(md, _dest, getWriterOptions());
+ assertTrue(_dest.exists());
+
+ String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
+ "\r\n", "\n").replace('\r', '\n');
+ String expected = readEntirely("test-write-dependencies-with-type.xml")
+ .replaceAll("\r\n", "\n").replace('\r', '\n');
+ assertEquals(expected, wrote);
+ }
+
+ public void testDependenciesWithClassifier() throws Exception {
+ ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(),
getClass().getResource("test-dependencies-with-classifier.pom"), false);
+ PomModuleDescriptorWriter.write(md, _dest, getWriterOptions());
+ assertTrue(_dest.exists());
+
+ String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
+ "\r\n", "\n").replace('\r', '\n');
+ String expected =
readEntirely("test-write-dependencies-with-classifier.xml")
+ .replaceAll("\r\n", "\n").replace('\r', '\n');
+ assertEquals(expected, wrote);
+ }
+
public void testOptional() throws Exception {
ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-optional.pom"),
false);
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom?rev=1156840&r1=1156839&r2=1156840&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-classifier.pom
Thu Aug 11 21:32:39 2011
@@ -23,10 +23,10 @@
<artifactId>test</artifactId>
<name>Test Module for Ivy M2 parsing</name>
<version>1.0</version>
- <url>http://ivy.jayasoft.org/</url>
+ <url>http://ant.apache.org/ivy</url>
<organization>
- <name>Jayasoft</name>
- <url>http://www.jayasoft.org/</url>
+ <name>Apache</name>
+ <url>http://ant.apache.org/ivy</url>
</organization>
<dependencies>
<dependency>
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom?rev=1156840&r1=1156839&r2=1156840&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom
Thu Aug 11 21:32:39 2011
@@ -23,10 +23,10 @@
<artifactId>test</artifactId>
<name>Test Module for Ivy M2 parsing</name>
<version>1.0</version>
- <url>http://ivy.jayasoft.org/</url>
+ <url>http://ant.apache.org/ivy</url>
<organization>
- <name>Jayasoft</name>
- <url>http://www.jayasoft.org/</url>
+ <name>Apache</name>
+ <url>http://ant.apache.org/ivy</url>
</organization>
<dependencies>
<dependency>
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-classifier.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-classifier.xml?rev=1156840&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-classifier.xml
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-classifier.xml
Thu Aug 11 21:32:39 2011
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache</groupId>
+ <artifactId>test</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <url>http://ant.apache.org/ivy</url>
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <classifier>asl</classifier>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-type.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-type.xml?rev=1156840&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-type.xml
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-dependencies-with-type.xml
Thu Aug 11 21:32:39 2011
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache</groupId>
+ <artifactId>test</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <url>http://ant.apache.org/ivy</url>
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <type>dll</type>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>