(Merged from 384102.) Fixing site URL calculation to disregard child module path adjustment.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@384105 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2006-03-08 03:09:44 +00:00
parent 4cbcd0edd5
commit fcb42e22ba
11 changed files with 188 additions and 8 deletions

View File

@ -2,7 +2,7 @@
<files>
<file>
<location>target/effective-pom.xml</location>
<contains>scp://host/path/sub1</contains>
<contains>scp://host/path/parent/sub1</contains>
</file>
<file>
<location>target/effective-pom.xml</location>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it1020</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>maven-core-it1020-child</artifactId>
<dependencies>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,9 @@
package org.apache.maven.it1019;
import org.jaxen.Context;
public class TestClass
{
private Context context;
}

1
maven-core-it/it1020/goals.txt Executable file
View File

@ -0,0 +1 @@
compile

42
maven-core-it/it1020/pom.xml Executable file
View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it1020</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>child</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1-beta-2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<exclusions>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.0.5</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

1
maven-core-it/it1021/goals.txt Executable file
View File

@ -0,0 +1 @@
compile

35
maven-core-it/it1021/pom.xml Executable file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it1019</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1-beta-2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<exclusions>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.0.5</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,9 @@
package org.apache.maven.it1019;
import org.jaxen.Context;
public class TestClass
{
private Context context;
}

View File

@ -336,6 +336,8 @@ public class MavenMetadataSource
artifact.setFile( new File( d.getSystemPath() ) );
}
ArtifactFilter artifactFilter = dependencyFilter;
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
{
if ( d.getExclusions() != null && !d.getExclusions().isEmpty() )
@ -354,15 +356,15 @@ public class MavenMetadataSource
AndArtifactFilter filter = new AndArtifactFilter();
filter.add( dependencyFilter );
filter.add( newFilter );
dependencyFilter = filter;
artifactFilter = filter;
}
else
{
dependencyFilter = newFilter;
artifactFilter = newFilter;
}
}
artifact.setDependencyFilter( dependencyFilter );
artifact.setDependencyFilter( artifactFilter );
if ( project != null )
{

View File

@ -108,7 +108,7 @@ public class DefaultModelInheritanceAssembler
}
}
assembleDistributionInheritence( child, parent, childPathAdjustment, appendPaths );
assembleDistributionInheritence( child, parent, appendPaths );
// issueManagement
if ( child.getIssueManagement() == null )
@ -399,8 +399,7 @@ public class DefaultModelInheritanceAssembler
}
}
private void assembleDistributionInheritence( Model child, Model parent, String childPathAdjustment,
boolean appendPaths )
private void assembleDistributionInheritence( Model child, Model parent, boolean appendPaths )
{
if ( parent.getDistributionManagement() != null )
{
@ -432,7 +431,7 @@ public class DefaultModelInheritanceAssembler
if ( site.getUrl() != null )
{
site.setUrl(
appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
appendPath( site.getUrl(), child.getArtifactId(), null, appendPaths ) );
}
}
}

View File

@ -10,6 +10,7 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.injection.ModelDefaultsInjector;
import org.codehaus.plexus.PlexusTestCase;
import java.util.Arrays;
import java.util.Map;
public class MavenMetadataSourceTest
@ -107,4 +108,55 @@ public class MavenMetadataSourceTest
assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_TEST, dep.getScope() );
}
public void testExcludeDoesNotAffectAllDependencies()
throws Exception
{
String groupId = "org.apache.maven";
String artifactId = "maven-model";
String version = "1.0";
Dependency dep1 = new Dependency();
dep1.setGroupId( groupId );
dep1.setArtifactId( artifactId + "1" );
dep1.setVersion( version );
dep1.setExclusions( Arrays.asList( new String[] { "exclude1:exclude1" } ) );
Model model = new Model();
model.addDependency( dep1 );
Dependency dep2 = new Dependency();
dep2.setGroupId( groupId );
dep2.setArtifactId( artifactId + "2" );
dep1.setVersion( version );
model.addDependency( dep2 );
MavenProject project = new MavenProject( model );
ModelDefaultsInjector injector = (ModelDefaultsInjector) lookup( ModelDefaultsInjector.ROLE );
injector.injectDefaults( model );
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
project.setArtifacts( project.createArtifacts( factory, null, null ) );
String key = ArtifactUtils.versionlessKey( groupId, artifactId );
Map artifactMap = project.getArtifactMap();
assertNotNull( "artifact-map should not be null.", artifactMap );
assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() );
Artifact artifact = (Artifact) artifactMap.get( key );
assertNotNull( "dependency artifact not found in map.", artifact );
assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_TEST, artifact.getScope() );
//check for back-propagation of default scope.
assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_TEST, dep1.getScope() );
}
}