diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 1b90abd83a..c1388a0b14 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -558,17 +558,21 @@ public class DefaultPluginManager PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); Xpp3Dom dom = mojoExecution.getConfiguration(); + if ( dom != null ) { try { List interpolatorProperties = new ArrayList(); + interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( session.getProjectBuilderConfiguration().getExecutionProperties(), PomInterpolatorTag.SYSTEM_PROPERTIES.name())); + interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( session.getProjectBuilderConfiguration().getUserProperties(), PomInterpolatorTag.USER_PROPERTIES.name())); - String interpolatedDom = - Interpolator.interpolateXmlString( String.valueOf( dom ), interpolatorProperties ); + + String interpolatedDom = Interpolator.interpolateXmlString( String.valueOf( dom ), interpolatorProperties ); + dom = Xpp3DomBuilder.build( new StringReader( interpolatedDom ) ); } catch ( XmlPullParserException e ) diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java index 65eee0f3e1..37e3b8932b 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java @@ -26,11 +26,10 @@ import java.util.List; import java.util.Properties; import org.apache.maven.Maven; +import org.apache.maven.MavenTools; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.embedder.Configuration; import org.apache.maven.embedder.MavenEmbedder; import org.apache.maven.embedder.MavenEmbedderException; @@ -53,15 +52,11 @@ import org.apache.maven.settings.Settings; import org.apache.maven.settings.SettingsConfigurationException; import org.apache.maven.settings.SettingsUtils; import org.apache.maven.wagon.repository.RepositoryPermissions; -import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -85,12 +80,6 @@ public class DefaultMavenExecutionRequestPopulator extends AbstractLogEnabled implements MavenExecutionRequestPopulator { - @Requirement - private ArtifactRepositoryFactory artifactRepositoryFactory; - - @Requirement - private ArtifactRepositoryLayout defaultArtifactRepositoryLayout; - @Requirement private PlexusContainer container; @@ -100,6 +89,9 @@ public class DefaultMavenExecutionRequestPopulator @Requirement private MavenSettingsBuilder settingsBuilder; + @Requirement + private MavenTools mavenTools; + public MavenExecutionRequest populateDefaults( MavenExecutionRequest request, Configuration configuration ) throws MavenEmbedderException @@ -259,8 +251,7 @@ public class DefaultMavenExecutionRequestPopulator snapshots.setUpdatePolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } - ArtifactRepository ar = artifactRepositoryFactory.createArtifactRepository( r.getId(), r.getUrl(), - defaultArtifactRepositoryLayout, snapshots, releases ); + ArtifactRepository ar = mavenTools.createRepository( r.getId(), r.getUrl(), snapshots, releases ); request.addRemoteRepository( ar ); } @@ -347,10 +338,6 @@ public class DefaultMavenExecutionRequestPopulator } } - // ------------------------------------------------------------------------ - // Local Repository - // ------------------------------------------------------------------------ - private void localRepository( MavenExecutionRequest request, Configuration configuration ) throws MavenEmbedderException @@ -368,119 +355,7 @@ public class DefaultMavenExecutionRequestPopulator request.setLocalRepository( createLocalRepository( request, request.getSettings(), configuration ) ); } } - - - public ArtifactRepository createLocalRepository( MavenExecutionRequest request, - Settings settings, - Configuration configuration ) - throws MavenEmbedderException - { - String localRepositoryPath = null; - - if ( request.getLocalRepositoryPath() != null ) - { - localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath(); - } - - if ( StringUtils.isEmpty( localRepositoryPath ) && ( configuration.getLocalRepository() != null ) ) - { - localRepositoryPath = configuration.getLocalRepository().getAbsolutePath(); - } - - if ( StringUtils.isEmpty( localRepositoryPath ) ) - { - localRepositoryPath = settings.getLocalRepository(); - } - - if ( StringUtils.isEmpty( localRepositoryPath ) ) - { - localRepositoryPath = MavenEmbedder.defaultUserLocalRepository.getAbsolutePath(); - } - - return createLocalRepository( - localRepositoryPath, - MavenEmbedder.DEFAULT_LOCAL_REPO_ID ); - } - - public ArtifactRepository createLocalRepository( String url, - String repositoryId ) - throws MavenEmbedderException - { - try - { - return createRepository( - canonicalFileUrl( url ), - repositoryId ); - } - catch ( IOException e ) - { - throw new MavenEmbedderException( - "Unable to resolve canonical path for local repository " + url, - e ); - } - } - - private String canonicalFileUrl( String url ) - throws IOException - { - if ( !url.startsWith( "file:" ) ) - { - url = "file://" + url; - } - else if ( url.startsWith( "file:" ) && !url.startsWith( "file://" ) ) - { - url = "file://" + url.substring( "file:".length() ); - } - - // So now we have an url of the form file:// - - // We want to eliminate any relative path nonsense and lock down the path so we - // need to fully resolve it before any sub-modules use the path. This can happen - // when you are using a custom settings.xml that contains a relative path entry - // for the local repository setting. - - File localRepository = new File( url.substring( "file://".length() ) ); - - if ( !localRepository.isAbsolute() ) - { - url = "file://" + localRepository.getCanonicalPath(); - } - - return url; - } - - public ArtifactRepository createRepository( String url, - String repositoryId ) - { - // snapshots vs releases - // offline = to turning the update policy off - - //TODO: we'll need to allow finer grained creation of repositories but this will do for now - - String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS; - - String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN; - - ArtifactRepositoryPolicy snapshotsPolicy = - new ArtifactRepositoryPolicy( - true, - updatePolicyFlag, - checksumPolicyFlag ); - - ArtifactRepositoryPolicy releasesPolicy = - new ArtifactRepositoryPolicy( - true, - updatePolicyFlag, - checksumPolicyFlag ); - - return artifactRepositoryFactory.createArtifactRepository( - repositoryId, - url, - defaultArtifactRepositoryLayout, - snapshotsPolicy, - releasesPolicy ); - } - + // ------------------------------------------------------------------------ // Snapshot Policy // ------------------------------------------------------------------------ @@ -505,12 +380,12 @@ public class DefaultMavenExecutionRequestPopulator { if ( request.isUpdateSnapshots() ) { - artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS ); + mavenTools.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS ); } else if ( request.isNoSnapshotUpdates() ) { getLogger().info( "+ Supressing SNAPSHOT updates." ); - artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER ); + mavenTools.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER ); } } } @@ -528,7 +403,7 @@ public class DefaultMavenExecutionRequestPopulator // We take the checksum passed in via the request. // ------------------------------------------------------------------------ - artifactRepositoryFactory.setGlobalChecksumPolicy( request.getGlobalChecksumPolicy() ); + mavenTools.setGlobalChecksumPolicy( request.getGlobalChecksumPolicy() ); } // ------------------------------------------------------------------------ @@ -626,7 +501,7 @@ public class DefaultMavenExecutionRequestPopulator } RepositoryPermissions defaultPermissions = new RepositoryPermissions(); - + defaultPermissions.setDirectoryMode( "775" ); defaultPermissions.setFileMode( "664" ); @@ -649,6 +524,43 @@ public class DefaultMavenExecutionRequestPopulator } } + public ArtifactRepository createLocalRepository( MavenExecutionRequest request, + Settings settings, + Configuration configuration ) + throws MavenEmbedderException + { + String localRepositoryPath = null; + + if ( request.getLocalRepositoryPath() != null ) + { + localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath(); + } + + if ( StringUtils.isEmpty( localRepositoryPath ) && ( configuration.getLocalRepository() != null ) ) + { + localRepositoryPath = configuration.getLocalRepository().getAbsolutePath(); + } + + if ( StringUtils.isEmpty( localRepositoryPath ) ) + { + localRepositoryPath = settings.getLocalRepository(); + } + + if ( StringUtils.isEmpty( localRepositoryPath ) ) + { + localRepositoryPath = MavenEmbedder.defaultUserLocalRepository.getAbsolutePath(); + } + + try + { + return mavenTools.createLocalRepository( localRepositoryPath, MavenEmbedder.DEFAULT_LOCAL_REPO_ID ); + } + catch ( IOException e ) + { + throw new MavenEmbedderException( "Cannot create local repository.", e ); + } + } + // ------------------------------------------------------------------------ // Eventing // ------------------------------------------------------------------------ @@ -689,15 +601,12 @@ public class DefaultMavenExecutionRequestPopulator { // ------------------------------------------------------------------------ // Profile Manager - // - // // ------------------------------------------------------------------------ ProfileActivationContext activationContext = request.getProfileActivationContext(); if ( activationContext == null ) { - activationContext = new DefaultProfileActivationContext( - request.getProperties(), false ); + activationContext = new DefaultProfileActivationContext( request.getProperties(), false ); } activationContext.setExplicitlyActiveProfileIds( request.getActiveProfiles() ); diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java b/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java index 06b8a8dc4a..2fbd845686 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java @@ -169,13 +169,16 @@ public class PomTransformer } } - List pList = new ArrayList(); + List pList; + if ( !hasExecutionsTag ) { pList = managementContainer.getProperties(); } else { + pList = new ArrayList(); + for ( ModelProperty mp : managementContainer.getProperties() ) { if ( !mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri ) ) @@ -191,8 +194,8 @@ public class PomTransformer if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) ) { - ModelDataSource dependencyDatasource = new DefaultModelDataSource(); - dependencyDatasource.init( pluginContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(), + ModelDataSource pluginDatasource = new DefaultModelDataSource(); + pluginDatasource.init( pluginContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) ); ModelDataSource managementDatasource = new DefaultModelDataSource(); @@ -208,12 +211,12 @@ public class PomTransformer source.join( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) ); - List dependencyExecutionContainers = dependencyDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri); + List pluginExecutionContainers = pluginDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri); List joinedExecutionContainers = new ArrayList(); for(ModelContainer a : managementExecutionContainers) { - for(ModelContainer b : dependencyExecutionContainers) + for(ModelContainer b : pluginExecutionContainers) { if(b.containerAction(a).equals(ModelContainerAction.JOIN)) { @@ -269,8 +272,8 @@ public class PomTransformer ModelDataSource executionSource = new DefaultModelDataSource(); executionSource.init( pluginContainer.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ) ); - List executionContainers = - executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ); + List executionContainers = executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ); + if ( executionContainers.size() < 2 ) { continue; diff --git a/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java b/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java index 46cff4e94d..7a7613c98d 100644 --- a/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java +++ b/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java @@ -19,6 +19,8 @@ package org.apache.maven; * under the License. */ +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -27,6 +29,7 @@ import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; @@ -44,6 +47,9 @@ public class DefaultMavenTools @Requirement private ArtifactRepositoryFactory artifactRepositoryFactory; + @Requirement + private ArtifactRepositoryLayout defaultArtifactRepositoryLayout; + // ---------------------------------------------------------------------------- // Code snagged from ProjectUtils: this will have to be moved somewhere else // but just trying to collect it all in one place right now. @@ -140,4 +146,78 @@ public class DefaultMavenTools return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy ); } + + // From MavenExecutionRequestPopulator + + public ArtifactRepository createLocalRepository( String url, String repositoryId ) + throws IOException + { + return createRepository( canonicalFileUrl( url ), repositoryId ); + } + + private String canonicalFileUrl( String url ) + throws IOException + { + if ( !url.startsWith( "file:" ) ) + { + url = "file://" + url; + } + else if ( url.startsWith( "file:" ) && !url.startsWith( "file://" ) ) + { + url = "file://" + url.substring( "file:".length() ); + } + + // So now we have an url of the form file:// + + // We want to eliminate any relative path nonsense and lock down the path so we + // need to fully resolve it before any sub-modules use the path. This can happen + // when you are using a custom settings.xml that contains a relative path entry + // for the local repository setting. + + File localRepository = new File( url.substring( "file://".length() ) ); + + if ( !localRepository.isAbsolute() ) + { + url = "file://" + localRepository.getCanonicalPath(); + } + + return url; + } + + public ArtifactRepository createRepository( String url, + String repositoryId ) + { + // snapshots vs releases + // offline = to turning the update policy off + + //TODO: we'll need to allow finer grained creation of repositories but this will do for now + + String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS; + + String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN; + + ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag ); + + ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag, checksumPolicyFlag ); + + return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy ); + } + + public ArtifactRepository createRepository( String url, + String repositoryId, + ArtifactRepositoryPolicy snapshotsPolicy, + ArtifactRepositoryPolicy releasesPolicy ) + { + return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy ); + } + + public void setGlobalUpdatePolicy( String policy ) + { + artifactRepositoryFactory.setGlobalUpdatePolicy( policy ); + } + + public void setGlobalChecksumPolicy( String policy ) + { + artifactRepositoryFactory.setGlobalChecksumPolicy( policy ); + } } diff --git a/maven-project/src/main/java/org/apache/maven/MavenTools.java b/maven-project/src/main/java/org/apache/maven/MavenTools.java index ad34776674..eb633c4805 100644 --- a/maven-project/src/main/java/org/apache/maven/MavenTools.java +++ b/maven-project/src/main/java/org/apache/maven/MavenTools.java @@ -21,9 +21,12 @@ package org.apache.maven; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.Repository; +import java.io.IOException; import java.util.List; /** @@ -45,4 +48,15 @@ public interface MavenTools ArtifactRepository buildArtifactRepository( Repository repo ) throws InvalidRepositoryException; + + ArtifactRepository createLocalRepository( String url, String repositoryId ) + throws IOException; + + ArtifactRepository createRepository( String url, String repositoryId ); + + ArtifactRepository createRepository( String url, String repositoryId, ArtifactRepositoryPolicy snapshotsPolicy, ArtifactRepositoryPolicy releasesPolicy ); + + void setGlobalUpdatePolicy( String policy ); + + void setGlobalChecksumPolicy( String policy ); } diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 9fa40c1d81..0df24e14b0 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -74,15 +74,6 @@ public class DefaultMavenProjectBuilder @Requirement protected MavenProfilesBuilder profilesBuilder; - @Requirement - protected ArtifactResolver artifactResolver; - - @Requirement - protected ArtifactMetadataSource artifactMetadataSource; - - @Requirement - private ArtifactFactory artifactFactory; - @Requirement private ModelValidator validator; @@ -101,6 +92,15 @@ public class DefaultMavenProjectBuilder private MavenXpp3Reader modelReader; private Logger logger; + + @Requirement + protected ArtifactResolver artifactResolver; + + @Requirement + protected ArtifactMetadataSource artifactMetadataSource; + + @Requirement + private ArtifactFactory artifactFactory; //DO NOT USE, it is here only for backward compatibility reasons. The existing // maven-assembly-plugin (2.2-beta-1) is accessing it via reflection. @@ -135,22 +135,21 @@ public class DefaultMavenProjectBuilder public MavenProject build( File projectDescriptor, ProjectBuilderConfiguration config ) throws ProjectBuildingException { - MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver( - config.getLocalRepository(), repositoryHelper.buildArtifactRepositories( - getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config ); + MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver( config.getLocalRepository(), repositoryHelper + .buildArtifactRepositories( getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config ); - project.setFile( projectDescriptor ); - project = buildWithProfiles( project.getModel(), config, projectDescriptor, project.getParentFile(), true ); + project.setFile( projectDescriptor ); + project = buildWithProfiles( project.getModel(), config, projectDescriptor, project.getParentFile(), true ); - Build build = project.getBuild(); - // NOTE: setting this script-source root before path translation, because - // the plugin tools compose basedir and scriptSourceRoot into a single file. - project.addScriptSourceRoot( build.getScriptSourceDirectory() ); - project.addCompileSourceRoot( build.getSourceDirectory() ); - project.addTestCompileSourceRoot( build.getTestSourceDirectory() ); - project.setFile( projectDescriptor ); + Build build = project.getBuild(); + // NOTE: setting this script-source root before path translation, because + // the plugin tools compose basedir and scriptSourceRoot into a single file. + project.addScriptSourceRoot( build.getScriptSourceDirectory() ); + project.addCompileSourceRoot( build.getSourceDirectory() ); + project.addTestCompileSourceRoot( build.getTestSourceDirectory() ); + project.setFile( projectDescriptor ); - setBuildOutputDirectoryOnParent( project ); + setBuildOutputDirectoryOnParent( project ); return project; } @@ -189,8 +188,7 @@ public class DefaultMavenProjectBuilder return project; } - File f = (artifact.getFile() != null) ? artifact.getFile() : - new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );; + File f = (artifact.getFile() != null) ? artifact.getFile() : new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); repositoryHelper.findModelFromRepository( artifact, remoteArtifactRepositories, localRepository ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ); @@ -200,7 +198,6 @@ public class DefaultMavenProjectBuilder project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config ); project = buildWithProfiles( project.getModel(), config, artifact.getFile(), project.getParentFile(), false ); - // project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config ); artifact.setFile( f ); project.setVersion( artifact.getVersion() ); @@ -242,8 +239,10 @@ public class DefaultMavenProjectBuilder } List interpolatorProperties = new ArrayList(); + interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getExecutionProperties(), PomInterpolatorTag.SYSTEM_PROPERTIES.name())); + interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getUserProperties(), PomInterpolatorTag.USER_PROPERTIES.name())); @@ -482,6 +481,7 @@ public class DefaultMavenProjectBuilder } URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" ); + String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID ); Reader reader = null; @@ -492,13 +492,13 @@ public class DefaultMavenProjectBuilder if ( modelSource.indexOf( "" + MAVEN_MODEL_VERSION ) < 0 ) { - throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.", - new File( "." ) ); + throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.", new File( "." ) ); } StringReader sReader = new StringReader( modelSource ); superModel = modelReader.read( sReader, STRICT_MODEL_PARSING ); + return superModel; } catch ( XmlPullParserException e ) @@ -526,14 +526,11 @@ public class DefaultMavenProjectBuilder throw new IllegalArgumentException( "projectDescriptor: null, Project Id =" + projectId ); } - if ( projectBuilder == null ) - { - throw new IllegalArgumentException( "projectBuilder: not initialized" ); - } - List interpolatorProperties = new ArrayList(); + interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getExecutionProperties(), PomInterpolatorTag.SYSTEM_PROPERTIES.name())); + interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getUserProperties(), PomInterpolatorTag.USER_PROPERTIES.name())); @@ -545,13 +542,19 @@ public class DefaultMavenProjectBuilder } interpolatorProperties.add(new InterpolatorProperty("${mavenVersion}", MavenProjectBuilder.STANDALONE_SUPERPOM_VERSION, PomInterpolatorTag.SYSTEM_PROPERTIES.name())); + MavenProject mavenProject; + try { - mavenProject = projectBuilder.buildFromLocalPath( new FileInputStream( projectDescriptor ), Arrays.asList( - getSuperProject( config, projectDescriptor, true ).getModel() ), null, interpolatorProperties, resolver, - projectDescriptor.getParentFile(), - config ); + mavenProject = projectBuilder.buildFromLocalPath( new FileInputStream( projectDescriptor ), + Arrays.asList( + getSuperProject( config, projectDescriptor, true ).getModel() ), + null, + interpolatorProperties, + resolver, + projectDescriptor.getParentFile(), + config ); } catch ( IOException e ) { diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java index 555f97db27..4bdba716d7 100644 --- a/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java @@ -37,21 +37,20 @@ public interface MavenProjectBuilder // site MavenProject build( File project, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException; - + // remote resources plugin MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStub ) - throws ProjectBuildingException; - // + throws ProjectBuildingException; MavenProject build( File project, ProjectBuilderConfiguration configuration ) throws ProjectBuildingException; - MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuilderConfiguration config ) + MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuilderConfiguration configuration ) throws ProjectBuildingException; MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository ) throws ProjectBuildingException; - MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config ) + MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration configuration ) throws ProjectBuildingException; } diff --git a/pom.xml b/pom.xml index e0fed88d76..6aab005502 100644 --- a/pom.xml +++ b/pom.xml @@ -46,44 +46,6 @@ under the License. jira http://jira.codehaus.org/browse/MNG - - - - - sonatype.snapshots - http://repository.sonatype.org/service/local/repositories/snapshots/content/ - - false - - - - sonatype.releases - http://repository.sonatype.org/service/local/repositories/releases/content/ - - false - - - - apache.snapshots - http://people.apache.org/repo/m2-snapshot-repository/ - - true - - - false - - - - codehaus.snapshots - http://snapshots.repository.codehaus.org/ - - true - - - false - - - Maven Developer List @@ -297,7 +259,7 @@ under the License. 1.5.5 1.0-beta-4 1.0-SNAPSHOT - 1.0.0-alpha-2-SNAPSHOT + 1.0.0-alpha-2 3.2.6 1.0-alpha-22