You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2008/05/27 00:01:35 UTC

svn commit: r660322 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/plugins/parser/m2/ test/java/org/apache/ivy/plugins/parser/m2/

Author: maartenc
Date: Mon May 26 15:01:29 2008
New Revision: 660322

URL: http://svn.apache.org/viewvc?rev=660322&view=rev
Log:
FIX: Type tag in poms not supported (IVY-762)

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom
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/PomReader.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=660322&r1=660321&r2=660322&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon May 26 15:01:29 2008
@@ -81,6 +81,7 @@
 - IMPROVEMENT: Change allownomd and skipbuildwithoutivy into a more semantically correct name (IVY-297)
 - IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher and GlobPatternMatcher
 
+- FIX: Type tag in poms not supported (IVY-762)
 - FIX: An empty exclusion tag results in an IllegalArgumentException (IVY-821)
 - FIX: Maven scope defined in POM dependencyManagement section not honoured (IVY-811)
 - FIX: SFTPRepository incorrectly calculates last modified time for resources (IVY-815)

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=660322&r1=660321&r2=660322&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 Mon May 26 15:01:29 2008
@@ -245,13 +245,19 @@
         ConfMapper mapping = (ConfMapper) MAVEN2_CONF_MAPPING.get(scope);
         mapping.addMappingConfs(dd, dep.isOptional());
         Map extraAtt = new HashMap();
-        if (dep.getClassifier() != null) {
+        if ((dep.getClassifier() != null) || (dep.getType() != null)) {
+            String type = "jar";
+            if (dep.getType() != null) {
+                type = dep.getType();
+            }
             // we deal with classifiers by setting an extra attribute and forcing the
             // dependency to assume such an artifact is published
-            extraAtt.put("m:classifier", dep.getClassifier());
+            if (dep.getClassifier() != null) {
+                extraAtt.put("m:classifier", dep.getClassifier());
+            }
             DefaultDependencyArtifactDescriptor depArtifact = 
                     new DefaultDependencyArtifactDescriptor(dd, dd.getDependencyId().getName(),
-                        "jar", "jar", null, extraAtt);
+                        type, type, null, extraAtt);
             // here we have to assume a type and ext for the artifact, so this is a limitation
             // compared to how m2 behave with classifiers
             String optionalizedScope = dep.isOptional() ? "optional" : scope;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java?rev=660322&r1=660321&r2=660322&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java Mon May 26 15:01:29 2008
@@ -66,7 +66,7 @@
     private static final String PROPERTIES = "properties";
     private static final String PLUGINS = "plugins";
     private static final String PLUGIN = "plugin";
-    
+    private static final String TYPE = "type";
 
     private HashMap properties = new HashMap();
     
@@ -331,6 +331,11 @@
             String val = getFirstChildText(depElement , CLASSIFIER);
             return replaceProps(val);
         }
+        
+        public String getType() {
+            String val = getFirstChildText(depElement, TYPE);
+            return replaceProps(val);
+        }
 
         public boolean isOptional() {
             return getFirstChildElement(depElement, OPTIONAL) != null;

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java?rev=660322&r1=660321&r2=660322&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java Mon May 26 15:01:29 2008
@@ -218,6 +218,25 @@
         assertEquals(extraAtt, dds[0].getAllDependencyArtifacts()[0].getExtraAttributes());
     }
 
+    public void testDependenciesWithType() throws Exception {
+        ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
+            settings, getClass().getResource("test-dependencies-with-type.pom"),
+            true);
+        assertNotNull(md);
+
+        assertEquals(ModuleRevisionId.newInstance("org.apache", "test", "1.0"), md
+                .getModuleRevisionId());
+
+        DependencyDescriptor[] dds = md.getDependencies();
+        assertNotNull(dds);
+        assertEquals(1, dds.length);
+        assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"),
+            dds[0].getDependencyRevisionId());
+        assertEquals(1, dds[0].getAllDependencyArtifacts().length);
+        assertEquals("dll", dds[0].getAllDependencyArtifacts()[0].getExt());
+        assertEquals("dll", dds[0].getAllDependencyArtifacts()[0].getType());
+    }
+
     public void testWithVersionPropertyAndPropertiesTag() throws Exception {
         ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
             settings, getClass().getResource("test-version.pom"), false);

Added: 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=660322&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-dependencies-with-type.pom Mon May 26 15:01:29 2008
@@ -0,0 +1,39 @@
+<?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</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>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+      <type>dll</type>
+    </dependency>
+  </dependencies>
+</project>