From b39d474f6a13b9e935e41aaf6fefa1661204a251 Mon Sep 17 00:00:00 2001 From: Niels Basjes Date: Fri, 20 May 2022 11:46:57 +0200 Subject: [PATCH] [MRELEASE-1078] Fix rebase issues --- .../src/main/components-fragment.xml | 19 +++++++ .../maven-release-ccsemver-policy/pom.xml | 15 +++++- .../ccsemver/CCSemVerVersionPolicy.java | 51 +++++++------------ .../release/policy/ccsemver/VersionRules.java | 24 +++------ .../ccsemver/CCSemVerVersionPolicyTest.java | 1 - 5 files changed, 58 insertions(+), 52 deletions(-) diff --git a/maven-release-manager/src/main/components-fragment.xml b/maven-release-manager/src/main/components-fragment.xml index e69de29b..d5333cb3 100644 --- a/maven-release-manager/src/main/components-fragment.xml +++ b/maven-release-manager/src/main/components-fragment.xml @@ -0,0 +1,19 @@ + + \ No newline at end of file diff --git a/maven-release-policies/maven-release-ccsemver-policy/pom.xml b/maven-release-policies/maven-release-ccsemver-policy/pom.xml index 4b586ff2..346c23d8 100644 --- a/maven-release-policies/maven-release-ccsemver-policy/pom.xml +++ b/maven-release-policies/maven-release-ccsemver-policy/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.release maven-release 3.0.0-M6-SNAPSHOT - ../.. + ../../pom.xml maven-release-ccsemver-policy @@ -53,6 +53,11 @@ ${scmVersion} + + org.slf4j + slf4j-api + + org.codehaus.plexus plexus-component-annotations @@ -64,6 +69,13 @@ junit test + + + org.slf4j + slf4j-simple + test + + @@ -82,7 +94,6 @@ 3.0.0 false - true src/main/mdo/ccsemver-config.mdo diff --git a/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicy.java b/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicy.java index 0abba202..93478e73 100644 --- a/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicy.java +++ b/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicy.java @@ -25,16 +25,13 @@ import org.apache.maven.shared.release.policy.version.VersionPolicyResult; import org.apache.maven.shared.release.versions.VersionParseException; import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.logging.LogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; import org.semver.Version; import org.semver.Version.Element; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; -import static org.codehaus.plexus.logging.Logger.LEVEL_DEBUG; - /** * Uses SemVer combined with the tags and commit messages to increase the version. */ @@ -44,17 +41,9 @@ description = "A VersionPolicy following the SemVer rules and looks at " + "the commit messages following the Conventional Commits convention." ) -public class CCSemVerVersionPolicy implements VersionPolicy, LogEnabled +public class CCSemVerVersionPolicy implements VersionPolicy { - // Default logger in case none was set. - // In normal runs this is overruled, in testing it is not. - protected Logger logger = new ConsoleLogger( LEVEL_DEBUG, "debug" ); - - @Override - public void enableLogging( Logger logger ) - { - this.logger = logger; - } + protected Logger logger = LoggerFactory.getLogger( CCSemVerVersionPolicy.class ); public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) throws VersionParseException @@ -78,8 +67,6 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request, CommitHistory commitHistory ) throws VersionParseException { - versionRules.enableLogging( logger ); - boolean usingTag = false; String versionString = request.getVersion(); // The current version in the pom @@ -87,8 +74,8 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request, logger.debug( "--------------------------------------------------------" ); logger.debug( "Determining next ReleaseVersion" ); - logger.debug( "VersionRules: \n" + versionRules ); - logger.debug( "Pom version : " + versionString ); + logger.debug( "VersionRules: \n{}", versionRules ); + logger.debug( "Pom version : {}", versionString ); logger.debug( "Commit History : \n" + commitHistory ); @@ -100,7 +87,7 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request, // Use the latest tag we have versionString = commitHistoryTags.get( 0 ); usingTag = true; - logger.debug( "Version from tags : " + versionString ); + logger.debug( "Version from tags : {}", versionString ); } else { @@ -113,7 +100,7 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request, } else { - logger.debug( "Step from commits : " + maxElementSinceLastVersionTag.name() ); + logger.debug( "Step from commits : {}", maxElementSinceLastVersionTag.name() ); } try @@ -125,7 +112,7 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request, throw new VersionParseException( e.getMessage() ); } - logger.debug( "Current version : " + version ); + logger.debug( "Current version : {}", version ); // If we have a version from the tag we use that + the calculated update. @@ -136,28 +123,28 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request, } Version releaseVersion = version.toReleaseVersion(); - logger.debug( "Next version : " + releaseVersion ); + logger.debug( "Next version : {}", releaseVersion ); logger.debug( "--------------------------------------------------------" ); if ( usingTag ) { - logger.info( "From SCM tag with version " + versionString - + " doing a " + maxElementSinceLastVersionTag - + " version increase based on commit messages to version " + releaseVersion ); + logger.info( "From SCM tag with version {} " + + "doing a {} version increase based on commit messages to version {}", + versionString, maxElementSinceLastVersionTag, releaseVersion ); } else { if ( maxElementSinceLastVersionTag == null ) { - logger.info( "From project.version " + versionString - + " (because we did not find any valid SCM tags) going to version " + releaseVersion - + " (because we did not find any minor/major commit messages)." ); + logger.info( "From project.version {} (because we did not find any valid SCM tags) " + + "going to version {} (because we did not find any minor/major commit messages).", + versionString, releaseVersion ); } else { - logger.info( "From project.version " + versionString - + " (because we did not find any valid SCM tags) doing a " + maxElementSinceLastVersionTag - + " version increase based on commit messages to version " + releaseVersion ); + logger.info( "From project.version {} (because we did not find any valid SCM tags) " + + "doing a {} version increase based on commit messages to version {}", + versionString, maxElementSinceLastVersionTag, releaseVersion ); } } diff --git a/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/VersionRules.java b/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/VersionRules.java index f4d083fa..e990e225 100644 --- a/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/VersionRules.java +++ b/maven-release-policies/maven-release-ccsemver-policy/src/main/java/org/apache/maven/shared/release/policy/ccsemver/VersionRules.java @@ -21,11 +21,10 @@ import org.apache.maven.shared.release.policy.ccsemver.config.CCSemverConfig; import org.apache.maven.shared.release.policy.ccsemver.config.io.xpp3.CCSemverConfigXpp3Reader; -import org.codehaus.plexus.logging.LogEnabled; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.semver.Version; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -35,22 +34,13 @@ import java.util.regex.Pattern; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.codehaus.plexus.logging.Logger.LEVEL_DEBUG; /** * The set of rules that determine from the commit history what the next version should be. */ -public class VersionRules implements LogEnabled +public class VersionRules { - // Default logger in case none was set. - // In normal runs this is overruled, in testing it is not. - protected Logger logger = new ConsoleLogger( LEVEL_DEBUG, "debug" ); - - @Override - public void enableLogging( Logger logger ) - { - this.logger = logger; - } + private static final Logger LOGGER = LoggerFactory.getLogger( VersionRules.class ); private final Pattern tagPattern; @@ -112,13 +102,13 @@ public Version.Element getMaxElementSinceLastVersionTag( CommitHistory commitHis { if ( isMajorUpdate( change ) ) { - logger.debug( "MAJOR: \"" + change + "\"" ); + LOGGER.debug( "MAJOR: \"{}\"", change ); return Version.Element.MAJOR; } else if ( isMinorUpdate( change ) ) { - logger.debug( "MINOR: \"" + change + "\"" ); + LOGGER.debug( "MINOR: \"{}\"", change ); needMinorUpdate = true; } } @@ -129,7 +119,7 @@ public Version.Element getMaxElementSinceLastVersionTag( CommitHistory commitHis } if ( commitHistory.getLastVersionTag() != null ) { - logger.debug( "PATCH: Tag " + commitHistory.getLastVersionTag() ); + LOGGER.debug( "PATCH: Tag " + commitHistory.getLastVersionTag() ); return Version.Element.PATCH; } return null; diff --git a/maven-release-policies/maven-release-ccsemver-policy/src/test/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicyTest.java b/maven-release-policies/maven-release-ccsemver-policy/src/test/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicyTest.java index bf88de0a..ed88dc82 100644 --- a/maven-release-policies/maven-release-ccsemver-policy/src/test/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicyTest.java +++ b/maven-release-policies/maven-release-ccsemver-policy/src/test/java/org/apache/maven/shared/release/policy/ccsemver/CCSemVerVersionPolicyTest.java @@ -38,7 +38,6 @@ private void verifyNextVersion( ) throws VersionParseException { VersionPolicyRequest request = new VersionPolicyRequest(); - request.setMetaData( null ); request.setScmProvider( FakeSCM.getSCMProvider( comment, tags ) ); request.setScmRepository( FakeSCM.getScmRepository() ); request.setWorkingDirectory( "/tmp" );