You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/01/22 22:44:46 UTC

[maven] 03/04: [MNG-5577] Migrate to JSR 300 Annotations - maven-embedder

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MNG-5577
in repository https://gitbox.apache.org/repos/asf/maven.git

commit cc19ae794fccbe0ebf160d26663ea28cf7606c19
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Jan 11 03:19:11 2019 +0100

    [MNG-5577] Migrate to JSR 300 Annotations - maven-embedder
---
 maven-embedder/pom.xml                             |  8 ------
 .../SettingsXmlConfigurationProcessor.java         | 31 ++++++++++++----------
 maven-embedder/src/site/apt/logging.apt            | 15 ++++++-----
 3 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 33cbabc..7ec7de9 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -100,10 +100,6 @@ under the License.
       <artifactId>org.eclipse.sisu.plexus</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-component-annotations</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.sonatype.plexus</groupId>
       <artifactId>plexus-sec-dispatcher</artifactId>
     </dependency>
@@ -175,10 +171,6 @@ under the License.
         <artifactId>sisu-maven-plugin</artifactId>
       </plugin>
       <plugin>
-        <groupId>org.codehaus.plexus</groupId>
-        <artifactId>plexus-component-metadata</artifactId>
-      </plugin>
-      <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
         <configuration>
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
index 2536a22..507be75 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
@@ -43,14 +43,18 @@ import org.apache.maven.settings.building.SettingsBuildingRequest;
 import org.apache.maven.settings.building.SettingsBuildingResult;
 import org.apache.maven.settings.building.SettingsProblem;
 import org.apache.maven.settings.crypto.SettingsDecrypter;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
 
 /**
  * SettingsXmlConfigurationProcessor
  */
-@Component( role = ConfigurationProcessor.class, hint = SettingsXmlConfigurationProcessor.HINT )
+@Named ( SettingsXmlConfigurationProcessor.HINT )
+@Singleton
 public class SettingsXmlConfigurationProcessor
     implements ConfigurationProcessor
 {
@@ -65,13 +69,12 @@ public class SettingsXmlConfigurationProcessor
     public static final File DEFAULT_GLOBAL_SETTINGS_FILE =
         new File( System.getProperty( "maven.conf" ), "settings.xml" );
 
-    @Requirement
-    private Logger logger;
+    private static final Logger LOGGER = LoggerFactory.getLogger( SettingsXmlConfigurationProcessor.class );
 
-    @Requirement
+    @Inject
     private SettingsBuilder settingsBuilder;
 
-    @Requirement
+    @Inject
     private SettingsDecrypter settingsDecrypter;
 
     @Override
@@ -132,9 +135,9 @@ public class SettingsXmlConfigurationProcessor
             request.getEventSpyDispatcher().onEvent( settingsRequest );
         }
 
-        logger.debug( "Reading global settings from "
+        LOGGER.debug( "Reading global settings from "
             + getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
-        logger.debug( "Reading user settings from "
+        LOGGER.debug( "Reading user settings from "
             + getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
 
         SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
@@ -146,16 +149,16 @@ public class SettingsXmlConfigurationProcessor
 
         populateFromSettings( request, settingsResult.getEffectiveSettings() );
 
-        if ( !settingsResult.getProblems().isEmpty() && logger.isWarnEnabled() )
+        if ( !settingsResult.getProblems().isEmpty() && LOGGER.isWarnEnabled() )
         {
-            logger.warn( "" );
-            logger.warn( "Some problems were encountered while building the effective settings" );
+            LOGGER.warn( "" );
+            LOGGER.warn( "Some problems were encountered while building the effective settings" );
 
             for ( SettingsProblem problem : settingsResult.getProblems() )
             {
-                logger.warn( problem.getMessage() + " @ " + problem.getLocation() );
+                LOGGER.warn( problem.getMessage() + " @ " + problem.getLocation() );
             }
-            logger.warn( "" );
+            LOGGER.warn( "" );
         }
     }
 
diff --git a/maven-embedder/src/site/apt/logging.apt b/maven-embedder/src/site/apt/logging.apt
index 800857c..9bf8e3c 100644
--- a/maven-embedder/src/site/apt/logging.apt
+++ b/maven-embedder/src/site/apt/logging.apt
@@ -64,21 +64,24 @@ Maven Logging
 
 * Getting Logger Instance
 
- Plexus Logger and LoggerManager can be injected in Plexus component using Plexus annotations
+ Plexus Logger and LoggerManager can be injected into component using JSR 300 annotations
 
 +------+
 import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
 
-@Component( role = MyComponent.class )
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+@Named
+@Singleton
 public class DefaultMyComponent
     implements MyComponent
 {
-    @Requirement
+    @Inject
     private Logger logger;
 
-    @Requirement
+    @Inject
     private LoggerManager loggerManager;
 }
 +------+