diff --git a/pom.xml b/pom.xml index a40981d1..4046c772 100644 --- a/pom.xml +++ b/pom.xml @@ -76,12 +76,6 @@ under the License. ${mavenVersion} provided - - org.slf4j - slf4j-api - ${slf4jVersion} - provided - org.codehaus.plexus plexus-utils diff --git a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java index 66e17317..e4d36272 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -21,13 +21,13 @@ import org.apache.maven.api.RemoteRepository; import org.apache.maven.api.Version; +import org.apache.maven.api.plugin.Log; import org.apache.maven.api.plugin.Mojo; import org.apache.maven.api.Session; import org.apache.maven.api.plugin.MojoException; +import org.apache.maven.api.plugin.annotations.Component; import org.apache.maven.api.plugin.annotations.Parameter; import org.apache.maven.api.services.VersionParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Abstract class for Deploy mojo's. @@ -39,7 +39,8 @@ public abstract class AbstractDeployMojo private static final String FIXED_MAVEN_VERSION = "3.9.0"; - protected final Logger logger = LoggerFactory.getLogger( getClass() ); + @Component + protected Log logger; /** * Flag whether Maven is currently in online/offline mode. @@ -109,7 +110,7 @@ protected Session getSession() return session; } - protected Logger getLog() + protected Log getLog() { return logger; } diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java index 603c43ef..120594ea 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -206,7 +206,7 @@ private Path readingPomFromJarFile() .orElse( null ); if ( entry != null ) { - logger.debug( "Using " + entry.getName() + " as pomFile" ); + getLog().debug( "Using " + entry.getName() + " as pomFile" ); try ( InputStream pomInputStream = jarFile.getInputStream( entry ) ) { @@ -226,7 +226,7 @@ private Path readingPomFromJarFile() } else { - logger.info( "pom.xml not found in " + file.getFileName() ); + getLog().info( "pom.xml not found in " + file.getFileName() ); } } } @@ -244,7 +244,7 @@ public void execute() if ( !Files.exists( file ) ) { String message = "The specified file '" + file + "' does not exist"; - logger.error( message ); + getLog().error( message ); throw new MojoException( message ); } @@ -312,12 +312,12 @@ public void execute() artifactManager.setPath( pomArtifact, deployedPom ); if ( generatePom ) { - logger.debug( "Deploying generated POM" ); + getLog().debug( "Deploying generated POM" ); deployables.add( pomArtifact ); } else { - logger.debug( "Skipping deploying POM" ); + getLog().debug( "Skipping deploying POM" ); } } } diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java index 62717bc7..6c53413a 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -186,7 +186,7 @@ public void execute() || ( "snapshots".equals( skip ) && session.isVersionSnapshot( project.getVersion() ) ) ) { - logger.info( "Skipping artifact deployment" ); + getLog().info( "Skipping artifact deployment" ); putState( State.SKIPPED ); } else @@ -202,7 +202,7 @@ public void execute() } else { - logger.info( "Deferring deploy for " + project.getGroupId() + getLog().info( "Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion() + " at end" ); putState( State.TO_BE_DEPLOYED, processProject( project ) ); @@ -325,7 +325,7 @@ else if ( !isSnapshot && altReleaseDeploymentRepository != null ) if ( altDeploymentRepo != null ) { - logger.info( "Using alternate deployment repository " + altDeploymentRepo ); + getLog().info( "Using alternate deployment repository " + altDeploymentRepo ); Matcher matcher = ALT_LEGACY_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo ); @@ -337,7 +337,7 @@ else if ( !isSnapshot && altReleaseDeploymentRepository != null ) if ( "default".equals( layout ) ) { - logger.warn( "Using legacy syntax for alternative repository. " + getLog().warn( "Using legacy syntax for alternative repository. " + "Use \"" + id + "::" + url + "\" instead." ); repo = createDeploymentArtifactRepository( id, url ); } diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java index 1f0613f4..e4c640ef 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -45,10 +45,12 @@ import org.apache.maven.api.plugin.testing.stubs.ArtifactStub; import org.apache.maven.api.plugin.testing.stubs.ProjectStub; import org.apache.maven.api.plugin.testing.stubs.SessionStub; +import org.apache.maven.internal.impl.DefaultLog; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.junit.jupiter.MockitoExtension; +import org.slf4j.LoggerFactory; import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject; import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject; @@ -298,6 +300,7 @@ class TestDeployMojo extends DeployMojo { super(); this.session = DeployMojoTest.this.session; + this.logger = new DefaultLog( LoggerFactory.getLogger( "anonymous" ) ); } }