[MNG-4283] [regression] Parent POM with packaging other than "pom" is not rejected

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@801424 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-05 21:43:24 +00:00
parent 27ff2babf9
commit 7de1280968
5 changed files with 99 additions and 2 deletions

View File

@ -113,7 +113,7 @@ public class DefaultProjectBuilder
}
catch ( ModelBuildingException e )
{
throw new ProjectBuildingException( "[unknown]", "Failed to build project for " + pomFile, pomFile, e );
throw new ProjectBuildingException( "[unknown]", "Encountered POM errors", pomFile, e );
}
Model model = result.getEffectiveModel();

View File

@ -1636,6 +1636,20 @@ public class PomConstructionTest
assertEquals( "PASSED", pom.getValue( "properties/interpolatedProperty" ) );
}
public void testParentPomPackagingMustBePom()
throws Exception
{
try
{
buildPom( "parent-pom-packaging/sub" );
fail( "Wrong packaging of parent POM was not rejected" );
}
catch ( ProjectBuildingException e )
{
// expected
}
}
private void assertPathSuffixEquals( String expected, Object actual )
{
String a = actual.toString();
@ -1649,7 +1663,7 @@ public class PomConstructionTest
}
private PomTestWrapper buildPom( String pomPath, String... profileIds )
throws Exception
throws ProjectBuildingException
{
return buildPom( pomPath, null, profileIds );
}

View File

@ -0,0 +1,35 @@
<?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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng4283</groupId>
<artifactId>parent</artifactId>
<version>0.1</version>
<!-- NOTE: Any packaging other than "pom" must be rejected for a parent POM -->
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4283</name>
<description>
Test that the model builder fails when a parent POM has not "pom" packaging.
</description>
</project>

View File

@ -0,0 +1,40 @@
<?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>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.its.mng4283</groupId>
<artifactId>parent</artifactId>
<version>0.1</version>
</parent>
<groupId>org.apache.maven.its.mng4283</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4283</name>
<description>
Test that the model builder fails when a parent POM has not "pom" packaging.
</description>
</project>

View File

@ -408,6 +408,14 @@ public class DefaultModelBuilder
}
}
}
Model parentModel = parentData.getModel();
if ( !"pom".equals( parentModel.getPackaging() ) )
{
problems.addError( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel )
+ ", must be \"pom\" but is \"" + parentModel.getPackaging() + "\"" );
}
}
else
{