Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 9466 invoked from network); 14 Jun 2009 16:46:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jun 2009 16:46:31 -0000 Received: (qmail 48777 invoked by uid 500); 14 Jun 2009 16:46:42 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 48654 invoked by uid 500); 14 Jun 2009 16:46:42 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 48645 invoked by uid 99); 14 Jun 2009 16:46:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Jun 2009 16:46:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Jun 2009 16:46:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9E3B92388874; Sun, 14 Jun 2009 16:46:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r784583 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/project/ maven-model-builder/src/main/java/org/apache/maven/model/ Date: Sun, 14 Jun 2009 16:46:16 -0000 To: commits@maven.apache.org From: bentmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090614164616.9E3B92388874@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bentmann Date: Sun Jun 14 16:46:16 2009 New Revision: 784583 URL: http://svn.apache.org/viewvc?rev=784583&view=rev Log: o Kept active external and POM profiles separate in model building result Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java 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=784583&r1=784582&r2=784583&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 Sun Jun 14 16:46:16 2009 @@ -17,7 +17,8 @@ import java.io.File; import java.io.IOException; -import java.util.Date; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -36,6 +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.resolution.ModelResolver; import org.apache.maven.project.artifact.ProjectArtifact; @@ -141,7 +143,11 @@ project.addCompileSourceRoot( build.getSourceDirectory() ); project.addTestCompileSourceRoot( build.getTestSourceDirectory() ); project.setFile( pomFile ); - project.setActiveProfiles( result.getActiveProfiles( result.getRawModel() ) ); + + List activeProfiles = new ArrayList(); + activeProfiles.addAll( result.getActivePomProfiles( result.getRawModel() ) ); + activeProfiles.addAll( result.getActiveExternalProfiles() ); + project.setActiveProfiles( activeProfiles ); return project; } Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java?rev=784583&r1=784582&r2=784583&view=diff ============================================================================== --- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java (original) +++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java Sun Jun 14 16:46:16 2009 @@ -117,6 +117,8 @@ List activeExternalProfiles = getActiveExternalProfiles( request, profileActivationContext, problems ); + result.setActiveExternalProfiles( activeExternalProfiles ); + Model model = readModel( modelSource, pomFile, request, problems ); List rawModels = new ArrayList(); @@ -132,23 +134,22 @@ modelNormalizer.mergeDuplicates( resultModel, request ); - List activeProjectProfiles = - getActiveProjectProfiles( rawModel, profileActivationContext, problems ); + List activePomProfiles = getActivePomProfiles( rawModel, profileActivationContext, problems ); - List activeProfiles = activeProjectProfiles; - if ( current == model ) - { - activeProfiles = new ArrayList( activeProjectProfiles.size() + activeExternalProfiles.size() ); - activeProfiles.addAll( activeProjectProfiles ); - activeProfiles.addAll( activeExternalProfiles ); - } + result.setActivePomProfiles( rawModel, activePomProfiles ); - for ( Profile activeProfile : activeProfiles ) + for ( Profile activeProfile : activePomProfiles ) { profileInjector.injectProfile( resultModel, activeProfile, request ); } - result.setActiveProfiles( rawModel, activeProfiles ); + if ( current == model ) + { + for ( Profile activeProfile : activeExternalProfiles ) + { + profileInjector.injectProfile( resultModel, activeProfile, request ); + } + } configureResolver( request.getModelResolver(), resultModel, problems ); } @@ -265,8 +266,8 @@ return result.getActiveProfiles(); } - private List getActiveProjectProfiles( Model model, ProfileActivationContext context, - List problems ) + private List getActivePomProfiles( Model model, ProfileActivationContext context, + List problems ) { ProfileSelectionResult result = profileSelector.getActiveProfiles( model.getProfiles(), context ); Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java?rev=784583&r1=784582&r2=784583&view=diff ============================================================================== --- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java (original) +++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java Sun Jun 14 16:46:16 2009 @@ -38,12 +38,15 @@ private List rawModels; - private Map> activeProfiles; + private Map> activePomProfiles; + + private List activeExternalProfiles; public DefaultModelBuildingResult() { rawModels = new ArrayList(); - activeProfiles = new HashMap>(); + activePomProfiles = new HashMap>(); + activeExternalProfiles = new ArrayList(); } public Model getEffectiveModel() @@ -79,13 +82,13 @@ return this; } - public List getActiveProfiles( Model rawModel ) + public List getActivePomProfiles( Model rawModel ) { - List profiles = this.activeProfiles.get( rawModel ); + List profiles = this.activePomProfiles.get( rawModel ); return ( profiles == null ) ? Collections. emptyList() : Collections.unmodifiableList( profiles ); } - public DefaultModelBuildingResult setActiveProfiles( Model rawModel, List activeProfiles ) + public DefaultModelBuildingResult setActivePomProfiles( Model rawModel, List activeProfiles ) { if ( rawModel == null ) { @@ -94,32 +97,48 @@ if ( activeProfiles != null ) { - this.activeProfiles.put( rawModel, new ArrayList( activeProfiles ) ); + this.activePomProfiles.put( rawModel, new ArrayList( activeProfiles ) ); } else { - this.activeProfiles.remove( rawModel ); + this.activePomProfiles.remove( rawModel ); } return this; } - public DefaultModelBuildingResult addActiveProfiles( Model rawModel, List activeProfiles ) + public DefaultModelBuildingResult addActivePomProfiles( Model rawModel, List activeProfiles ) { if ( rawModel == null ) { throw new IllegalArgumentException( "no model specified" ); } - List currentProfiles = this.activeProfiles.get( rawModel ); + List currentProfiles = this.activePomProfiles.get( rawModel ); if ( currentProfiles == null ) { currentProfiles = new ArrayList( activeProfiles.size() ); - this.activeProfiles.put( rawModel, currentProfiles ); + this.activePomProfiles.put( rawModel, currentProfiles ); } currentProfiles.addAll( activeProfiles ); return this; } + public List getActiveExternalProfiles() + { + return Collections.unmodifiableList( activeExternalProfiles ); + } + + public DefaultModelBuildingResult setActiveExternalProfiles( List activeProfiles ) + { + this.activeExternalProfiles.clear(); + if ( activeProfiles != null ) + { + this.activeExternalProfiles.addAll( activeProfiles ); + } + + return this; + } + } Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java?rev=784583&r1=784582&r2=784583&view=diff ============================================================================== --- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java (original) +++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java Sun Jun 14 16:46:16 2009 @@ -29,12 +29,44 @@ public interface ModelBuildingResult { + /** + * Gets the fully assembled model. + * + * @return The fully assembled model, never {@code null}. + */ Model getEffectiveModel(); + /** + * Gets the raw model as it was read from the model source. Apart from basic validation, the raw model has not + * undergone any updates by the model builder, e.g. reflects neither inheritance or interpolation. + * + * @return The raw model, never {@code null}. + */ Model getRawModel(); + /** + * Gets the lineage of raw models from which the effective model was constructed. The first model is the model on + * which the model builder was originally invoked, the last model is the super POM. + * + * @return The lineage of raw models, never {@code null}. + */ List getRawModels(); - List getActiveProfiles( Model rawModel ); + /** + * Gets the profiles from the specified (raw) model that were active during model building. The input parameter + * should be a model from the collection obtained by {@link #getRawModels()}. + * + * @param rawModel The (raw) model for whose active profiles should be retrieved, must not be {@code null}. + * @return The active profiles of the model or an empty list if none, never {@code null}. + */ + List getActivePomProfiles( Model rawModel ); + + /** + * Gets the external profiles that were active during model building. External profiles are those that were + * contributed by {@link ModelBuildingRequest#getProfiles()}. + * + * @return The active external profiles or an empty list if none, never {@code null}. + */ + List getActiveExternalProfiles(); }