mirror of https://github.com/apache/maven.git
o Removed super POM handling from project builder and did a proper call to the model builder instead
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@786853 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f526ca65d
commit
6a63fb495f
|
@ -16,7 +16,6 @@ package org.apache.maven.project;
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -38,7 +37,7 @@ import org.apache.maven.model.ModelBuildingException;
|
|||
import org.apache.maven.model.ModelBuildingRequest;
|
||||
import org.apache.maven.model.ModelBuildingResult;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.io.ModelReader;
|
||||
import org.apache.maven.model.UrlModelSource;
|
||||
import org.apache.maven.model.resolution.ModelResolver;
|
||||
import org.apache.maven.project.artifact.ProjectArtifact;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
|
@ -60,9 +59,6 @@ public class DefaultProjectBuilder
|
|||
@Requirement
|
||||
private ModelBuilder modelBuilder;
|
||||
|
||||
@Requirement
|
||||
private ModelReader modelReader;
|
||||
|
||||
@Requirement
|
||||
private LifecycleExecutor lifecycle;
|
||||
|
||||
|
@ -72,7 +68,7 @@ public class DefaultProjectBuilder
|
|||
@Requirement
|
||||
private ResolutionErrorHandler resolutionErrorHandler;
|
||||
|
||||
private MavenProject superProject;
|
||||
private MavenProject standaloneProject;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// MavenProjectBuilder Implementation
|
||||
|
@ -87,19 +83,7 @@ public class DefaultProjectBuilder
|
|||
private MavenProject build( File pomFile, boolean localProject, ProjectBuildingRequest configuration )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
ModelResolver resolver =
|
||||
new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, configuration.getLocalRepository(),
|
||||
configuration.getRemoteRepositories() );
|
||||
|
||||
ModelBuildingRequest request = new DefaultModelBuildingRequest();
|
||||
request.setLenientValidation( configuration.istLenientValidation() );
|
||||
request.setProcessPlugins( configuration.isProcessPlugins() );
|
||||
request.setProfiles( configuration.getProfiles() );
|
||||
request.setActiveProfileIds( configuration.getActiveProfileIds() );
|
||||
request.setInactiveProfileIds( configuration.getInactiveProfileIds() );
|
||||
request.setExecutionProperties( configuration.getExecutionProperties() );
|
||||
request.setBuildStartTime( configuration.getBuildStartTime() );
|
||||
request.setModelResolver( resolver );
|
||||
ModelBuildingRequest request = getModelBuildingRequest( configuration );
|
||||
|
||||
ModelBuildingResult result;
|
||||
try
|
||||
|
@ -153,6 +137,25 @@ public class DefaultProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
private ModelBuildingRequest getModelBuildingRequest( ProjectBuildingRequest configuration )
|
||||
{
|
||||
ModelResolver resolver =
|
||||
new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, configuration.getLocalRepository(),
|
||||
configuration.getRemoteRepositories() );
|
||||
|
||||
ModelBuildingRequest request = new DefaultModelBuildingRequest();
|
||||
request.setLenientValidation( configuration.istLenientValidation() );
|
||||
request.setProcessPlugins( configuration.isProcessPlugins() );
|
||||
request.setProfiles( configuration.getProfiles() );
|
||||
request.setActiveProfileIds( configuration.getActiveProfileIds() );
|
||||
request.setInactiveProfileIds( configuration.getInactiveProfileIds() );
|
||||
request.setExecutionProperties( configuration.getExecutionProperties() );
|
||||
request.setBuildStartTime( configuration.getBuildStartTime() );
|
||||
request.setModelResolver( resolver );
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public MavenProject build( Artifact artifact, ProjectBuildingRequest configuration )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
@ -189,25 +192,35 @@ public class DefaultProjectBuilder
|
|||
public MavenProject buildStandaloneSuperProject( ProjectBuildingRequest config )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( superProject != null )
|
||||
if ( standaloneProject != null )
|
||||
{
|
||||
return superProject;
|
||||
return standaloneProject;
|
||||
}
|
||||
|
||||
Model superModel = getSuperModel();
|
||||
ModelBuildingRequest request = getModelBuildingRequest( config );
|
||||
|
||||
ModelBuildingResult result;
|
||||
try
|
||||
{
|
||||
result = modelBuilder.build( new UrlModelSource( getClass().getResource( "standalone.xml" ) ), request );
|
||||
}
|
||||
catch ( ModelBuildingException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "[standalone]", "Failed to build standalone project", e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
superProject = new MavenProject( superModel, repositorySystem, this, config );
|
||||
standaloneProject = new MavenProject( result.getEffectiveModel(), repositorySystem, this, config );
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
// Not going to happen.
|
||||
}
|
||||
|
||||
superProject.setExecutionRoot( true );
|
||||
standaloneProject.setExecutionRoot( true );
|
||||
|
||||
return superProject;
|
||||
return standaloneProject;
|
||||
}
|
||||
|
||||
public MavenProjectBuildingResult buildProjectWithDependencies( File pomFile, ProjectBuildingRequest request )
|
||||
|
@ -282,32 +295,4 @@ public class DefaultProjectBuilder
|
|||
return ArtifactUtils.versionlessKey( gid, aid );
|
||||
}
|
||||
|
||||
// Super Model Handling
|
||||
|
||||
private static final String MAVEN_MODEL_VERSION = "4.0.0";
|
||||
|
||||
private Model superModel;
|
||||
|
||||
protected Model getSuperModel()
|
||||
{
|
||||
if ( superModel != null )
|
||||
{
|
||||
return superModel;
|
||||
}
|
||||
|
||||
String superPomResource = "/org/apache/maven/project/pom-" + MAVEN_MODEL_VERSION + ".xml";
|
||||
|
||||
try
|
||||
{
|
||||
superModel = modelReader.read( getClass().getResourceAsStream( superPomResource ), null );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new IllegalStateException( "The super POM is damaged"
|
||||
+ ", please verify the integrity of your Maven installation", e );
|
||||
}
|
||||
|
||||
return superModel;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?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</groupId>
|
||||
<artifactId>standalone-pom</artifactId>
|
||||
<version>1</version>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
|
@ -1,3 +1,5 @@
|
|||
<?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
|
||||
|
@ -20,10 +22,7 @@ under the License.
|
|||
<!-- START SNIPPET: superpom -->
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>super-pom</artifactId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<name>Maven Default Project</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
|
@ -155,4 +154,4 @@ under the License.
|
|||
<outputDirectory>${project.build.directory}/site</outputDirectory>
|
||||
</reporting>
|
||||
</project>
|
||||
<!-- END SNIPPET: superpom -->
|
||||
<!-- END SNIPPET: superpom -->
|
||||
|
|
Loading…
Reference in New Issue