You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2019/06/21 21:58:26 UTC

[maven] branch MNG-6686 updated (b6edab7 -> 59bd396)

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

michaelo pushed a change to branch MNG-6686
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard b6edab7  [MNG-6686] Convert Maven Embedder to JSR 330
     new 59bd396  [MNG-6686] Convert Maven Embedder to JSR 330

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (b6edab7)
            \
             N -- N -- N   refs/heads/MNG-6686 (59bd396)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cli/configuration/SettingsXmlConfigurationProcessor.java   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)


[maven] 01/01: [MNG-6686] Convert Maven Embedder to JSR 330

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

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

    [MNG-6686] Convert Maven Embedder to JSR 330
    
    This closes #257
---
 maven-embedder/pom.xml                             |  8 -----
 .../org/apache/maven/cli/CLIReportingUtils.java    |  2 +-
 .../main/java/org/apache/maven/cli/MavenCli.java   | 35 +++++++++++-----------
 .../SettingsXmlConfigurationProcessor.java         | 35 ++++++++++++----------
 .../maven/cli/event/ExecutionEventLogger.java      | 12 ++++----
 .../impl/UnsupportedSlf4jBindingConfiguration.java |  2 +-
 .../cli/transfer/Slf4jMavenTransferListener.java   |  4 +--
 maven-embedder/src/site/apt/logging.apt            | 24 ++-------------
 8 files changed, 48 insertions(+), 74 deletions(-)

diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index a6757fb..33fd43a 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/CLIReportingUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
index e1a4c2f..fb78239 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
@@ -146,7 +146,7 @@ public final class CLIReportingUtils
 
                 for ( Throwable cause = e.getCause(); cause != null; cause = cause.getCause() )
                 {
-                    logger.error( "Caused by: " + cause.getMessage() );
+                    logger.error( "Caused by: {}", cause.getMessage() );
                 }
             }
         }
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 4ee6aa8..ff5fcc7 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -569,7 +569,7 @@ public class MavenCli
 
         if ( slf4jLogger.isDebugEnabled() )
         {
-            slf4jLogger.debug( "Message scheme: " + ( MessageUtils.isColorEnabled() ? "color" : "plain" ) );
+            slf4jLogger.debug( "Message scheme: {}", ( MessageUtils.isColorEnabled() ? "color" : "plain" ) );
             if ( MessageUtils.isColorEnabled() )
             {
                 MessageBuilder buff = MessageUtils.buffer();
@@ -767,7 +767,7 @@ public class MavenCli
         }
         catch ( Exception e )
         {
-            slf4jLogger.warn( "Failed to read extensions descriptor " + extensionsFile + ": " + e.getMessage() );
+            slf4jLogger.warn( "Failed to read extensions descriptor {}: {}", extensionsFile, e.getMessage() );
         }
         return Collections.emptyList();
     }
@@ -795,11 +795,11 @@ public class MavenCli
 
             extRealm.setParentRealm( coreRealm );
 
-            slf4jLogger.debug( "Populating class realm " + extRealm.getId() );
+            slf4jLogger.debug( "Populating class realm {}", extRealm.getId() );
 
             for ( File file : extClassPath )
             {
-                slf4jLogger.debug( "  Included " + file );
+                slf4jLogger.debug( "  Included {}", file );
 
                 extRealm.addURL( file.toURI().toURL() );
             }
@@ -848,7 +848,7 @@ public class MavenCli
             {
                 File file = resolveFile( new File( jar ), cliRequest.workingDirectory );
 
-                slf4jLogger.debug( "  Included " + file );
+                slf4jLogger.debug( "  Included {}", file );
 
                 jars.add( file );
             }
@@ -983,13 +983,13 @@ public class MavenCli
 
             if ( !cliRequest.showErrors )
             {
-                slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the "
-                    + buffer().strong( "-e" ) + " switch." );
+                slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the {} switch.",
+                        buffer().strong( "-e" ) );
             }
             if ( !slf4jLogger.isDebugEnabled() )
             {
-                slf4jLogger.error( "Re-run Maven using the " + buffer().strong( "-X" )
-                    + " switch to enable full debug logging." );
+                slf4jLogger.error( "Re-run Maven using the {} switch to enable full debug logging.",
+                        buffer().strong( "-X" ) );
             }
 
             if ( !references.isEmpty() )
@@ -1000,7 +1000,7 @@ public class MavenCli
 
                 for ( Map.Entry<String, String> entry : references.entrySet() )
                 {
-                    slf4jLogger.error( buffer().strong( entry.getValue() ) + " " + entry.getKey() );
+                    slf4jLogger.error( "{} {}", buffer().strong( entry.getValue() ), entry.getKey() );
                 }
             }
 
@@ -1257,11 +1257,10 @@ public class MavenCli
 
         eventSpyDispatcher.onEvent( toolchainsRequest );
 
-        slf4jLogger.debug(
-            "Reading global toolchains from " + getLocation( toolchainsRequest.getGlobalToolchainsSource(),
-                                                             globalToolchainsFile ) );
-        slf4jLogger.debug( "Reading user toolchains from " + getLocation( toolchainsRequest.getUserToolchainsSource(),
-                                                                          userToolchainsFile ) );
+        slf4jLogger.debug( "Reading global toolchains from {}",
+                getLocation( toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile ) );
+        slf4jLogger.debug( "Reading user toolchains from {}",
+                getLocation( toolchainsRequest.getUserToolchainsSource(), userToolchainsFile ) );
 
         ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest );
 
@@ -1277,7 +1276,7 @@ public class MavenCli
 
             for ( Problem problem : toolchainsResult.getProblems() )
             {
-                slf4jLogger.warn( problem.getMessage() + " @ " + problem.getLocation() );
+                slf4jLogger.warn( "{} @ {}", problem.getMessage(), problem.getLocation() );
             }
 
             slf4jLogger.warn( "" );
@@ -1311,8 +1310,8 @@ public class MavenCli
         {
             if ( commandLine.hasOption( deprecatedOption ) )
             {
-                slf4jLogger.warn( "Command line option -" + deprecatedOption
-                                      + " is deprecated and will be removed in future Maven versions." );
+                slf4jLogger.warn( "Command line option -{} is deprecated and will be removed in future Maven versions.",
+                        deprecatedOption );
             }
         }
 
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..0a862c4 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
@@ -23,6 +23,10 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.util.List;
 
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
 import org.apache.commons.cli.CommandLine;
 import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.bridge.MavenRepositorySystem;
@@ -43,14 +47,14 @@ 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;
 
 /**
  * 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 final Logger logger = LoggerFactory.getLogger( SettingsXmlConfigurationProcessor.class );
 
-    @Requirement
+    @Inject
     private SettingsBuilder settingsBuilder;
 
-    @Requirement
+    @Inject
     private SettingsDecrypter settingsDecrypter;
 
     @Override
@@ -132,10 +135,10 @@ public class SettingsXmlConfigurationProcessor
             request.getEventSpyDispatcher().onEvent( settingsRequest );
         }
 
-        logger.debug( "Reading global settings from "
-            + getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
-        logger.debug( "Reading user settings from "
-            + getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
+        logger.debug( "Reading global settings from {}",
+            getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
+        logger.debug( "Reading user settings from {}",
+            getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
 
         SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
 
@@ -153,7 +156,7 @@ public class SettingsXmlConfigurationProcessor
 
             for ( SettingsProblem problem : settingsResult.getProblems() )
             {
-                logger.warn( problem.getMessage() + " @ " + problem.getLocation() );
+                logger.warn( "{} @ {}", problem.getMessage(), problem.getLocation() );
             }
             logger.warn( "" );
         }
@@ -234,7 +237,7 @@ public class SettingsXmlConfigurationProcessor
                 {
                     try
                     {
-                        request.addRemoteRepository( 
+                        request.addRemoteRepository(
                             MavenRepositorySystem.buildArtifactRepository( remoteRepository ) );
                     }
                     catch ( InvalidRepositoryException e )
@@ -242,20 +245,20 @@ public class SettingsXmlConfigurationProcessor
                         // do nothing for now
                     }
                 }
-                
+
                 List<Repository> pluginRepositories = rawProfile.getPluginRepositories();
                 for ( Repository pluginRepository : pluginRepositories )
                 {
                     try
                     {
-                        request.addPluginArtifactRepository( 
+                        request.addPluginArtifactRepository(
                             MavenRepositorySystem.buildArtifactRepository( pluginRepository ) );
                     }
                     catch ( InvalidRepositoryException e )
                     {
                         // do nothing for now
                     }
-                }                
+                }
             }
         }
         return request;
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
index cb34d8e..17da655 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
@@ -115,8 +115,8 @@ public class ExecutionEventLogger
             for ( MavenProject project : projects )
             {
                 int len = LINE_LENGTH - project.getName().length() - project.getPackaging().length() - 2;
-                logger.info( project.getName() + chars( ' ', ( len > 0 ) ? len : 1 ) + '[' + project.getPackaging()
-                    + ']' );
+                logger.info( "{}{}[{}]",
+                        project.getName(), chars( ' ', ( len > 0 ) ? len : 1 ), project.getPackaging() );
             }
 
             totalProjects = projects.size();
@@ -267,9 +267,9 @@ public class ExecutionEventLogger
 
         String wallClock = session.getRequest().getDegreeOfConcurrency() > 1 ? " (Wall Clock)" : "";
 
-        logger.info( "Total time:  " + formatDuration( time ) + wallClock );
+        logger.info( "Total time:  {}{}", formatDuration( time ), wallClock );
 
-        logger.info( "Finished at: " + formatTimestamp( finish ) );
+        logger.info( "Finished at: {}", formatTimestamp( finish ) );
     }
 
     @Override
@@ -345,8 +345,8 @@ public class ExecutionEventLogger
     {
         if ( logger.isWarnEnabled() )
         {
-            logger.warn( "Goal " + event.getMojoExecution().getGoal()
-                + " requires online mode for execution but Maven is currently offline, skipping" );
+            logger.warn( "Goal {} requires online mode for execution but Maven is currently offline, skipping",
+                    event.getMojoExecution().getGoal() );
         }
     }
 
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java
index d269770..4757cff 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java
@@ -51,7 +51,7 @@ public class UnsupportedSlf4jBindingConfiguration
     @Override
     public void activate()
     {
-        logger.warn( "The SLF4J binding actually used is not supported by Maven: " + slf4jBinding );
+        logger.warn( "The SLF4J binding actually used is not supported by Maven: {}", slf4jBinding );
         logger.warn( "Maven supported bindings are:" );
 
         String ls = System.getProperty( "line.separator" );
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
index 086e406..57e69ba 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java
@@ -69,8 +69,8 @@ public class Slf4jMavenTransferListener
         throws TransferCancelledException
     {
         TransferResource resource = event.getResource();
-        out.warn( event.getException().getMessage() + " from " + resource.getRepositoryId() + " for "
-            + resource.getRepositoryUrl() + resource.getResourceName() );
+        out.warn( "{} from {} for {}{}", event.getException().getMessage(), resource.getRepositoryId(),
+            resource.getRepositoryUrl(), resource.getResourceName() );
     }
 
     @Override
diff --git a/maven-embedder/src/site/apt/logging.apt b/maven-embedder/src/site/apt/logging.apt
index 800857c..7ff3129 100644
--- a/maven-embedder/src/site/apt/logging.apt
+++ b/maven-embedder/src/site/apt/logging.apt
@@ -64,28 +64,8 @@ Maven Logging
 
 * Getting Logger Instance
 
- Plexus Logger and LoggerManager can be injected in Plexus component using Plexus 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 )
-public class DefaultMyComponent
-    implements MyComponent
-{
-    @Requirement
-    private Logger logger;
-
-    @Requirement
-    private LoggerManager loggerManager;
-}
-+------+
-
- Starting with Maven 3.1.0, SLF4J Logger can be used directly too, without Plexus. Of course, this will only work when run under
- Maven 3.1.0, then this technique can be used safely only in Maven core components or in plugins/component not requiring
- compatibility with previous Maven versions.
+ Starting with Maven 3.1.0, SLF4J Logger can be used directly. This technique can be used safely in Maven core
+ components or in plugins/component not requiring compatibility with previous Maven versions.
 
 +-----+
 import org.slf4j.Logger;