Author: maartenc Date: Thu Oct 2 13:19:59 2008 New Revision: 701232 URL: http://svn.apache.org/viewvc?rev=701232&view=rev Log: FIX: Maven2 parser doesn't support POMs with <model> as root (IVY-932)
Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-model.pom Modified: ant/ivy/core/trunk/CHANGES.txt 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=701232&r1=701231&r2=701232&view=diff ============================================================================== --- ant/ivy/core/trunk/CHANGES.txt (original) +++ ant/ivy/core/trunk/CHANGES.txt Thu Oct 2 13:19:59 2008 @@ -99,6 +99,7 @@ - FIX: ivy:settings doesn't work if id is a property (IVY-925) - FIX: HttpClientHandler hanging in certain cases (IVY-930) (thanks to Scott Hebert) - FIX: Can't download files containing space or + in their names by HTTP (IVY-923) +- FIX: Maven2 parser doesn't support POMs with <model> as root (IVY-932) 2.0.0-rc1 ===================================== 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=701232&r1=701231&r2=701232&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 Thu Oct 2 13:19:59 2008 @@ -58,6 +58,7 @@ private static final String DEPENDENCIES = "dependencies"; private static final String DEPENDENCY_MGT = "dependencyManagement"; private static final String PROJECT = "project"; + private static final String MODEL = "model"; private static final String GROUP_ID = "groupId"; private static final String ARTIFACT_ID = "artifactId"; private static final String VERSION = "version"; @@ -99,7 +100,7 @@ } }); projectElement = pomDomDoc.getDocumentElement(); - if (!PROJECT.equals(projectElement.getNodeName())) { + if (!PROJECT.equals(projectElement.getNodeName()) && !MODEL.equals(projectElement.getNodeName())) { throw new SAXParseException("project must be the root tag" , res.getName() , res.getName(), 0, 0); } 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=701232&r1=701231&r2=701232&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 Thu Oct 2 13:19:59 2008 @@ -631,5 +631,25 @@ settings, getClass().getResource("test-entity.pom"), true); assertNotNull(md); } + + public void testModel() throws Exception { + ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor( + settings, getClass().getResource("test-model.pom"), false); + assertNotNull(md); + + ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0"); + assertEquals(mrid, md.getModuleRevisionId()); + + assertNotNull(md.getConfigurations()); + assertEquals(Arrays.asList(PomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS), Arrays + .asList(md.getConfigurations())); + + Artifact[] artifact = md.getArtifacts("master"); + assertEquals(1, artifact.length); + assertEquals(mrid, artifact[0].getModuleRevisionId()); + assertEquals("test", artifact[0].getName()); + assertEquals("jar", artifact[0].getExt()); + assertEquals("jar", artifact[0].getType()); + } } Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-model.pom URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-model.pom?rev=701232&view=auto ============================================================================== --- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-model.pom (added) +++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-model.pom Thu Oct 2 13:19:59 2008 @@ -0,0 +1,31 @@ +<?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. +--> +<model> + <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://ant.apache.org/ivy</url> + <organization> + <name>Jayasoft</name> + <url>http://www.jayasoft.org/</url> + </organization> +</model>