mirror of https://github.com/apache/maven.git
Fixing super-pom building to allow injection of external profiles (again). Also, removing use of pluginRepositories and improving error reporting just a tad.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@599658 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0d6bdba6d5
commit
b310a40d6b
|
@ -4,6 +4,7 @@ import org.apache.maven.project.build.model.DefaultModelLineageBuilder;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.model.Parent;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -16,18 +17,21 @@ public privileged aspect ProjectArtifactErrorReporterAspect
|
|||
private pointcut mlbldr_resolveParentFromRepositories( Parent parentRef, ArtifactRepository localRepo,
|
||||
List remoteRepos, String childId, File childPomFile ):
|
||||
execution( File DefaultModelLineageBuilder.resolveParentFromRepository( Parent, ArtifactRepository, List, String, File ) )
|
||||
&& within( DefaultModelLineageBuilder )
|
||||
&& args( parentRef, localRepo, remoteRepos, childId, childPomFile )
|
||||
&& notWithinAspect();
|
||||
|
||||
private pointcut anfe_handler( ArtifactNotFoundException cause ):
|
||||
handler( ArtifactNotFoundException )
|
||||
&& args( cause )
|
||||
&& notWithinAspect();
|
||||
private pointcut mlbldr_parentArtifactNotFound( Parent parentRef, ArtifactRepository localRepo, List remoteRepos, String childId, File childPomFile, ArtifactNotFoundException cause ):
|
||||
cflow( mlbldr_resolveParentFromRepositories( parentRef, localRepo, remoteRepos, childId, childPomFile ) )
|
||||
&& !cflowbelow( mlbldr_resolveParentFromRepositories( Parent, ArtifactRepository, List, String, File ) )
|
||||
&& call( ProjectBuildingException.new( .., ArtifactNotFoundException ) )
|
||||
&& args( .., cause );
|
||||
|
||||
private pointcut are_handler( ArtifactResolutionException cause ):
|
||||
handler( ArtifactResolutionException )
|
||||
&& args( cause )
|
||||
&& notWithinAspect();
|
||||
private pointcut mlbldr_parentArtifactUnresolvable( Parent parentRef, ArtifactRepository localRepo, List remoteRepos, String childId, File childPomFile, ArtifactResolutionException cause ):
|
||||
cflow( mlbldr_resolveParentFromRepositories( parentRef, localRepo, remoteRepos, childId, childPomFile ) )
|
||||
&& !cflowbelow( mlbldr_resolveParentFromRepositories( Parent, ArtifactRepository, List, String, File ) )
|
||||
&& call( ProjectBuildingException.new( .., ArtifactResolutionException ) )
|
||||
&& args( .., cause );
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
|
@ -40,8 +44,7 @@ public privileged aspect ProjectArtifactErrorReporterAspect
|
|||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( Parent parentRef, ArtifactRepository localRepo, List remoteRepos, String childId, File childPomFile, ArtifactNotFoundException cause ):
|
||||
cflow( mlbldr_resolveParentFromRepositories( parentRef, localRepo, remoteRepos, childId, childPomFile ) )
|
||||
&& anfe_handler( cause )
|
||||
mlbldr_parentArtifactNotFound( parentRef, localRepo, remoteRepos, childId, childPomFile, cause )
|
||||
{
|
||||
getReporter().reportParentPomArtifactNotFound( parentRef, localRepo, remoteRepos, childId, childPomFile, cause );
|
||||
}
|
||||
|
@ -57,8 +60,7 @@ public privileged aspect ProjectArtifactErrorReporterAspect
|
|||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( Parent parentRef, ArtifactRepository localRepo, List remoteRepos, String childId, File childPomFile, ArtifactResolutionException cause ):
|
||||
cflow( mlbldr_resolveParentFromRepositories( parentRef, localRepo, remoteRepos, childId, childPomFile ) )
|
||||
&& are_handler( cause )
|
||||
mlbldr_parentArtifactUnresolvable( parentRef, localRepo, remoteRepos, childId, childPomFile, cause )
|
||||
{
|
||||
getReporter().reportParentPomArtifactUnresolvable( parentRef, localRepo, remoteRepos, childId, childPomFile, cause );
|
||||
}
|
||||
|
|
|
@ -71,8 +71,8 @@ public class DefaultProfileInjector
|
|||
injectModules( profile, model );
|
||||
|
||||
model.setRepositories( ModelUtils.mergeRepositoryLists( profile.getRepositories(), model.getRepositories() ) );
|
||||
model.setPluginRepositories( ModelUtils.mergeRepositoryLists( profile.getPluginRepositories(), model
|
||||
.getPluginRepositories() ) );
|
||||
// model.setPluginRepositories( ModelUtils.mergeRepositoryLists( profile.getPluginRepositories(), model
|
||||
// .getPluginRepositories() ) );
|
||||
|
||||
injectReporting( profile, model );
|
||||
|
||||
|
|
|
@ -201,18 +201,19 @@ public class DefaultMavenProjectBuilder
|
|||
false, false, false );
|
||||
}
|
||||
|
||||
private MavenProject superProject;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
// what is using this externally? jvz.
|
||||
public MavenProject buildStandaloneSuperProject()
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( superProject != null )
|
||||
{
|
||||
return superProject;
|
||||
//TODO mkleint - use the (Container, Properties) constructor to make system properties embeddable
|
||||
return buildStandaloneSuperProject( null );
|
||||
}
|
||||
|
||||
public MavenProject buildStandaloneSuperProject( ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Model superModel = getSuperModel();
|
||||
|
||||
superModel.setGroupId( STANDALONE_SUPERPOM_GROUPID );
|
||||
|
@ -221,13 +222,30 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
superModel.setVersion( STANDALONE_SUPERPOM_VERSION );
|
||||
|
||||
superProject = new MavenProject( superModel );
|
||||
List activeProfiles;
|
||||
if ( profileManager != null )
|
||||
{
|
||||
activeProfiles = profileAdvisor.applyActivatedExternalProfiles( superModel, null, profileManager );
|
||||
}
|
||||
else
|
||||
{
|
||||
activeProfiles = Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
MavenProject project = new MavenProject( superModel );
|
||||
|
||||
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
||||
|
||||
project.setManagedVersionMap(
|
||||
createManagedVersionMap( projectId, superModel.getDependencyManagement(), null ) );
|
||||
|
||||
project.setActiveProfiles( activeProfiles );
|
||||
|
||||
try
|
||||
{
|
||||
superProject.setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
||||
project.setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
||||
|
||||
superProject.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
||||
project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
|
@ -239,11 +257,11 @@ public class DefaultMavenProjectBuilder
|
|||
e );
|
||||
}
|
||||
|
||||
superProject.setOriginalModel( superModel );
|
||||
project.setOriginalModel( superModel );
|
||||
|
||||
superProject.setExecutionRoot( true );
|
||||
project.setExecutionRoot( true );
|
||||
|
||||
return superProject;
|
||||
return project;
|
||||
}
|
||||
|
||||
/** @since 2.0.x */
|
||||
|
@ -840,7 +858,7 @@ public class DefaultMavenProjectBuilder
|
|||
project.getVersion(), project.getPackaging() );
|
||||
project.setArtifact( projectArtifact );
|
||||
|
||||
project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( model.getPluginRepositories() ) );
|
||||
// project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( model.getPluginRepositories() ) );
|
||||
|
||||
DistributionManagement dm = model.getDistributionManagement();
|
||||
|
||||
|
@ -1227,9 +1245,16 @@ public class DefaultMavenProjectBuilder
|
|||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private Model superModel;
|
||||
|
||||
private Model getSuperModel()
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( superModel != null )
|
||||
{
|
||||
return superModel;
|
||||
}
|
||||
|
||||
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
|
||||
|
||||
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
||||
|
|
|
@ -22,10 +22,10 @@ package org.apache.maven.project;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||
import org.apache.maven.artifact.versioning.ManagedVersionMap;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.versioning.ManagedVersionMap;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.CiManagement;
|
||||
import org.apache.maven.model.Contributor;
|
||||
|
@ -1329,7 +1329,8 @@ public class MavenProject
|
|||
|
||||
public List getPluginRepositories()
|
||||
{
|
||||
return model.getPluginRepositories();
|
||||
// return model.getPluginRepositories();
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
public void setActiveProfiles( List activeProfiles )
|
||||
|
|
|
@ -91,4 +91,7 @@ public interface MavenProjectBuilder
|
|||
*/
|
||||
MavenProject buildStandaloneSuperProject()
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject buildStandaloneSuperProject( ProfileManager profileManager )
|
||||
throws ProjectBuildingException;
|
||||
}
|
||||
|
|
|
@ -573,7 +573,7 @@ public final class ModelUtils
|
|||
newProfile.setModules( new ArrayList( modules ) );
|
||||
}
|
||||
|
||||
newProfile.setPluginRepositories( cloneProfileRepositories( profile.getPluginRepositories() ) );
|
||||
// newProfile.setPluginRepositories( cloneProfileRepositories( profile.getPluginRepositories() ) );
|
||||
|
||||
Properties props = profile.getProperties();
|
||||
|
||||
|
|
|
@ -654,11 +654,11 @@ public class DefaultProjectErrorReporter
|
|||
writer.write( NEWLINE );
|
||||
if ( pomFile == null )
|
||||
{
|
||||
writer.write( "Error parsing built-in super POM!" );
|
||||
writer.write( "Error reading built-in super POM!" );
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.write( "Error parsing POM." );
|
||||
writer.write( "Error reading POM." );
|
||||
}
|
||||
|
||||
writer.write( NEWLINE );
|
||||
|
@ -682,11 +682,11 @@ public class DefaultProjectErrorReporter
|
|||
writer.write( NEWLINE );
|
||||
if ( parentPomFile == null )
|
||||
{
|
||||
writer.write( "Error parsing built-in super POM!" );
|
||||
writer.write( "Error reading built-in super POM!" );
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.write( "Error parsing parent-POM." );
|
||||
writer.write( "Error reading parent-POM." );
|
||||
}
|
||||
|
||||
writer.write( NEWLINE );
|
||||
|
|
|
@ -170,8 +170,8 @@ public class DefaultModelInheritanceAssembler
|
|||
assembleDependencyInheritance( child, parent );
|
||||
|
||||
child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) );
|
||||
child.setPluginRepositories(
|
||||
ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) );
|
||||
// child.setPluginRepositories(
|
||||
// ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) );
|
||||
|
||||
assembleReportingInheritance( child, parent );
|
||||
|
||||
|
@ -335,13 +335,13 @@ public class DefaultModelInheritanceAssembler
|
|||
ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() );
|
||||
|
||||
List resources = childBuild.getResources();
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
if ( ( resources == null ) || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setResources( parentBuild.getResources() );
|
||||
}
|
||||
|
||||
resources = childBuild.getTestResources();
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
if ( ( resources == null ) || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setTestResources( parentBuild.getTestResources() );
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ public class DefaultModelInheritanceAssembler
|
|||
PluginManagement dominantPM = childBuild.getPluginManagement();
|
||||
PluginManagement recessivePM = parentBuild.getPluginManagement();
|
||||
|
||||
if ( dominantPM == null && recessivePM != null )
|
||||
if ( ( dominantPM == null ) && ( recessivePM != null ) )
|
||||
{
|
||||
childBuild.setPluginManagement( recessivePM );
|
||||
}
|
||||
|
@ -493,11 +493,15 @@ public class DefaultModelInheritanceAssembler
|
|||
if ( appendPaths )
|
||||
{
|
||||
if ( pathAdjustment != null )
|
||||
{
|
||||
uncleanPath += "/" + pathAdjustment;
|
||||
}
|
||||
|
||||
if ( childPath != null )
|
||||
{
|
||||
uncleanPath += "/" + childPath;
|
||||
}
|
||||
}
|
||||
|
||||
String cleanedPath = "";
|
||||
|
||||
|
@ -510,7 +514,9 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
if ( uncleanPath.startsWith( "/" ) )
|
||||
{
|
||||
cleanedPath += "/";
|
||||
}
|
||||
|
||||
return cleanedPath + resolvePath( uncleanPath );
|
||||
}
|
||||
|
@ -524,7 +530,7 @@ public class DefaultModelInheritanceAssembler
|
|||
|
||||
while ( tokenizer.hasMoreTokens() )
|
||||
{
|
||||
String token = (String) tokenizer.nextToken();
|
||||
String token = tokenizer.nextToken();
|
||||
|
||||
if ( token.equals( "" ) )
|
||||
{
|
||||
|
@ -556,8 +562,10 @@ public class DefaultModelInheritanceAssembler
|
|||
{
|
||||
cleanedPath.append( pathElements.removeFirst() );
|
||||
if ( !pathElements.isEmpty() )
|
||||
{
|
||||
cleanedPath.append( '/' );
|
||||
}
|
||||
}
|
||||
|
||||
return cleanedPath.toString();
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ public class DefaultModelValidator
|
|||
|
||||
validateRepositories( result, model.getRepositories(), "repositories.repository" );
|
||||
|
||||
validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" );
|
||||
// validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" );
|
||||
|
||||
forcePluginExecutionIdCollision( model, result );
|
||||
|
||||
|
|
|
@ -19,15 +19,6 @@ package org.apache.maven.project;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class SuperPomProjectBuilderTest
|
||||
extends AbstractMavenProjectTestCase
|
||||
|
@ -45,7 +36,7 @@ public class SuperPomProjectBuilderTest
|
|||
MavenProject project = projectBuilder.buildStandaloneSuperProject();
|
||||
|
||||
assertNotNull( project.getRemoteArtifactRepositories() );
|
||||
|
||||
assertNotNull( project.getPluginArtifactRepositories() );
|
||||
//
|
||||
// assertNotNull( project.getPluginArtifactRepositories() );
|
||||
}
|
||||
}
|
|
@ -193,15 +193,15 @@ public class DefaultModelValidatorTest
|
|||
{
|
||||
ModelValidationResult result = validate( "missing-repository-id-pom.xml" );
|
||||
|
||||
assertEquals( 4, result.getMessageCount() );
|
||||
assertEquals( 2, result.getMessageCount() );
|
||||
|
||||
assertEquals( "'repositories.repository.id' is missing.", result.getMessage( 0 ) );
|
||||
|
||||
assertEquals( "'repositories.repository.url' is missing.", result.getMessage( 1 ) );
|
||||
|
||||
assertEquals( "'pluginRepositories.pluginRepository.id' is missing.", result.getMessage( 2 ) );
|
||||
|
||||
assertEquals( "'pluginRepositories.pluginRepository.url' is missing.", result.getMessage( 3 ) );
|
||||
//
|
||||
// assertEquals( "'pluginRepositories.pluginRepository.id' is missing.", result.getMessage( 2 ) );
|
||||
//
|
||||
// assertEquals( "'pluginRepositories.pluginRepository.url' is missing.", result.getMessage( 3 ) );
|
||||
}
|
||||
|
||||
public void testMissingResourceDirectory()
|
||||
|
|
Loading…
Reference in New Issue