FIX: packaging data not parsed in maven 2 pom (IVY-500) (thanks to Jeffrey Blatttman)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/core/trunk@537380 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2007-05-12 10:37:26 +00:00
parent f8a3e4edbe
commit 1a89989477
4 changed files with 68 additions and 2 deletions

View File

@ -51,6 +51,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
- IMPROVEMENT: Allow "main" parameters to be passed directly (instead of using -args flag) (IVY-480) (thanks to Archie Cobbs)
- FIX: packaging data not parsed in maven 2 pom (IVY-500) (thanks to Jeffrey Blatttman)
- FIX: install ant task: requires default resolver in ivy settings (IVY-477)
- FIX: Ant project reference lost from context on multiple ant calls in single thread (IVY-497) (thanks to Jaroslaw Wypychowski)
- FIX: EOL in the doc pages (IVY-470)

View File

@ -85,6 +85,8 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
private String _revision;
private String _scope;
private String _classifier;
private String _type;
private String _ext;
private boolean _optional = false;
private List _exclusions = new ArrayList();
private DefaultDependencyDescriptor _dd;
@ -138,7 +140,10 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
_properties.put("project.version", _revision);
_properties.put("pom.version", _revision);
_md.setModuleRevisionId(mrid);
_md.addArtifact("master", new DefaultArtifact(mrid, getDefaultPubDate(),_module, "jar", "jar"));
if (_type == null) {
_type = _ext = "jar";
}
_md.addArtifact("master", new DefaultArtifact(mrid, getDefaultPubDate(),_module, _type, _ext));
_organisation = null;
_module = null;
_revision = null;
@ -177,7 +182,7 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
_dd.addDependencyArtifact(
confs[i],
new DefaultDependencyArtifactDescriptor(
_dd.getDependencyId().getName(),
_dd.getDependencyId().getName(),
"jar",
"jar", // here we have to assume a type and ext for the artifact, so this is a limitation compared to how m2 behave with classifiers
null,
@ -232,6 +237,11 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
_revision = txt;
return;
}
if (context.equals("project/parent/packaging") && _type == null) {
_type = txt;
_ext = txt;
return;
}
if (context.startsWith("project/parent")) {
return;
}
@ -247,6 +257,9 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
_revision = txt;
} else if (_revision == null && context.endsWith("version")) {
_revision = txt;
} else if (_type == null && context.endsWith("packaging")) {
_type = txt;
_ext = txt;
} else if (_scope == null && context.endsWith("scope")) {
_scope = txt;
} else if (_classifier == null && context.endsWith("dependency/classifier")) {

View File

@ -58,6 +58,26 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(1, artifact.length);
assertEquals(mrid, artifact[0].getModuleRevisionId());
assertEquals("test", artifact[0].getName());
assertEquals("jar", artifact[0].getExt());
assertEquals("jar", artifact[0].getType());
}
public void testPackaging() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), getClass().getResource("test-packaging.pom"), false);
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0");
assertEquals(mrid, md.getModuleRevisionId());
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(PomModuleDescriptorParser.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("war", artifact[0].getExt());
assertEquals("war", artifact[0].getType());
}
public void testParent() throws Exception {

View File

@ -0,0 +1,32 @@
<?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>
<packaging>war</packaging>
<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>
</project>