You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by si...@apache.org on 2008/09/18 21:59:51 UTC
svn commit: r696784 - in
/maven/components/branches/sisbell-maven-3.0-profile:
maven-core/src/main/java/org/apache/maven/errors/
maven-core/src/main/java/org/apache/maven/execution/
maven-core/src/main/java/org/apache/maven/extension/ maven-core/src/ma...
Author: sisbell
Date: Thu Sep 18 12:59:51 2008
New Revision: 696784
URL: http://svn.apache.org/viewvc?rev=696784&view=rev
Log:
Added new profile injector code.
Modified:
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/DefaultProjectErrorReporter.java
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorReporter.java
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorTips.java
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilder.java
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/resources/META-INF/plexus/components.xml
maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/test/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilderTest.java
maven/components/branches/sisbell-maven-3.0-profile/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java
maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java
maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/DefaultProjectErrorReporter.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/DefaultProjectErrorReporter.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/DefaultProjectErrorReporter.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/DefaultProjectErrorReporter.java Thu Sep 18 12:59:51 2008
@@ -11,11 +11,9 @@
import org.apache.maven.model.Parent;
import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
-/*
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.activation.ProfileActivator;
-*/
import org.apache.maven.execution.DuplicateProjectException;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.InvalidProjectVersionException;
@@ -77,6 +75,9 @@
return new ArrayList( formattedMessages.keySet() );
}
+ /**
+ * @see ProjectErrorReporter#hasInformationFor(java.lang.Throwable)
+ */
public Throwable findReportedException( Throwable error )
{
if ( formattedMessages.containsKey( error ) )
@@ -138,7 +139,9 @@
formattedMessages.put( error, formattedMessage );
}
- /*
+ /**
+ * @see ProjectErrorReporter#reportActivatorErrorWhileApplyingProfiles(org.apache.maven.profiles.activation.ProfileActivator, org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException)
+ */
public void reportActivatorError( ProfileActivator activator,
Model model,
File pomFile,
@@ -173,10 +176,11 @@
cause ), writer );
registerBuildError( cause, writer.toString(), cause.getCause() );
-
}
- */
-/*
+
+ /**
+ * @see ProjectErrorReporter#reportActivatorLookupError(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
+ */
public void reportActivatorLookupError( Model model,
File pomFile,
Profile profile,
@@ -207,7 +211,7 @@
registerBuildError( cause, writer.toString(), cause.getCause() );
}
- */
+
/**
* @see ProjectErrorReporter#reportErrorLoadingExternalProfilesFromFile(org.apache.maven.model.Model, java.io.File, java.io.File, java.io.IOException)
*/
@@ -273,7 +277,9 @@
registerBuildError( cause, writer.toString(), cause.getCause() );
}
-
+ /**
+ * @see ProjectErrorReporter#reportInvalidRepositoryWhileGettingRepositoriesFromProfiles(org.apache.maven.model.Repository, java.lang.String, java.io.File, org.apache.maven.artifact.InvalidRepositoryException)
+ */
public void reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( Repository repo,
Model model,
File pomFile,
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorReporter.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorReporter.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorReporter.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorReporter.java Thu Sep 18 12:59:51 2008
@@ -8,11 +8,9 @@
import org.apache.maven.model.Parent;
import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
-/*
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.activation.ProfileActivator;
-*/
import org.apache.maven.execution.DuplicateProjectException;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.InvalidProjectVersionException;
@@ -59,14 +57,12 @@
* <------ ProjectBuildingException
* </pre>
*/
- /*
void reportActivatorError( ProfileActivator activator,
Model model,
File pomFile,
Profile profile,
ProfileActivationContext context,
ProfileActivationException cause );
- */
/**
* <b>Call Stack:</b>
@@ -84,13 +80,11 @@
* <------ ProjectBuildingException
* </pre>
*/
- /*
void reportActivatorLookupError( Model model,
File pomFile,
Profile profile,
ProfileActivationContext context,
ComponentLookupException cause );
- */
/**
* <b>Call Stack:</b>
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorTips.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorTips.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorTips.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/errors/ProjectErrorTips.java Thu Sep 18 12:59:51 2008
@@ -5,11 +5,9 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.apache.maven.model.RepositoryBase;
-/*
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.activation.ProfileActivator;
-*/
import org.apache.maven.execution.DuplicateProjectException;
import org.apache.maven.project.InvalidProjectVersionException;
import org.apache.maven.project.MavenProject;
@@ -34,7 +32,7 @@
private ProjectErrorTips()
{
}
- /*
+
public static List getTipsForActivatorError( ProfileActivator activator,
String projectId,
File pomFile,
@@ -48,7 +46,7 @@
"XSD location for settings.xml: http://maven.apache.org/xsd/settings-1.0.0.xsd",
"XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } );
}
- */
+
public static List getTipsForActivatorLookupError( String projectId,
File pomFile,
Profile profile,
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java Thu Sep 18 12:59:51 2008
@@ -23,8 +23,8 @@
import org.apache.maven.errors.CoreErrorReporter;
import org.apache.maven.monitor.event.EventMonitor;
import org.apache.maven.monitor.event.MavenWorkspaceMonitor;
-//import org.apache.maven.profiles.ProfileManager;
-//import org.apache.maven.profiles.activation.ProfileActivationContext;
+import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.realm.MavenRealmManager;
@@ -116,7 +116,7 @@
private boolean updateSnapshots = false;
- //private ProfileManager profileManager;
+ private ProfileManager profileManager;
private List remoteRepositories;
@@ -164,7 +164,7 @@
loggingLevel = original.getLoggingLevel();
globalChecksumPolicy = original.getGlobalChecksumPolicy();
updateSnapshots = original.isUpdateSnapshots();
- //profileManager = original.getProfileManager();
+ profileManager = original.getProfileManager();
remoteRepositories = original.getRemoteRepositories();
noSnapshotUpdates = original.isNoSnapshotUpdates();
realmManager = original.getRealmManager();
@@ -588,7 +588,7 @@
private CoreErrorReporter errorReporter;
- //private ProfileActivationContext profileActivationContext;
+ private ProfileActivationContext profileActivationContext;
// calculated from request attributes.
private ProjectBuilderConfiguration projectBuildingConfiguration;
@@ -604,7 +604,7 @@
{
return settings;
}
- /*
+
public ProfileManager getProfileManager()
{
return profileManager;
@@ -616,7 +616,7 @@
return this;
}
- */
+
public boolean isProjectPresent()
{
return isProjectPresent;
@@ -700,7 +700,7 @@
errorReporter = reporter;
return this;
}
- /*
+
public ProfileActivationContext getProfileActivationContext()
{
return profileActivationContext;
@@ -711,7 +711,7 @@
this.profileActivationContext = profileActivationContext;
return this;
}
- */
+
public MavenWorkspaceMonitor getWorkspaceMonitor()
{
return workspaceMonitor;
@@ -741,9 +741,10 @@
projectBuildingConfiguration = new DefaultProjectBuilderConfiguration();
projectBuildingConfiguration.setLocalRepository( getLocalRepository() );
projectBuildingConfiguration.setExecutionProperties( getProperties() );
- // projectBuildingConfiguration.setGlobalProfileManager( getProfileManager() );
+ projectBuildingConfiguration.setGlobalProfileManager( getProfileManager() );
projectBuildingConfiguration.setUserProperties( getUserProperties() );
projectBuildingConfiguration.setBuildStartTime( getStartTime() );
+ projectBuildingConfiguration.setActiveProfileIds(activeProfiles);
}
return projectBuildingConfiguration;
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java Thu Sep 18 12:59:51 2008
@@ -24,8 +24,8 @@
import org.apache.maven.errors.CoreErrorReporter;
import org.apache.maven.monitor.event.EventMonitor;
import org.apache.maven.monitor.event.MavenWorkspaceMonitor;
-//import org.apache.maven.profiles.ProfileManager;
-//import org.apache.maven.profiles.activation.ProfileActivationContext;
+import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.realm.MavenRealmManager;
import org.apache.maven.settings.Settings;
@@ -195,13 +195,13 @@
// Setting
Settings getSettings();
MavenExecutionRequest setSettings( Settings settings );
- /*
+
ProfileManager getProfileManager();
MavenExecutionRequest setProfileManager( ProfileManager profileManager );
ProfileActivationContext getProfileActivationContext();
MavenExecutionRequest setProfileActivationContext( ProfileActivationContext profileActivationContext );
- */
+
boolean isProjectPresent();
MavenExecutionRequest setProjectPresent( boolean isProjectPresent );
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java Thu Sep 18 12:59:51 2008
@@ -28,11 +28,9 @@
import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
-/*
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationContext;
-*/
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuilderConfiguration;
@@ -414,7 +412,7 @@
private ModelLineage buildModelLineage( File pom, ProjectBuilderConfiguration config,
List originalRemoteRepositories )
throws ExtensionScanningException
- { /*
+ {
ProfileManager profileManager = config.getGlobalProfileManager();
ProfileActivationContext profileActivationContext = profileManager == null
@@ -422,7 +420,7 @@
: profileManager.getProfileActivationContext();
boolean suppressActivatorFailure = profileActivationContext.isCustomActivatorFailureSuppressed();
- */
+
ModelLineage lineage;
try
{
@@ -432,7 +430,7 @@
// not for POMs from the repository...otherwise, we would need to be more careful with
// the last parameter here and determine whether it's appropriate for the POM to have
// an accompanying profiles.xml file.
- // profileActivationContext.setCustomActivatorFailureSuppressed( true );
+ profileActivationContext.setCustomActivatorFailureSuppressed( true );
lineage = modelLineageBuilder.buildModelLineage( pom, config, originalRemoteRepositories, false, true );
}
@@ -443,7 +441,7 @@
}
finally
{
- // profileActivationContext.setCustomActivatorFailureSuppressed( suppressActivatorFailure );
+ profileActivationContext.setCustomActivatorFailureSuppressed( suppressActivatorFailure );
}
return lineage;
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilder.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilder.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilder.java Thu Sep 18 12:59:51 2008
@@ -29,11 +29,9 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-/*
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.build.ProfileAdvisor;
-*/
import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.ModelAndFile;
@@ -69,7 +67,7 @@
private MavenTools mavenTools;
- // private ProfileAdvisor profileAdvisor;
+ private ProfileAdvisor profileAdvisor;
private ProjectWorkspace projectWorkspace;
@@ -86,6 +84,9 @@
this.artifactFactory = artifactFactory;
}
+ /**
+ * @see ModelLineageBuilder#buildModelLineage(java.io.File, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
+ */
public ModelLineage buildModelLineage( File pom,
ProjectBuilderConfiguration config,
List remoteRepositories,
@@ -182,6 +183,7 @@
* Update the remote repository set used to resolve parent POMs, by adding those declared in
* the given model to the HEAD of a new list, then appending the old remote repositories list.
* The specified pomFile is used for error reporting.
+ * @param profileManager
*/
private List updateRepositorySet( Model model,
List oldArtifactRepositories,
@@ -234,7 +236,6 @@
// getLogger().debug( "Grabbing profile-injected repositories for: " + model.getId() );
// FIXME: Find a way to pass in this context, so it's never null!
- /*
ProfileActivationContext context;
if ( config.getGlobalProfileManager() != null )
@@ -245,7 +246,7 @@
{
context = new DefaultProfileActivationContext( config.getExecutionProperties(), false );
}
- /*
+
LinkedHashSet profileRepos = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model,
pomFile,
config.getGlobalProfileManager() );
@@ -265,12 +266,14 @@
{
repositories.addAll( profileRepos );
}
- */
}
/**
* Pull the parent specification out of the given model, construct an Artifact instance, and
* resolve that artifact...then, return the resolved POM file for the parent.
+ * @param projectBuildCache
+ * @param allowStubs
+ * @param childIsReactorProject
*/
private ModelAndFile resolveParentPom( ModelAndFile child,
List remoteRepositories,
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/main/resources/META-INF/plexus/components.xml Thu Sep 18 12:59:51 2008
@@ -209,12 +209,10 @@
<requirement>
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
</requirement>
- <!--
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
<role-hint>default</role-hint>
</requirement>
- -->
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/test/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/test/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilderTest.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/test/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilderTest.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-core/src/test/java/org/apache/maven/extension/lineage/DefaultModelLineageBuilderTest.java Thu Sep 18 12:59:51 2008
@@ -28,12 +28,10 @@
import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-/*
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationContext;
-*/
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.errors.ProjectErrorReporter;
@@ -395,7 +393,7 @@
assertEquals( current.getId(), ( (Model) modelIterator.next() ).getId() );
assertEquals( parent.getId(), ( (Model) modelIterator.next() ).getId() );
}
- /*
+
public void testReadPOMWithParentInRepoBroughtInViaExternalProfile()
throws Exception
{
@@ -468,7 +466,7 @@
assertEquals( current.getId(), ( (Model) modelIterator.next() ).getId() );
assertEquals( parent.getId(), ( (Model) modelIterator.next() ).getId() );
}
- */
+
private File createTempDir( String basename )
throws IOException
{
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java Thu Sep 18 12:59:51 2008
@@ -37,12 +37,10 @@
import org.apache.maven.monitor.event.MavenWorkspaceMonitor;
import org.apache.maven.monitor.event.PerCallWorkspaceMonitor;
import org.apache.maven.plugin.Mojo;
-/*
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationContext;
-*/
import org.apache.maven.realm.DefaultMavenRealmManager;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Mirror;
@@ -134,7 +132,7 @@
profileManager( request, configuration );
processSettings( request, configuration );
-
+
return request;
}
@@ -247,7 +245,7 @@
private void processSettings( MavenExecutionRequest request,
Configuration configuration )
- { /*
+ {
ProfileManager profileManager = request.getProfileManager();
Settings settings = request.getSettings();
@@ -311,7 +309,6 @@
}
}
}
- */
}
// ------------------------------------------------------------------------
@@ -741,7 +738,7 @@
//
//
// ------------------------------------------------------------------------
- /*
+
ProfileActivationContext activationContext = request.getProfileActivationContext();
if ( activationContext == null )
{
@@ -756,7 +753,6 @@
request.setProfileManager( globalProfileManager );
request.setProfileActivationContext( activationContext );
- */
}
// ----------------------------------------------------------------------------
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java Thu Sep 18 12:59:51 2008
@@ -121,13 +121,14 @@
throw new ProjectBuildingException( projectId, e.getMessage(), pomFile, e );
}
-
+ /*
for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
{
Profile profile = (Profile) it.next();
profileInjector.inject( profile, model );
}
+ */
}
else
{
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Thu Sep 18 12:59:51 2008
@@ -115,8 +115,8 @@
throws ProjectBuildingException
{
ProjectBuilderConfiguration config =
- new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );
- // .setGlobalProfileManager( profileManager );
+ new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
+ .setGlobalProfileManager( profileManager );
return build( projectDescriptor, config );
}
@@ -127,7 +127,7 @@
MavenProject project = projectWorkspace.getProject( projectDescriptor );
if ( project == null )
- {
+ { /*
List<Profile> activeProfiles;
try
{
@@ -143,15 +143,14 @@
{
activeProfileProperties.putAll(profile.getProperties());
}
-
+ */
project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(
config.getLocalRepository(), repositoryHelper.buildArtifactRepositories(
- getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config,
- activeProfileProperties );
+ getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
project.setFile( projectDescriptor );
- project = buildMavenProject( project.getModel(), config, projectDescriptor, project.getParentFile(), activeProfiles);
+ project = buildMavenProject( project.getModel(), config, projectDescriptor, project.getParentFile(), true);
Build build = project.getBuild();
// NOTE: setting this script-source root before path translation, because
@@ -204,7 +203,7 @@
new ArrayList<ArtifactRepository>( remoteArtifactRepositories );
artifactRepositories.addAll( repositoryHelper.buildArtifactRepositories(
getSuperProject( config, artifact.getFile(), false ).getModel() ) );
-
+ /*
List<Profile> activeProfiles;
try
@@ -215,17 +214,10 @@
{
throw new ProjectBuildingException("", e.getMessage());
}
-
- Properties activeProfileProperties = new Properties();
- for(Profile profile : activeProfiles)
- {
- activeProfileProperties.putAll(profile.getProperties());
- }
-
+ */
project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver(
- config.getLocalRepository(), artifactRepositories, artifactResolver ), config, activeProfileProperties );
- project = buildMavenProject( project.getModel(), config, artifact.getFile(), project.getParentFile(),
- activeProfiles);
+ config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
+ project = buildMavenProject( project.getModel(), config, artifact.getFile(), project.getParentFile(), false);
}
artifact.setFile( f );
@@ -281,7 +273,7 @@
activeProfiles.addAll( activated );
}
}
-
+
List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getExecutionProperties(),
PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
@@ -340,7 +332,7 @@
try
{
project = constructMavenProjectFromModel( project.getModel(), null, null, config );
- // project.setActiveProfiles( activeProfiles );
+ project.setActiveProfiles( activeProfiles );
project.setRemoteArtifactRepositories(
mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
project.setPluginArtifactRepositories(
@@ -376,8 +368,8 @@
throws ProjectBuildingException
{
ProjectBuilderConfiguration config =
- new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );
- // .setGlobalProfileManager( profileManager );
+ new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
+ .setGlobalProfileManager( profileManager );
return buildProjectWithDependencies( projectDescriptor, config );
}
@@ -423,7 +415,7 @@
{
return logger;
}
-
+ /*
private List<Profile> getActiveProfilesFromModel(Model model, ProjectBuilderConfiguration config,
File projectDescriptor, boolean isReactorProject)
throws ProjectBuildingException
@@ -431,7 +423,7 @@
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
ProfileActivationContext profileActivationContext;
- /*
+
ProfileManager externalProfileManager = config.getGlobalProfileManager();
if ( externalProfileManager != null )
{
@@ -451,18 +443,18 @@
{
profileActivationContext = new DefaultProfileActivationContext( config.getExecutionProperties(), false );
}
- */
+
profileActivationContext = new DefaultProfileActivationContext( config.getExecutionProperties(), false );
List<Profile> projectProfiles = new ArrayList<Profile>();
projectProfiles.addAll( profileAdvisor.applyActivatedProfiles( model, projectDescriptor,
isReactorProject, profileActivationContext ) );
- // projectProfiles.addAll( profileAdvisor.applyActivatedExternalProfiles( model,
- // externalProfileManager ) );
+ projectProfiles.addAll( profileAdvisor.applyActivatedExternalProfiles( model, null,
+ externalProfileManager ) );
return projectProfiles;
}
-
+ */
private MavenProject buildMavenProject( Model model, ProjectBuilderConfiguration config, File projectDescriptor,
- File parentDescriptor, List<Profile> projectProfiles )
+ File parentDescriptor, boolean isReactorProject )
throws ProjectBuildingException
{
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
@@ -477,7 +469,36 @@
throw new InvalidProjectModelException( projectId, e.getMessage(), projectDescriptor, e );
}
+ ProfileActivationContext profileActivationContext;
+ ProfileManager externalProfileManager = config.getGlobalProfileManager();
+ if ( externalProfileManager != null )
+ {
+ // used to trigger the caching of SystemProperties in the container context...
+ try
+ {
+ externalProfileManager.getActiveProfiles();
+ }
+ catch ( ProfileActivationException e )
+ {
+ throw new ProjectBuildingException( projectId, "Failed to activate external profiles.",
+ projectDescriptor, e );
+ }
+ profileActivationContext = externalProfileManager.getProfileActivationContext();
+ }
+ else
+ {
+ profileActivationContext = new DefaultProfileActivationContext( config.getExecutionProperties(), false );
+ }
+
+
+
+ List<Profile> projectProfiles = new ArrayList<Profile>();
+ projectProfiles.addAll( profileAdvisor.applyActivatedProfiles( project.getModel(), project.getFile(),
+ isReactorProject, profileActivationContext ) );
+ projectProfiles.addAll( profileAdvisor.applyActivatedExternalProfiles( project.getModel(), project.getFile(),
+ externalProfileManager ) );
project.setActiveProfiles( projectProfiles );
+ //project.setActiveProfiles( projectProfiles );
projectWorkspace.storeProjectByCoordinate( project );
projectWorkspace.storeProjectByFile( project );
@@ -518,7 +539,7 @@
"Maven super-POM contains an invalid repository!", e );
}
- superProject.setActiveProfiles( getActiveProfilesFromModel(model, config, projectDescriptor, isReactorProject) );
+ // superProject.setActiveProfiles( getActiveProfilesFromModel(model, config, projectDescriptor, isReactorProject) );
return superProject;
}
@@ -573,7 +594,7 @@
}
private MavenProject readModelFromLocalPath( String projectId, File projectDescriptor, PomArtifactResolver resolver,
- ProjectBuilderConfiguration config, Properties profileProperties )
+ ProjectBuilderConfiguration config )
throws ProjectBuildingException
{
if ( projectDescriptor == null )
@@ -591,11 +612,6 @@
PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getUserProperties(),
PomInterpolatorTag.USER_PROPERTIES.name()));
- if(profileProperties != null)
- {
- interpolatorProperties.addAll(InterpolatorProperty.toInterpolatorProperties( profileProperties,
- PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
- }
if(config.getBuildStartTime() != null)
{
@@ -616,7 +632,7 @@
{
throw new ProjectBuildingException( projectId, "File = " + projectDescriptor.getAbsolutePath(), e );
}
- mavenProject.getProperties().putAll(profileProperties);
+ // mavenProject.getProperties().putAll(profileProperties);
return mavenProject;
}
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java Thu Sep 18 12:59:51 2008
@@ -24,6 +24,7 @@
import java.util.Date;
import java.util.Properties;
+import java.util.List;
public class DefaultProjectBuilderConfiguration
implements ProjectBuilderConfiguration
@@ -39,6 +40,16 @@
private Date buildStartTime;
+ public List<String> getActiveProfileIds() {
+ return activeProfileIds;
+ }
+
+ public void setActiveProfileIds(List<String> activeProfileIds) {
+ this.activeProfileIds = activeProfileIds;
+ }
+
+ private List<String> activeProfileIds;
+
public DefaultProjectBuilderConfiguration()
{
}
@@ -103,4 +114,5 @@
return this;
}
+
}
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.java Thu Sep 18 12:59:51 2008
@@ -5,6 +5,7 @@
import java.util.Date;
import java.util.Properties;
+import java.util.List;
public interface ProjectBuilderConfiguration
{
@@ -29,4 +30,8 @@
ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime );
+ List<String> getActiveProfileIds();
+
+ void setActiveProfileIds(List<String> activeProfileIds);
+
}
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java Thu Sep 18 12:59:51 2008
@@ -104,20 +104,16 @@
private static Map<String, List<ModelProperty>> cache = new HashMap<String, List<ModelProperty>>();
- private List<Profile> profiles;
+ private List<String> profiles;
//private static List<DomainModel> cache = new ArrayList<DomainModel>();
/**
* Default constructor
*/
- public PomClassicTransformer( List<Profile> profiles )
+ public PomClassicTransformer( List<String> profiles )
{
- if(profiles == null)
- {
- throw new IllegalArgumentException("profiles: null");
- }
- this.profiles = profiles;
+ this.profiles = (profiles != null) ? profiles : new ArrayList<String>();
}
/**
@@ -492,11 +488,6 @@
//Profiles
if(domainModels.indexOf(domainModel) == 0)
{
- List<String> profileIds = new ArrayList<String>();
- for(Profile profile : profiles)
- {
- profileIds.add(profile.getId());
- }
List<ModelProperty> activeProfileModelProperties = new ArrayList<ModelProperty>();
ModelDataSource source = new DefaultModelDataSource();
source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
@@ -506,9 +497,9 @@
{
for(ModelProperty mp : container.getProperties())
{
- if(mp.getUri().equals(ProjectUri.Profiles.Profile.id) && mp.getValue() != null)
+ if( mp.getValue() != null)
{
- for(String profileId : profileIds) {
+ for(String profileId : profiles) {
if(mp.getValue().equals(profileId))
{
activeProfileModelProperties.addAll(transformProfile(container.getProperties()));
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java Thu Sep 18 12:59:51 2008
@@ -52,7 +52,7 @@
* @throws IOException if there is a problem in the construction of the maven project
*/
MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedModels, Collection<ImportModel> importModels,
- Collection<InterpolatorProperty> interpolatorProperties,
+ Collection<InterpolatorProperty> interpolatorProperties,
PomArtifactResolver resolver, File baseDirectory,
ProjectBuilderConfiguration projectBuilderConfiguration )
throws IOException;
Modified: maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java?rev=696784&r1=696783&r2=696784&view=diff
==============================================================================
--- maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java (original)
+++ maven/components/branches/sisbell-maven-3.0-profile/maven-project/src/main/java/org/apache/maven/project/builder/impl/DefaultProjectBuilder.java Thu Sep 18 12:59:51 2008
@@ -175,16 +175,9 @@
PomClassicTransformer transformer;
- // try
- // {
- List<Profile> activeProfiles = new ArrayList<Profile>();
- //( projectBuilderConfiguration.getGlobalProfileManager() != null)
- //? projectBuilderConfiguration.getGlobalProfileManager().getActiveProfiles(domainModel.getModel()) : new ArrayList<Profile>() ;
- transformer = new PomClassicTransformer(activeProfiles);
- // } catch (ProfileActivationException e)
- // {
- // throw new IOException(e.getMessage());
- // }
+
+ transformer = new PomClassicTransformer(projectBuilderConfiguration.getActiveProfileIds());
+
ModelTransformerContext ctx = new ModelTransformerContext(
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );