From 9bc9c862318f5b97da32efeb69a2b8a124914e66 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Sun, 30 Nov 2008 01:46:13 +0000 Subject: [PATCH] o use annos where possible git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@721750 13f79535-47bb-0310-9956-ffa450edef68 --- maven-embedder/pom.xml | 22 ++------- ...DefaultMavenExecutionRequestPopulator.java | 47 ++++++++----------- .../resources/META-INF/plexus/components.xml | 27 ++--------- 3 files changed, 26 insertions(+), 70 deletions(-) diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 64590907ad..3d1c11287e 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -74,6 +74,10 @@ + + org.codehaus.plexus + plexus-component-metadata + maven-surefire-plugin @@ -84,22 +88,4 @@ - - - - st - - - - maven-surefire-plugin - - - **/MavenEmbedderTest.java - - - - - - - diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java index 2327678b0c..65eee0f3e1 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java @@ -19,6 +19,12 @@ package org.apache.maven.embedder.execution; * under the License. */ +import java.io.File; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + import org.apache.maven.Maven; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -34,7 +40,6 @@ import org.apache.maven.model.Profile; import org.apache.maven.model.Repository; import org.apache.maven.monitor.event.DefaultEventMonitor; import org.apache.maven.monitor.event.EventMonitor; -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; @@ -48,24 +53,19 @@ import org.apache.maven.settings.Settings; import org.apache.maven.settings.SettingsConfigurationException; import org.apache.maven.settings.SettingsUtils; import org.apache.maven.wagon.repository.RepositoryPermissions; -import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.MutablePlexusContainer; +import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.io.File; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - /** * Things that we deal with in this populator to ensure that we have a valid {@MavenExecutionRequest} *

@@ -80,19 +80,24 @@ import java.util.Properties; * * @version $Id$ */ +@Component(role = MavenExecutionRequestPopulator.class) public class DefaultMavenExecutionRequestPopulator extends AbstractLogEnabled - implements MavenExecutionRequestPopulator, - Contextualizable + implements MavenExecutionRequestPopulator { + @Requirement private ArtifactRepositoryFactory artifactRepositoryFactory; + @Requirement private ArtifactRepositoryLayout defaultArtifactRepositoryLayout; - private MutablePlexusContainer container; + @Requirement + private PlexusContainer container; + @Requirement private WagonManager wagonManager; + @Requirement private MavenSettingsBuilder settingsBuilder; public MavenExecutionRequest populateDefaults( MavenExecutionRequest request, @@ -657,15 +662,11 @@ public class DefaultMavenExecutionRequestPopulator // // ------------------------------------------------------------------------ - Logger logger = container.getLoggerManager().getLoggerForComponent( Mojo.ROLE ); - if ( ( request.getEventMonitors() == null ) || request.getEventMonitors().isEmpty() ) { - request.addEventMonitor( new DefaultEventMonitor( logger ) ); + request.addEventMonitor( new DefaultEventMonitor( getLogger() ) ); } - container.getLoggerManager().setThreshold( request.getLoggingLevel() ); - // Now, add in any event monitors from the Configuration instance. List configEventMonitors = configuration.getEventMonitors(); @@ -707,14 +708,4 @@ public class DefaultMavenExecutionRequestPopulator request.setProfileManager( globalProfileManager ); request.setProfileActivationContext( activationContext ); } - - // ---------------------------------------------------------------------------- - // Lifecycle - // ---------------------------------------------------------------------------- - - public void contextualize( Context context ) - throws ContextException - { - container = (MutablePlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); - } } diff --git a/maven-embedder/src/main/resources/META-INF/plexus/components.xml b/maven-embedder/src/main/resources/META-INF/plexus/components.xml index 7eba653420..0cf45b2067 100644 --- a/maven-embedder/src/main/resources/META-INF/plexus/components.xml +++ b/maven-embedder/src/main/resources/META-INF/plexus/components.xml @@ -19,27 +19,6 @@ under the License. - - org.apache.maven.embedder.execution.MavenExecutionRequestPopulator - org.apache.maven.embedder.execution.DefaultMavenExecutionRequestPopulator - - - org.apache.maven.artifact.manager.WagonManager - default - - - org.apache.maven.settings.MavenSettingsBuilder - - - org.apache.maven.artifact.repository.ArtifactRepositoryFactory - - - org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout - default - - - - org.apache.maven.wagon.Wagon http @@ -51,7 +30,7 @@ under the License. User-Agent - Apache-Maven/${project.version} maven-artifact/${artifactVersion} + Apache-Maven/${project.version} @@ -61,13 +40,13 @@ under the License. https org.apache.maven.wagon.providers.http.LightweightHttpsWagon per-lookup - LIghtweightHttpsWagon + LightweightHttpsWagon false User-Agent - Apache-Maven/${project.version} maven-artifact/${artifactVersion} + Apache-Maven/${project.version}