mirror of https://github.com/apache/maven.git
o Fixed handling of missing project artifact id
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@934440 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7e5e5eb1da
commit
41eb59fdd1
|
@ -1089,14 +1089,15 @@ public class PomConstructionTest
|
||||||
assertEquals(1, ( (Properties) pom.getValue( "properties" ) ).size());
|
assertEquals(1, ( (Properties) pom.getValue( "properties" ) ).size());
|
||||||
assertEquals("child", pom.getValue( "properties/pomProfile" ) );
|
assertEquals("child", pom.getValue( "properties/pomProfile" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPomInheritance()
|
public void testPomInheritance()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
PomTestWrapper pom = buildPom( "pom-inheritance/sub" );
|
PomTestWrapper pom = buildPom( "pom-inheritance/sub" );
|
||||||
assertEquals("parent-description", pom.getValue("description"));
|
assertEquals( "parent-description", pom.getValue( "description" ) );
|
||||||
}
|
assertEquals( "jar", pom.getValue( "packaging" ) );
|
||||||
|
}
|
||||||
|
|
||||||
public void testCompleteModelWithoutParent()
|
public void testCompleteModelWithoutParent()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -1756,6 +1757,20 @@ public class PomConstructionTest
|
||||||
assertEquals( actual, expected );
|
assertEquals( actual, expected );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testProjectArtifactIdIsNotInheritedButMandatory()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
buildPom( "artifact-id-inheritance/child" );
|
||||||
|
fail( "Missing artifactId did not cause validation error" );
|
||||||
|
}
|
||||||
|
catch ( ProjectBuildingException e )
|
||||||
|
{
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void assertPathSuffixEquals( String expected, Object actual )
|
private void assertPathSuffixEquals( String expected, Object actual )
|
||||||
{
|
{
|
||||||
String a = actual.toString();
|
String a = actual.toString();
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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.mng</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<!-- while groupId and version are inherited, artifactId is not and must be specified -->
|
||||||
|
</project>
|
|
@ -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.mng</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
NOTE: This extends the test to check an edge case of URL adjustment which must not error out during inheritance
|
||||||
|
if the child misses the artifactId (as to be reported by validation).
|
||||||
|
-->
|
||||||
|
<url>http://maven.apache.org/</url>
|
||||||
|
</project>
|
|
@ -101,8 +101,7 @@ public class MavenModelMerger
|
||||||
}
|
}
|
||||||
else if ( target.getUrl() == null )
|
else if ( target.getUrl() == null )
|
||||||
{
|
{
|
||||||
target.setUrl( appendPath( src, context.get( ARTIFACT_ID ).toString(),
|
target.setUrl( appendPath( src, context ) );
|
||||||
context.get( CHILD_PATH_ADJUSTMENT ).toString() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,6 +167,12 @@ public class MavenModelMerger
|
||||||
// neither inherited nor injected
|
// neither inherited nor injected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mergeModel_ArtifactId( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
|
||||||
|
{
|
||||||
|
// neither inherited nor injected
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mergeModel_Profiles( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
|
protected void mergeModel_Profiles( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
|
||||||
{
|
{
|
||||||
|
@ -396,8 +401,7 @@ public class MavenModelMerger
|
||||||
}
|
}
|
||||||
else if ( target.getUrl() == null )
|
else if ( target.getUrl() == null )
|
||||||
{
|
{
|
||||||
target.setUrl( appendPath( src, context.get( ARTIFACT_ID ).toString(),
|
target.setUrl( appendPath( src, context ) );
|
||||||
context.get( CHILD_PATH_ADJUSTMENT ).toString() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,8 +418,7 @@ public class MavenModelMerger
|
||||||
}
|
}
|
||||||
else if ( target.getUrl() == null )
|
else if ( target.getUrl() == null )
|
||||||
{
|
{
|
||||||
target.setUrl( appendPath( src, context.get( ARTIFACT_ID ).toString(),
|
target.setUrl( appendPath( src, context ) );
|
||||||
context.get( CHILD_PATH_ADJUSTMENT ).toString() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,8 +435,7 @@ public class MavenModelMerger
|
||||||
}
|
}
|
||||||
else if ( target.getConnection() == null )
|
else if ( target.getConnection() == null )
|
||||||
{
|
{
|
||||||
target.setConnection( appendPath( src, context.get( ARTIFACT_ID ).toString(),
|
target.setConnection( appendPath( src, context ) );
|
||||||
context.get( CHILD_PATH_ADJUSTMENT ).toString() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,8 +453,7 @@ public class MavenModelMerger
|
||||||
}
|
}
|
||||||
else if ( target.getDeveloperConnection() == null )
|
else if ( target.getDeveloperConnection() == null )
|
||||||
{
|
{
|
||||||
target.setDeveloperConnection( appendPath( src, context.get( ARTIFACT_ID ).toString(),
|
target.setDeveloperConnection( appendPath( src, context ) );
|
||||||
context.get( CHILD_PATH_ADJUSTMENT ).toString() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,6 +557,21 @@ public class MavenModelMerger
|
||||||
return object.getGroupId() + ':' + object.getArtifactId();
|
return object.getGroupId() + ':' + object.getArtifactId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String appendPath( String parentPath, Map<Object, Object> context )
|
||||||
|
{
|
||||||
|
Object artifactId = context.get( ARTIFACT_ID );
|
||||||
|
Object childPathAdjustment = context.get( CHILD_PATH_ADJUSTMENT );
|
||||||
|
|
||||||
|
if ( artifactId != null && childPathAdjustment != null )
|
||||||
|
{
|
||||||
|
return appendPath( parentPath, artifactId.toString(), childPathAdjustment.toString() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return parentPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String appendPath( String parentPath, String childPath, String pathAdjustment )
|
private String appendPath( String parentPath, String childPath, String pathAdjustment )
|
||||||
{
|
{
|
||||||
String path = parentPath;
|
String path = parentPath;
|
||||||
|
|
Loading…
Reference in New Issue