mirror of https://github.com/apache/maven.git
Fixing a few problems with the model-lineage builder, where it was stubbing models inappropriately and other minor logical problems.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@564761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1d58a421ce
commit
c5a74a8242
|
@ -330,7 +330,7 @@ public class DefaultBuildExtensionScanner
|
||||||
getLogger().debug( "Building model-lineage for: " + pom + " to pre-scan for extensions." );
|
getLogger().debug( "Building model-lineage for: " + pom + " to pre-scan for extensions." );
|
||||||
|
|
||||||
lineage = modelLineageBuilder.buildModelLineage( pom, localRepository, originalRemoteRepositories,
|
lineage = modelLineageBuilder.buildModelLineage( pom, localRepository, originalRemoteRepositories,
|
||||||
globalProfileManager );
|
globalProfileManager, false );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -754,11 +754,11 @@ public class DefaultMavenProjectBuilder
|
||||||
getLogger().debug( "Cannot determine whether " + currentProject.getId() + " is a module of " + previousProject.getId() + ". Reason: " + e.getMessage(), e );
|
getLogger().debug( "Cannot determine whether " + currentProject.getId() + " is a module of " + previousProject.getId() + ". Reason: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().debug( "[buildInternal] Assembling model-inheritance: child=" + current.getId() + ", parent=" + previous.getId() );
|
getLogger().debug( "[buildInternal] Assembling model-inheritance: child=" + current.getId() + " has distributionManagement? " + ( current.getDistributionManagement() != null ) + ", parent=" + previous.getId() + " has distributionManagement? " + ( previous.getDistributionManagement() != null ) );
|
||||||
|
|
||||||
modelInheritanceAssembler.assembleModelInheritance( current, previous, pathAdjustment );
|
modelInheritanceAssembler.assembleModelInheritance( current, previous, pathAdjustment );
|
||||||
|
|
||||||
getLogger().debug( "[buildInternal] Assembled model-inheritance for child=" + current.getId() );
|
getLogger().debug( "[buildInternal] Assembled model-inheritance for child=" + current.getId() + " (has distributionManagement? " + ( current.getDistributionManagement() != null ) + ")" );
|
||||||
|
|
||||||
previous = current;
|
previous = current;
|
||||||
previousProject = currentProject;
|
previousProject = currentProject;
|
||||||
|
@ -1054,7 +1054,8 @@ public class DefaultMavenProjectBuilder
|
||||||
ModelLineage modelLineage = new DefaultModelLineage();
|
ModelLineage modelLineage = new DefaultModelLineage();
|
||||||
modelLineage.setOrigin( model, new File( projectDir, "pom.xml" ), new ArrayList( aggregatedRemoteWagonRepositories ) );
|
modelLineage.setOrigin( model, new File( projectDir, "pom.xml" ), new ArrayList( aggregatedRemoteWagonRepositories ) );
|
||||||
|
|
||||||
modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager );
|
// strict means "no stubs", so we invert it here for the allowStubs parameter.
|
||||||
|
modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager, !strict );
|
||||||
|
|
||||||
ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
|
ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
|
||||||
|
|
||||||
|
@ -1080,8 +1081,6 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
Model currentModel = (Model) it.next();
|
Model currentModel = (Model) it.next();
|
||||||
|
|
||||||
getLogger().debug( "[assembleLineage] Assembling MavenProject instance for: " + currentModel.getId() );
|
|
||||||
|
|
||||||
File currentPom = it.getPOMFile();
|
File currentPom = it.getPOMFile();
|
||||||
|
|
||||||
MavenProject project = new MavenProject( currentModel );
|
MavenProject project = new MavenProject( currentModel );
|
||||||
|
|
|
@ -228,7 +228,7 @@ public class DefaultModelLineage
|
||||||
return tuple.file;
|
return tuple.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDeepestArtifactRepositoryList()
|
public List getDeepestAncestorArtifactRepositoryList()
|
||||||
{
|
{
|
||||||
if ( tuples.isEmpty() )
|
if ( tuples.isEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -240,7 +240,7 @@ public class DefaultModelLineage
|
||||||
return tuple.remoteRepositories;
|
return tuple.remoteRepositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDeepestFile()
|
public File getDeepestAncestorFile()
|
||||||
{
|
{
|
||||||
if ( tuples.isEmpty() )
|
if ( tuples.isEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -252,7 +252,7 @@ public class DefaultModelLineage
|
||||||
return tuple.file;
|
return tuple.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Model getDeepestModel()
|
public Model getDeepestAncestorModel()
|
||||||
{
|
{
|
||||||
if ( tuples.isEmpty() )
|
if ( tuples.isEmpty() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class DefaultModelLineageBuilder
|
||||||
* @see org.apache.maven.project.build.model.ModelLineageBuilder#buildModelLineage(java.io.File, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
|
* @see org.apache.maven.project.build.model.ModelLineageBuilder#buildModelLineage(java.io.File, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
|
||||||
*/
|
*/
|
||||||
public ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
|
public ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
|
||||||
ProfileManager profileManager )
|
ProfileManager profileManager, boolean allowStubs )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
||||||
|
@ -99,7 +99,7 @@ public class DefaultModelLineageBuilder
|
||||||
|
|
||||||
ModelAndFile current = new ModelAndFile( readModel( pom, projectBuildCache ), pom );
|
ModelAndFile current = new ModelAndFile( readModel( pom, projectBuildCache ), pom );
|
||||||
|
|
||||||
while ( current != null )
|
do
|
||||||
{
|
{
|
||||||
if ( lineage.size() == 0 )
|
if ( lineage.size() == 0 )
|
||||||
{
|
{
|
||||||
|
@ -112,44 +112,43 @@ public class DefaultModelLineageBuilder
|
||||||
|
|
||||||
currentRemoteRepositories = updateRepositorySet( current.model, currentRemoteRepositories, current.file, profileManager );
|
currentRemoteRepositories = updateRepositorySet( current.model, currentRemoteRepositories, current.file, profileManager );
|
||||||
|
|
||||||
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache, allowStubs );
|
||||||
}
|
}
|
||||||
|
while ( current != null );
|
||||||
|
|
||||||
return lineage;
|
return lineage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
|
public void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
|
||||||
ProfileManager profileManager )
|
ProfileManager profileManager, boolean allowStubs )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
|
if ( lineage.size() == 0 )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( "unknown", "Cannot resume a ModelLineage that doesn't contain at least one Model instance." );
|
||||||
|
}
|
||||||
|
|
||||||
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
|
||||||
|
|
||||||
List currentRemoteRepositories = lineage.getDeepestArtifactRepositoryList();
|
List currentRemoteRepositories = lineage.getDeepestAncestorArtifactRepositoryList();
|
||||||
|
|
||||||
if ( currentRemoteRepositories == null )
|
if ( currentRemoteRepositories == null )
|
||||||
{
|
{
|
||||||
currentRemoteRepositories = new ArrayList();
|
currentRemoteRepositories = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelAndFile current = new ModelAndFile( lineage.getDeepestModel(), lineage.getDeepestFile() );
|
ModelAndFile current = new ModelAndFile( lineage.getDeepestAncestorModel(), lineage.getDeepestAncestorFile() );
|
||||||
|
|
||||||
// use the above information to re-bootstrap the resolution chain...
|
// use the above information to re-bootstrap the resolution chain...
|
||||||
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache, allowStubs );
|
||||||
|
|
||||||
while ( current != null )
|
while ( current != null )
|
||||||
{
|
|
||||||
if ( lineage.size() == 0 )
|
|
||||||
{
|
|
||||||
lineage.setOrigin( current.model, current.file, currentRemoteRepositories );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
lineage.addParent( current.model, current.file, currentRemoteRepositories );
|
lineage.addParent( current.model, current.file, currentRemoteRepositories );
|
||||||
}
|
|
||||||
|
|
||||||
currentRemoteRepositories = updateRepositorySet( current.model, currentRemoteRepositories, current.file, profileManager );
|
currentRemoteRepositories = updateRepositorySet( current.model, currentRemoteRepositories, current.file, profileManager );
|
||||||
|
|
||||||
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache );
|
current = resolveParentPom( current, currentRemoteRepositories, localRepository, projectBuildCache, allowStubs );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,9 +289,10 @@ public class DefaultModelLineageBuilder
|
||||||
* Pull the parent specification out of the given model, construct an Artifact instance, and
|
* Pull the parent specification out of the given model, construct an Artifact instance, and
|
||||||
* resolve that artifact...then, return the resolved POM file for the parent.
|
* resolve that artifact...then, return the resolved POM file for the parent.
|
||||||
* @param projectBuildCache
|
* @param projectBuildCache
|
||||||
|
* @param allowStubs
|
||||||
*/
|
*/
|
||||||
private ModelAndFile resolveParentPom( ModelAndFile child, List remoteRepositories, ArtifactRepository localRepository,
|
private ModelAndFile resolveParentPom( ModelAndFile child, List remoteRepositories, ArtifactRepository localRepository,
|
||||||
ProjectBuildCache projectBuildCache )
|
ProjectBuildCache projectBuildCache, boolean allowStubs )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
Model model = child.model;
|
Model model = child.model;
|
||||||
|
@ -306,8 +306,6 @@ public class DefaultModelLineageBuilder
|
||||||
{
|
{
|
||||||
validateParentDeclaration( modelParent, model );
|
validateParentDeclaration( modelParent, model );
|
||||||
|
|
||||||
// getLogger().debug( "Looking for cached parent POM under: " + cacheKey );
|
|
||||||
|
|
||||||
File parentPomFile = projectBuildCache.getCachedModelFile( modelParent );
|
File parentPomFile = projectBuildCache.getCachedModelFile( modelParent );
|
||||||
|
|
||||||
if ( parentPomFile == null )
|
if ( parentPomFile == null )
|
||||||
|
@ -316,28 +314,50 @@ public class DefaultModelLineageBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( parentPomFile == null )
|
if ( parentPomFile == null )
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
parentPomFile = resolveParentFromRepositories( modelParent, localRepository, remoteRepositories, modelPomFile );
|
parentPomFile = resolveParentFromRepositories( modelParent, localRepository, remoteRepositories, modelPomFile );
|
||||||
}
|
}
|
||||||
|
catch( ProjectBuildingException e )
|
||||||
|
{
|
||||||
|
if ( allowStubs )
|
||||||
|
{
|
||||||
|
getLogger().debug( "DISREGARDING the error encountered while resolving artifact for: " + modelParent.getId() + ", building a stub model in its place.", e );
|
||||||
|
parentPomFile = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Model parent;
|
|
||||||
if ( parentPomFile == null )
|
if ( parentPomFile == null )
|
||||||
|
{
|
||||||
|
if ( allowStubs )
|
||||||
{
|
{
|
||||||
getLogger().warn( "Cannot find parent POM: " + modelParent.getId() + " for child: " + model.getId() + ". Using stub model instead." );
|
getLogger().warn( "Cannot find parent POM: " + modelParent.getId() + " for child: " + model.getId() + ". Using stub model instead." );
|
||||||
|
|
||||||
parent = new Model();
|
Model parent = new Model();
|
||||||
|
|
||||||
parent.setGroupId( modelParent.getGroupId() );
|
parent.setGroupId( modelParent.getGroupId() );
|
||||||
parent.setArtifactId( modelParent.getArtifactId() );
|
parent.setArtifactId( modelParent.getArtifactId() );
|
||||||
parent.setVersion( modelParent.getVersion() );
|
parent.setVersion( modelParent.getVersion() );
|
||||||
|
|
||||||
|
result = new ModelAndFile( parent, parentPomFile );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parent = readModel( parentPomFile );
|
getLogger().error( "Cannot find parent POM: " + modelParent.getId() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Model parent = readModel( parentPomFile );
|
||||||
result = new ModelAndFile( parent, parentPomFile );
|
result = new ModelAndFile( parent, parentPomFile );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,19 +39,19 @@ public interface ModelLineage
|
||||||
* Retrieve the Model instance for the deepest ancestor which has been resolved so far in this
|
* Retrieve the Model instance for the deepest ancestor which has been resolved so far in this
|
||||||
* lineage.
|
* lineage.
|
||||||
*/
|
*/
|
||||||
Model getDeepestModel();
|
Model getDeepestAncestorModel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the POM file for the deepest ancestor which has been resolved so far in this
|
* Retrieve the POM file for the deepest ancestor which has been resolved so far in this
|
||||||
* lineage.
|
* lineage.
|
||||||
*/
|
*/
|
||||||
File getDeepestFile();
|
File getDeepestAncestorFile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the remote-repository list for the deepest ancestor which has been resolved so far
|
* Retrieve the remote-repository list for the deepest ancestor which has been resolved so far
|
||||||
* in this lineage.
|
* in this lineage.
|
||||||
*/
|
*/
|
||||||
List getDeepestArtifactRepositoryList();
|
List getDeepestAncestorArtifactRepositoryList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the Model instance for the POM from which this lineage was constructed. This is the
|
* Retrieve the Model instance for the POM from which this lineage was constructed. This is the
|
||||||
|
|
|
@ -50,9 +50,11 @@ public interface ModelLineageBuilder
|
||||||
* should be resolved
|
* should be resolved
|
||||||
* @param profileManager The profile manager containing information about global profiles to be
|
* @param profileManager The profile manager containing information about global profiles to be
|
||||||
* applied (from settings.xml, for instance)
|
* applied (from settings.xml, for instance)
|
||||||
|
* @param allowStubs Whether stubbed-out Model instances should be constructed in the event that
|
||||||
|
* a parent-POM cannot be resolved.
|
||||||
*/
|
*/
|
||||||
ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
|
ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
|
||||||
ProfileManager profileManager )
|
ProfileManager profileManager, boolean allowStubs )
|
||||||
throws ProjectBuildingException;
|
throws ProjectBuildingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,9 +65,11 @@ public interface ModelLineageBuilder
|
||||||
* @param localRepository The local repository against which parent POMs should be resolved
|
* @param localRepository The local repository against which parent POMs should be resolved
|
||||||
* @param profileManager The profile manager containing information about global profiles to be
|
* @param profileManager The profile manager containing information about global profiles to be
|
||||||
* applied (from settings.xml, for instance)
|
* applied (from settings.xml, for instance)
|
||||||
|
* @param allowStubs Whether stubbed-out Model instances should be constructed in the event that
|
||||||
|
* a parent-POM cannot be resolved.
|
||||||
*/
|
*/
|
||||||
void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
|
void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
|
||||||
ProfileManager profileManager )
|
ProfileManager profileManager, boolean allowStubs )
|
||||||
throws ProjectBuildingException;
|
throws ProjectBuildingException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class DefaultModelLineageBuilderTest
|
||||||
IOUtil.close( writer );
|
IOUtil.close( writer );
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelLineage lineage = modelLineageBuilder.buildModelLineage( pomFile, null, null, null );
|
ModelLineage lineage = modelLineageBuilder.buildModelLineage( pomFile, null, null, null, false );
|
||||||
|
|
||||||
assertEquals( 1, lineage.size() );
|
assertEquals( 1, lineage.size() );
|
||||||
|
|
||||||
|
@ -150,11 +150,13 @@ public class DefaultModelLineageBuilderTest
|
||||||
writeModel( current, currentPOM );
|
writeModel( current, currentPOM );
|
||||||
|
|
||||||
// 7. build the lineage.
|
// 7. build the lineage.
|
||||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local", localRepoDirectory.toURL()
|
ArtifactRepository localRepository = new DefaultArtifactRepository(
|
||||||
.toExternalForm(), defaultLayout );
|
"local",
|
||||||
|
localRepoDirectory.toURL().toExternalForm(),
|
||||||
|
defaultLayout );
|
||||||
|
|
||||||
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
|
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
|
||||||
Collections.EMPTY_LIST, null );
|
Collections.EMPTY_LIST, null, false );
|
||||||
|
|
||||||
assertEquals( 3, lineage.size() );
|
assertEquals( 3, lineage.size() );
|
||||||
|
|
||||||
|
@ -165,6 +167,54 @@ public class DefaultModelLineageBuilderTest
|
||||||
assertEquals( ancestor.getId(), ( (Model) modelIterator.next() ).getId() );
|
assertEquals( ancestor.getId(), ( (Model) modelIterator.next() ).getId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testReadPOMWithMissingParentAndAllowStubsSetToTrue()
|
||||||
|
throws IOException, ProjectBuildingException
|
||||||
|
{
|
||||||
|
// 1. create local repository directory
|
||||||
|
File localRepoDirectory = File.createTempFile( "DefaultModelLineageBuilder.localRepository.", "" );
|
||||||
|
|
||||||
|
localRepoDirectory.delete();
|
||||||
|
localRepoDirectory.mkdirs();
|
||||||
|
|
||||||
|
deleteDirOnExit( localRepoDirectory );
|
||||||
|
|
||||||
|
// 5. create the current pom with a parent-ref on the parent model
|
||||||
|
Model current = createModel( "group", "current", "1" );
|
||||||
|
|
||||||
|
Parent currentParent = new Parent();
|
||||||
|
currentParent.setGroupId( "group" );
|
||||||
|
currentParent.setArtifactId( "parent" );
|
||||||
|
currentParent.setVersion( "1" );
|
||||||
|
|
||||||
|
current.setParent( currentParent );
|
||||||
|
|
||||||
|
// 6. write the current pom somewhere
|
||||||
|
File currentPOM = File.createTempFile( "DefaultModelLineageBuilder.test.", ".pom" );
|
||||||
|
currentPOM.deleteOnExit();
|
||||||
|
|
||||||
|
writeModel( current, currentPOM );
|
||||||
|
|
||||||
|
// 7. build the lineage.
|
||||||
|
ArtifactRepository localRepository = new DefaultArtifactRepository(
|
||||||
|
"local",
|
||||||
|
localRepoDirectory.toURL().toExternalForm(),
|
||||||
|
defaultLayout );
|
||||||
|
|
||||||
|
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
|
||||||
|
Collections.EMPTY_LIST, null, true );
|
||||||
|
|
||||||
|
assertEquals( 2, lineage.size() );
|
||||||
|
|
||||||
|
Iterator modelIterator = lineage.modelIterator();
|
||||||
|
|
||||||
|
assertEquals( current.getId(), ( (Model) modelIterator.next() ).getId() );
|
||||||
|
|
||||||
|
Model parent = (Model) modelIterator.next();
|
||||||
|
assertEquals( currentParent.getGroupId(), parent.getGroupId() );
|
||||||
|
assertEquals( currentParent.getArtifactId(), parent.getArtifactId() );
|
||||||
|
assertEquals( currentParent.getVersion(), parent.getVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
public void testReadPOMWithParentInLocalRepositoryAndAncestorInRemoteRepository()
|
public void testReadPOMWithParentInLocalRepositoryAndAncestorInRemoteRepository()
|
||||||
throws IOException, ProjectBuildingException
|
throws IOException, ProjectBuildingException
|
||||||
{
|
{
|
||||||
|
@ -219,14 +269,19 @@ public class DefaultModelLineageBuilderTest
|
||||||
writeModel( current, currentPOM );
|
writeModel( current, currentPOM );
|
||||||
|
|
||||||
// 7. build the lineage.
|
// 7. build the lineage.
|
||||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local", localRepoDirectory.toURL()
|
ArtifactRepository localRepository = new DefaultArtifactRepository(
|
||||||
.toExternalForm(), defaultLayout );
|
"local",
|
||||||
|
localRepoDirectory.toURL().toExternalForm(),
|
||||||
|
defaultLayout );
|
||||||
|
|
||||||
ArtifactRepository remoteRepository = new DefaultArtifactRepository( "test", remoteRepoDirectory.toURL()
|
ArtifactRepository remoteRepository = new DefaultArtifactRepository( "test",
|
||||||
.toExternalForm(), defaultLayout );
|
remoteRepoDirectory.toURL()
|
||||||
|
.toExternalForm(),
|
||||||
|
defaultLayout );
|
||||||
|
|
||||||
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository, Collections
|
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
|
||||||
.singletonList( remoteRepository ), null );
|
Collections.singletonList( remoteRepository ),
|
||||||
|
null, false );
|
||||||
|
|
||||||
assertEquals( 3, lineage.size() );
|
assertEquals( 3, lineage.size() );
|
||||||
|
|
||||||
|
@ -277,11 +332,13 @@ public class DefaultModelLineageBuilderTest
|
||||||
writeModel( current, currentPOM );
|
writeModel( current, currentPOM );
|
||||||
|
|
||||||
// 7. build the lineage.
|
// 7. build the lineage.
|
||||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local", projectRootDirectory.toURL()
|
ArtifactRepository localRepository = new DefaultArtifactRepository( "local",
|
||||||
.toExternalForm(), defaultLayout );
|
projectRootDirectory.toURL()
|
||||||
|
.toExternalForm(),
|
||||||
|
defaultLayout );
|
||||||
|
|
||||||
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
|
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
|
||||||
Collections.EMPTY_LIST, null );
|
Collections.EMPTY_LIST, null, false );
|
||||||
|
|
||||||
assertEquals( 2, lineage.size() );
|
assertEquals( 2, lineage.size() );
|
||||||
|
|
||||||
|
@ -366,8 +423,8 @@ public class DefaultModelLineageBuilderTest
|
||||||
writeModel( current, currentPOM );
|
writeModel( current, currentPOM );
|
||||||
|
|
||||||
// 7. build the lineage.
|
// 7. build the lineage.
|
||||||
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, null, Collections
|
ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, null, Collections.EMPTY_LIST, null,
|
||||||
.EMPTY_LIST, null );
|
false );
|
||||||
|
|
||||||
assertEquals( 2, lineage.size() );
|
assertEquals( 2, lineage.size() );
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,62 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
childDistMgmt.getSnapshotRepository().isUniqueVersion() );
|
childDistMgmt.getSnapshotRepository().isUniqueVersion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testThreeLevelDistributionManagementInheritance()
|
||||||
|
{
|
||||||
|
Model gpar = makeBaseModel( "gpar" );
|
||||||
|
Model parent = makeBaseModel( "parent" );
|
||||||
|
Model child = makeBaseModel( "child" );
|
||||||
|
|
||||||
|
DistributionManagement distributionManagement = new DistributionManagement();
|
||||||
|
distributionManagement.setDownloadUrl( "downloadUrl" );
|
||||||
|
distributionManagement.setRelocation( new Relocation() );
|
||||||
|
distributionManagement.setStatus( "deployed" );
|
||||||
|
|
||||||
|
DeploymentRepository repository = new DeploymentRepository();
|
||||||
|
repository.setId( "apache.releases" );
|
||||||
|
repository.setUrl( "scp://minotaur.apache.org/www/www.apache.org/dist/java-repository" );
|
||||||
|
repository.setName( "name" );
|
||||||
|
repository.setLayout( "legacy" );
|
||||||
|
distributionManagement.setRepository( repository );
|
||||||
|
|
||||||
|
DeploymentRepository snapshotRepository = new DeploymentRepository();
|
||||||
|
snapshotRepository.setId( "apache.snapshots" );
|
||||||
|
snapshotRepository.setUrl( "scp://minotaur.apache.org/www/cvs.apache.org/repository" );
|
||||||
|
snapshotRepository.setName( "name" );
|
||||||
|
snapshotRepository.setLayout( "legacy" );
|
||||||
|
snapshotRepository.setUniqueVersion( false );
|
||||||
|
distributionManagement.setSnapshotRepository( snapshotRepository );
|
||||||
|
|
||||||
|
Site site = new Site();
|
||||||
|
site.setId( "apache.website" );
|
||||||
|
site.setUrl( "scp://minotaur.apache.org/www/maven.apache.org/" );
|
||||||
|
site.setName( "name3" );
|
||||||
|
distributionManagement.setSite( site );
|
||||||
|
|
||||||
|
gpar.setDistributionManagement( distributionManagement );
|
||||||
|
|
||||||
|
assembler.assembleModelInheritance( parent, gpar );
|
||||||
|
assembler.assembleModelInheritance( child, parent );
|
||||||
|
|
||||||
|
DistributionManagement childDistMgmt = child.getDistributionManagement();
|
||||||
|
assertNotNull( "Check distMgmt inherited", childDistMgmt );
|
||||||
|
assertNull( "Check status NOT inherited", childDistMgmt.getStatus() );
|
||||||
|
assertNull( "Check relocation NOT inherited", childDistMgmt.getRelocation() );
|
||||||
|
assertEquals( "Check downloadUrl inherited", distributionManagement.getDownloadUrl(),
|
||||||
|
childDistMgmt.getDownloadUrl() );
|
||||||
|
|
||||||
|
Site childSite = childDistMgmt.getSite();
|
||||||
|
assertNotNull( "Check site inherited", childSite );
|
||||||
|
assertEquals( "Check id matches", site.getId(), childSite.getId() );
|
||||||
|
assertEquals( "Check name matches", site.getName(), childSite.getName() );
|
||||||
|
assertEquals( "Check url matches with appended path", site.getUrl() + "parent/child", childSite.getUrl() );
|
||||||
|
|
||||||
|
assertRepositoryBase( childDistMgmt.getRepository(), repository );
|
||||||
|
assertRepositoryBase( childDistMgmt.getSnapshotRepository(), snapshotRepository );
|
||||||
|
assertEquals( "Check uniqueVersion is inherited", snapshotRepository.isUniqueVersion(),
|
||||||
|
childDistMgmt.getSnapshotRepository().isUniqueVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
private static void assertRepositoryBase( RepositoryBase childRepository, RepositoryBase repository )
|
private static void assertRepositoryBase( RepositoryBase childRepository, RepositoryBase repository )
|
||||||
{
|
{
|
||||||
assertNotNull( "Check repository inherited", childRepository );
|
assertNotNull( "Check repository inherited", childRepository );
|
||||||
|
@ -590,7 +646,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
{
|
{
|
||||||
Build childBuild = child.getBuild();
|
Build childBuild = child.getBuild();
|
||||||
|
|
||||||
if ( expectedPlugins != null && !expectedPlugins.isEmpty() )
|
if ( ( expectedPlugins != null ) && !expectedPlugins.isEmpty() )
|
||||||
{
|
{
|
||||||
assertNotNull( childBuild );
|
assertNotNull( childBuild );
|
||||||
|
|
||||||
|
@ -616,7 +672,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue( childBuild == null || childBuild.getPlugins() == null || childBuild.getPlugins().isEmpty() );
|
assertTrue( ( childBuild == null ) || ( childBuild.getPlugins() == null ) || childBuild.getPlugins().isEmpty() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,9 +684,9 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
List referenceExecutions = reference.getExecutions();
|
List referenceExecutions = reference.getExecutions();
|
||||||
Map testExecutionsMap = test.getExecutionsAsMap();
|
Map testExecutionsMap = test.getExecutionsAsMap();
|
||||||
|
|
||||||
if ( referenceExecutions != null && !referenceExecutions.isEmpty() )
|
if ( ( referenceExecutions != null ) && !referenceExecutions.isEmpty() )
|
||||||
{
|
{
|
||||||
assertTrue( "Missing goals specification", ( testExecutionsMap != null && !testExecutionsMap.isEmpty() ) );
|
assertTrue( "Missing goals specification", ( ( testExecutionsMap != null ) && !testExecutionsMap.isEmpty() ) );
|
||||||
|
|
||||||
for ( Iterator it = referenceExecutions.iterator(); it.hasNext(); )
|
for ( Iterator it = referenceExecutions.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -648,7 +704,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue( "Unexpected goals specification",
|
assertTrue( "Unexpected goals specification",
|
||||||
( testExecutionsMap == null || testExecutionsMap.isEmpty() ) );
|
( ( testExecutionsMap == null ) || testExecutionsMap.isEmpty() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +806,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
{
|
{
|
||||||
Reporting childBuild = child.getReporting();
|
Reporting childBuild = child.getReporting();
|
||||||
|
|
||||||
if ( expectedPlugins != null && !expectedPlugins.isEmpty() )
|
if ( ( expectedPlugins != null ) && !expectedPlugins.isEmpty() )
|
||||||
{
|
{
|
||||||
assertNotNull( childBuild );
|
assertNotNull( childBuild );
|
||||||
|
|
||||||
|
@ -776,7 +832,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue( childBuild == null || childBuild.getPlugins() == null || childBuild.getPlugins().isEmpty() );
|
assertTrue( ( childBuild == null ) || ( childBuild.getPlugins() == null ) || childBuild.getPlugins().isEmpty() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,9 +844,9 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
List referenceReportSets = reference.getReportSets();
|
List referenceReportSets = reference.getReportSets();
|
||||||
Map testReportSetsMap = test.getReportSetsAsMap();
|
Map testReportSetsMap = test.getReportSetsAsMap();
|
||||||
|
|
||||||
if ( referenceReportSets != null && !referenceReportSets.isEmpty() )
|
if ( ( referenceReportSets != null ) && !referenceReportSets.isEmpty() )
|
||||||
{
|
{
|
||||||
assertTrue( "Missing goals specification", ( testReportSetsMap != null && !testReportSetsMap.isEmpty() ) );
|
assertTrue( "Missing goals specification", ( ( testReportSetsMap != null ) && !testReportSetsMap.isEmpty() ) );
|
||||||
|
|
||||||
for ( Iterator it = referenceReportSets.iterator(); it.hasNext(); )
|
for ( Iterator it = referenceReportSets.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -808,7 +864,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue( "Unexpected goals specification",
|
assertTrue( "Unexpected goals specification",
|
||||||
( testReportSetsMap == null || testReportSetsMap.isEmpty() ) );
|
( ( testReportSetsMap == null ) || testReportSetsMap.isEmpty() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,7 +907,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
{
|
{
|
||||||
Model model = makeBaseModel( artifactId );
|
Model model = makeBaseModel( artifactId );
|
||||||
|
|
||||||
if ( connection != null || developerConnection != null || url != null )
|
if ( ( connection != null ) || ( developerConnection != null ) || ( url != null ) )
|
||||||
{
|
{
|
||||||
Scm scm = new Scm();
|
Scm scm = new Scm();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue