Skip to content

Commit

Permalink
[MRELEASE-1078] Fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsbasjes committed May 20, 2022
1 parent 587b886 commit b39d474
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 52 deletions.
19 changes: 19 additions & 0 deletions maven-release-manager/src/main/components-fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
15 changes: 13 additions & 2 deletions maven-release-policies/maven-release-ccsemver-policy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<groupId>org.apache.maven.release</groupId>
<artifactId>maven-release</artifactId>
<version>3.0.0-M6-SNAPSHOT</version>
<relativePath>../..</relativePath>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>maven-release-ccsemver-policy</artifactId>
Expand Down Expand Up @@ -53,6 +53,11 @@
<version>${scmVersion}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
Expand All @@ -64,6 +69,13 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand All @@ -82,7 +94,6 @@
<configuration>
<version>3.0.0</version>
<packageWithVersion>false</packageWithVersion>
<useJava5>true</useJava5>
<models>
<model>src/main/mdo/ccsemver-config.mdo</model>
</models>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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
Expand All @@ -78,17 +67,15 @@ 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
Version version;

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 );

Expand All @@ -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
{
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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 );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down

0 comments on commit b39d474

Please sign in to comment.