You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/10/19 18:02:32 UTC
svn commit: r586515 - in /maven/components/trunk:
maven-core/src/main/java/org/apache/maven/execution/
maven-core/src/main/java/org/apache/maven/lifecycle/
maven-core/src/main/java/org/apache/maven/plugin/
maven-project/src/main/java/org/apache/maven/p...
Author: jdcasey
Date: Fri Oct 19 09:02:31 2007
New Revision: 586515
URL: http://svn.apache.org/viewvc?rev=586515&view=rev
Log:
Plugins now load per-project, which means they can have different plugin-level dependencies and configurations per-project, even if they're running in the same reactor.
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionException.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginContainerException.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java?rev=586515&r1=586514&r2=586515&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java Fri Oct 19 09:02:31 2007
@@ -25,6 +25,7 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.Date;
@@ -70,11 +71,20 @@
this.projectSessions = projectSessions;
}
+ // TODO: Figure out how/when we can shut down all the realms for extensions/plugins connected to each project session...
public MavenProjectSession getProjectSession( MavenProject project )
+ throws PlexusContainerException
{
String id = MavenProjectSession.createProjectId( project.getGroupId(), project.getArtifactId(), project.getVersion() );
- return (MavenProjectSession) projectSessions.get( id );
+ MavenProjectSession projectSession = (MavenProjectSession) projectSessions.get( id );
+ if ( projectSession == null )
+ {
+ projectSession = new MavenProjectSession( id, container );
+ projectSessions.put( id, projectSession );
+ }
+
+ return projectSession;
}
public Map getPluginContext( PluginDescriptor pluginDescriptor,
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=586515&r1=586514&r2=586515&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Fri Oct 19 09:02:31 2007
@@ -57,6 +57,7 @@
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
@@ -146,7 +147,7 @@
session,
rootProject );
- // TODO: probably don't want to do all this up front
+ // FIXME: This should be handled by the extension scanner.
try
{
Map handlers = findArtifactTypeHandlers( session );
@@ -157,6 +158,7 @@
{
throw new LifecycleExecutionException(
"Plugin could not be not found while searching for artifact-type handlers.",
+ rootProject,
e );
}
@@ -400,8 +402,20 @@
private ClassRealm setProjectLookupRealm( MavenSession session,
MavenProject rootProject )
+ throws LifecycleExecutionException
{
- MavenProjectSession projectSession = session.getProjectSession( rootProject );
+ MavenProjectSession projectSession;
+ try
+ {
+ projectSession = session.getProjectSession( rootProject );
+ }
+ catch ( PlexusContainerException e )
+ {
+ throw new LifecycleExecutionException(
+ "Failed to create project-specific session for: "
+ + rootProject.getId(),
+ rootProject, e );
+ }
if ( projectSession != null )
{
return container.setLookupRealm( projectSession.getProjectRealm() );
@@ -443,7 +457,7 @@
{
throw new LifecycleExecutionException(
"Failed to construct build plan for: " + targetDescription
- + ". Reason: " + e.getMessage(),
+ + ". Reason: " + e.getMessage(), project,
e );
}
@@ -488,6 +502,7 @@
throw new LifecycleExecutionException(
"Failed to load plugin for: "
+ MojoBindingUtils.toString( mojoBinding ) + ". Reason: " + e.getMessage(),
+ project,
e );
}
}
@@ -511,36 +526,42 @@
throw new LifecycleExecutionException(
"Internal error in the plugin manager executing goal '"
+ mojoDescriptor.getId() + "': " + e.getMessage(),
+ project,
e );
}
catch ( ArtifactNotFoundException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( InvalidDependencyVersionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( ArtifactResolutionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( MojoExecutionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( PluginConfigurationException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
}
@@ -548,7 +569,7 @@
{
throw new LifecycleExecutionException(
"Failed to load plugin for: "
- + MojoBindingUtils.toString( mojoBinding ) + ". Reason: unknown" );
+ + MojoBindingUtils.toString( mojoBinding ) + ". Reason: unknown", project );
}
}
catch ( LifecycleExecutionException e )
@@ -789,6 +810,7 @@
throw new LifecycleExecutionException(
"Error looking up available components from plugin '"
+ plugin.getKey() + "': " + e.getMessage(),
+ project,
e );
}
@@ -827,36 +849,42 @@
throw new LifecycleExecutionException(
"Internal error in the plugin manager getting plugin '"
+ plugin.getKey() + "': " + e.getMessage(),
+ project,
e );
}
catch ( PluginVersionResolutionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( InvalidPluginException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( ArtifactNotFoundException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( ArtifactResolutionException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
catch ( PluginVersionNotFoundException e )
{
throw new LifecycleExecutionException(
e.getMessage(),
+ project,
e );
}
return pluginDescriptor;
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionException.java?rev=586515&r1=586514&r2=586515&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionException.java Fri Oct 19 09:02:31 2007
@@ -11,7 +11,9 @@
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.codehaus.plexus.PlexusContainerException;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -39,87 +41,116 @@
public class LifecycleExecutionException
extends Exception
{
- public LifecycleExecutionException( String message )
+ private final MavenProject project;
+
+ public LifecycleExecutionException( String message, MavenProject project )
{
super( message );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
PluginManagerException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
PluginNotFoundException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
PluginVersionResolutionException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
InvalidVersionSpecificationException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
InvalidPluginException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
ArtifactNotFoundException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
ArtifactResolutionException cause )
{
super( message, cause );
+ this.project = project;
}
public LifecycleExecutionException( String message,
- PluginLoaderException cause )
+ MavenProject project, PluginLoaderException cause )
{
super( message, cause );
+ this.project = project;
}
public LifecycleExecutionException( String message,
- LifecycleException cause )
+ MavenProject project, LifecycleException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
InvalidDependencyVersionException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
MojoExecutionException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
PluginConfigurationException cause )
{
super( message, cause );
+ this.project = project;
}
- public LifecycleExecutionException( String message,
+ public LifecycleExecutionException( String message, MavenProject project,
PluginVersionNotFoundException cause )
{
super( message, cause );
+ this.project = project;
+ }
+
+ public LifecycleExecutionException( String message,
+ MavenProject project,
+ PlexusContainerException cause )
+ {
+ super( message, cause );
+ this.project = project;
+ }
+
+ public MavenProject getProject()
+ {
+ return project;
}
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=586515&r1=586514&r2=586515&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Fri Oct 19 09:02:31 2007
@@ -347,30 +347,31 @@
ClassRealm pluginRealm = null;
- // if we have a project session, it must mean we have extensions...
- // which in turn may alter the execution of a plugin.
- MavenProjectSession projectSession = session.getProjectSession( project );
- if ( projectSession != null )
+ MavenProjectSession projectSession;
+ try
{
- try
- {
- pluginRealm = projectSession.getPluginRealm( projectPlugin );
- }
- catch ( NoSuchRealmException e )
- {
- getLogger().debug( "Plugin realm is missing for: " + projectPlugin.getKey() + ". New realm will be created." );
- }
+ projectSession = session.getProjectSession( project );
}
- else
+ catch ( PlexusContainerException e )
{
- pluginRealm = container.getComponentRealm( key );
+ throw new PluginManagerException( plugin, "Failed to create project-specific session for project: " + project.getId()
+ + ".", project, e );
+ }
+
+ try
+ {
+ pluginRealm = projectSession.getPluginRealm( projectPlugin );
+ }
+ catch ( NoSuchRealmException e )
+ {
+ getLogger().debug( "Plugin realm is missing for: " + projectPlugin.getKey() + ". New realm will be created." );
}
if ( ( pluginRealm != null ) && ( pluginRealm != container.getContainerRealm() ) )
{
getLogger().debug(
"Realm already exists for: " + key
- + ". Skipping addition..." );
+ + " (realm id: " + pluginRealm.getId() + "). Skipping addition..." );
// we've already discovered this plugin, and configured it, so skip it this time.
return;
@@ -384,70 +385,45 @@
try
{
- if ( projectSession != null )
+ pluginRealm = projectSession.createPluginRealm( projectPlugin );
+
+ try
{
- pluginRealm = projectSession.createPluginRealm( projectPlugin );
+ pluginRealm.addURL( pluginArtifact.getFile().toURI().toURL() );
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new PluginContainerException( plugin, pluginRealm, "Error rendering plugin artifact: " + pluginArtifact.getId() + " as URL.", e );
+ }
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
try
{
- pluginRealm.addURL( pluginArtifact.getFile().toURI().toURL() );
+ getLogger().debug( "Adding: " + artifact.getId() + " to plugin class-realm: " + key + " in project-session: " + project.getId() );
+ pluginRealm.addURL( artifact.getFile().toURI().toURL() );
}
catch ( MalformedURLException e )
{
- throw new PluginContainerException( plugin, pluginRealm, "Error rendering plugin artifact: " + pluginArtifact.getId() + " as URL.", e );
- }
-
- for ( Iterator i = artifacts.iterator(); i.hasNext(); )
- {
- Artifact artifact = (Artifact) i.next();
-
- try
- {
- getLogger().debug( "Adding: " + artifact.getId() + " to plugin class-realm: " + key + " in project-session: " + project.getId() );
- pluginRealm.addURL( artifact.getFile().toURI().toURL() );
- }
- catch ( MalformedURLException e )
- {
- throw new PluginContainerException( plugin, pluginRealm, "Error rendering plugin artifact: " + artifact.getId() + " as URL.", e );
- }
+ throw new PluginContainerException( plugin, pluginRealm, "Error rendering plugin artifact: " + artifact.getId() + " as URL.", e );
}
+ }
- try
- {
- getLogger().debug( "Discovering components in realm: " + pluginRealm );
- container.discoverComponents( pluginRealm, false );
- }
- catch ( PlexusConfigurationException e )
- {
- throw new PluginContainerException( plugin, pluginRealm, "Error re-scanning project realm for components.", e );
- }
- catch ( ComponentRepositoryException e )
- {
- throw new PluginContainerException( plugin, pluginRealm, "Error re-scanning project realm for components.", e );
- }
+ try
+ {
+ getLogger().debug( "Discovering components in realm: " + pluginRealm );
+ container.discoverComponents( pluginRealm, false );
}
- else
+ catch ( PlexusConfigurationException e )
{
- List jars = new ArrayList();
-
- for ( Iterator i = artifacts.iterator(); i.hasNext(); )
- {
- Artifact artifact = (Artifact) i.next();
-
- jars.add( artifact.getFile() );
- }
-
- jars.add( pluginArtifact.getFile() );
-
- // Now here we need the artifact coreArtifactFilter stuff
- pluginRealm = container.createComponentRealm( key, jars );
+ throw new PluginContainerException( plugin, pluginRealm, "Error re-scanning project realm for components.", e );
+ }
+ catch ( ComponentRepositoryException e )
+ {
+ throw new PluginContainerException( plugin, pluginRealm, "Error re-scanning project realm for components.", e );
}
-
- }
- catch ( PlexusContainerException e )
- {
- throw new PluginContainerException( plugin, pluginRealm, "Failed to create realm for plugin '" + projectPlugin
- + ".", e );
}
catch ( DuplicateRealmException e )
{
@@ -687,12 +663,15 @@
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
ClassRealm pluginRealm = pluginDescriptor.getClassRealm();
+ ClassRealm oldRealm = null;
try
{
+ getLogger().debug( "Setting lookup realm and context classloader for plugin to: " + pluginRealm.getId() + " (instance is: " + pluginRealm + ")" );
+
Thread.currentThread().setContextClassLoader( pluginRealm );
- ClassRealm oldRealm = container.setLookupRealm( pluginRealm );
+ oldRealm = container.setLookupRealm( pluginRealm );
plugin.execute();
@@ -710,8 +689,6 @@
ctx.store( buildContextManager );
}
- container.setLookupRealm( oldRealm );
-
dispatcher.dispatchEnd( event, goalExecId );
}
catch ( MojoExecutionException e )
@@ -728,6 +705,10 @@
}
finally
{
+ if ( oldRealm != null )
+ {
+ container.setLookupRealm( oldRealm );
+ }
Thread.currentThread().setContextClassLoader( oldClassLoader );
}
@@ -801,90 +782,62 @@
ClassRealm realm = null;
- MavenProjectSession projectSession = session.getProjectSession( project );
- if ( projectSession != null )
+ MavenProjectSession projectSession;
+ try
{
- try
- {
- realm = projectSession.getPluginRealm( pluginDescriptor );
- }
- catch ( NoSuchRealmException e )
- {
- throw new PluginManagerException( mojoDescriptor, project, "Plugin realm: " + pluginDescriptor.getId() + " not found in project session for: " + project.getId(), e );
- }
+ projectSession = session.getProjectSession( project );
}
- else
+ catch ( PlexusContainerException e )
{
- realm = mojoDescriptor.getPluginDescriptor().getClassRealm();
+ throw new PluginManagerException( mojoDescriptor, "Failed to create project-specific session for project: " + project.getId()
+ + ".", project, e );
+ }
+
+ try
+ {
+ realm = projectSession.getPluginRealm( pluginDescriptor );
+ }
+ catch ( NoSuchRealmException e )
+ {
+ getLogger().debug( "Plugin realm: " + pluginDescriptor.getId() + " not found in project session for: " + project.getId() + ". Using project realm instead." );
+ realm = projectSession.getProjectRealm();
}
// We are forcing the use of the plugin realm for all lookups that might occur during
// the lifecycle that is part of the lookup. Here we are specifically trying to keep
// lookups that occur in contextualize calls in line with the right realm.
- if ( realm != null )
- {
- ClassRealm oldRealm = container.setLookupRealm( realm );
-
- getLogger().debug(
- "Looking up mojo " + mojoDescriptor.getRoleHint() + " in realm "
- + realm.getId() + " - descRealmId="
- + mojoDescriptor.getRealmId() );
+ ClassRealm oldRealm = container.setLookupRealm( realm );
- try
- {
- plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint(), realm );
- }
- catch ( ComponentLookupException e )
- {
- throw new PluginContainerException( mojoDescriptor, realm, "Unable to find the mojo '"
- + mojoDescriptor.getRoleHint() + "' in the plugin '"
- + pluginDescriptor.getPluginLookupKey() + "'", e );
- }
-
- if ( plugin != null )
- {
- getLogger().debug(
- "Looked up - " + plugin + " - "
- + plugin.getClass().getClassLoader() );
- }
- else
- {
- getLogger().warn( "No luck." );
- }
+ getLogger().debug(
+ "Looking up mojo " + mojoDescriptor.getRoleHint() + " in realm "
+ + realm.getId() + " - descRealmId="
+ + mojoDescriptor.getRealmId() );
+ try
+ {
+ plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint(), realm );
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new PluginContainerException( mojoDescriptor, realm, "Unable to find the mojo '"
+ + mojoDescriptor.getRoleHint() + "' in the plugin '"
+ + pluginDescriptor.getPluginLookupKey() + "'", e );
+ }
+ finally
+ {
container.setLookupRealm( oldRealm );
}
+
+ if ( plugin != null )
+ {
+ getLogger().debug(
+ "Looked up - " + plugin + " - "
+ + plugin.getClass().getClassLoader() );
+ }
else
{
- getLogger().info(
- "Looking up mojo " + mojoDescriptor.getRoleHint()
- + " in default realm "
- + container.getLookupRealm() + " - descRealmId="
- + mojoDescriptor.getRealmId() );
-
- try
- {
- plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
- }
- catch ( ComponentLookupException e )
- {
- throw new PluginContainerException( mojoDescriptor, container.getContainerRealm(), "Unable to find the mojo '"
- + mojoDescriptor.getRoleHint() + "' in the plugin '"
- + pluginDescriptor.getPluginLookupKey() + "' (using core class realm)", e );
- }
-
- if ( plugin != null )
- {
- getLogger().info(
- "Looked up - " + plugin + " - "
- + plugin.getClass().getClassLoader() );
- }
- else
- {
- getLogger().warn( "No luck." );
- }
-
+ getLogger().warn( "No luck." );
}
if ( report && !( plugin instanceof MavenReport ) )
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginContainerException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginContainerException.java?rev=586515&r1=586514&r2=586515&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginContainerException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginContainerException.java Fri Oct 19 09:02:31 2007
@@ -2,7 +2,6 @@
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
@@ -42,16 +41,6 @@
ClassRealm pluginRealm,
String message,
NoSuchRealmException e )
- {
- super( plugin, message, e );
-
- this.pluginRealm = pluginRealm;
- }
-
- public PluginContainerException( Plugin plugin,
- ClassRealm pluginRealm,
- String message,
- PlexusContainerException e )
{
super( plugin, message, e );
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java?rev=586515&r1=586514&r2=586515&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java Fri Oct 19 09:02:31 2007
@@ -3,6 +3,7 @@
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
@@ -54,10 +55,12 @@
protected PluginManagerException( Plugin plugin,
String message,
+ MavenProject project,
PlexusContainerException cause )
{
super( message, cause );
+ this.project = project;
pluginGroupId = plugin.getGroupId();
pluginArtifactId = plugin.getArtifactId();
pluginVersion = plugin.getVersion();
@@ -149,6 +152,23 @@
pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
+ goal = mojoDescriptor.getGoal();
+ }
+
+ public PluginManagerException( MojoDescriptor mojoDescriptor,
+ String message,
+ MavenProject project,
+ PlexusContainerException cause )
+ {
+ super( message, cause );
+
+ this.project = project;
+
+ PluginDescriptor pd = mojoDescriptor.getPluginDescriptor();
+ pluginGroupId = pd.getGroupId();
+ pluginArtifactId = pd.getArtifactId();
+ pluginVersion = pd.getVersion();
+
goal = mojoDescriptor.getGoal();
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java?rev=586515&r1=586514&r2=586515&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java Fri Oct 19 09:02:31 2007
@@ -22,6 +22,9 @@
import org.apache.maven.context.SystemBuildContext;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Profile;
+import org.codehaus.plexus.logging.LogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.codehaus.plexus.util.StringUtils;
import java.util.ArrayList;
@@ -29,9 +32,11 @@
public class JdkPrefixProfileActivator
extends DetectedProfileActivator
+ implements LogEnabled
{
public static final String JDK_VERSION = "java.version";
+ private Logger logger;
public boolean isActive( Profile profile )
{
@@ -41,6 +46,11 @@
SystemBuildContext systemContext = SystemBuildContext.getSystemBuildContext( getBuildContextManager(), true );
String javaVersion = systemContext.getSystemProperty( JDK_VERSION );
+ if ( javaVersion == null )
+ {
+ getLogger().warn( "Cannot locate java version property in SystemBuildContext: " + JDK_VERSION + ". NOT enabling profile: " + profile.getId() );
+ return false;
+ }
return isActive( javaVersion, jdk );
}
@@ -141,5 +151,20 @@
}
}
return 0;
+ }
+
+ protected Logger getLogger()
+ {
+ if ( logger == null )
+ {
+ logger = new ConsoleLogger( Logger.LEVEL_INFO, "jdk-activator internal" );
+ }
+
+ return logger;
+ }
+
+ public void enableLogging( Logger logger )
+ {
+ this.logger = logger;
}
}