You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/06/20 18:40:21 UTC
svn commit: r786853 - in /maven/components/trunk:
maven-core/src/main/java/org/apache/maven/project/
maven-core/src/main/resources/org/apache/maven/project/
maven-model-builder/src/main/resources/org/apache/maven/project/
Author: bentmann
Date: Sat Jun 20 16:40:21 2009
New Revision: 786853
URL: http://svn.apache.org/viewvc?rev=786853&view=rev
Log:
o Removed super POM handling from project builder and did a proper call to the model builder instead
Added:
maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/ (with props)
maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/standalone.xml (with props)
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
maven/components/trunk/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java?rev=786853&r1=786852&r2=786853&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java Sat Jun 20 16:40:21 2009
@@ -16,7 +16,6 @@
*/
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.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;
@@ -61,9 +60,6 @@
private ModelBuilder modelBuilder;
@Requirement
- private ModelReader modelReader;
-
- @Requirement
private LifecycleExecutor lifecycle;
@Requirement
@@ -72,7 +68,7 @@
@Requirement
private ResolutionErrorHandler resolutionErrorHandler;
- private MavenProject superProject;
+ private MavenProject standaloneProject;
// ----------------------------------------------------------------------
// MavenProjectBuilder Implementation
@@ -87,19 +83,7 @@
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 @@
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 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 @@
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;
- }
-
}
\ No newline at end of file
Propchange: maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/
------------------------------------------------------------------------------
bugtraq:label = Enter issue ID:
Propchange: maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/
------------------------------------------------------------------------------
bugtraq:message = Issue id: %BUGID%
Propchange: maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/
------------------------------------------------------------------------------
bugtraq:number = false
Propchange: maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Added: maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/standalone.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/standalone.xml?rev=786853&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/standalone.xml (added)
+++ maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/standalone.xml Sat Jun 20 16:40:21 2009
@@ -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>
Propchange: maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/standalone.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/resources/org/apache/maven/project/standalone.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/components/trunk/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml?rev=786853&r1=786852&r2=786853&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml (original)
+++ maven/components/trunk/maven-model-builder/src/main/resources/org/apache/maven/project/pom-4.0.0.xml Sat Jun 20 16:40:21 2009
@@ -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 @@
<!-- 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 @@
<outputDirectory>${project.build.directory}/site</outputDirectory>
</reporting>
</project>
- <!-- END SNIPPET: superpom -->
+<!-- END SNIPPET: superpom -->