-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MRELEASE-1078] Conventional Commits Version Policy
- Loading branch information
1 parent
906b6e4
commit 1571e4f
Showing
31 changed files
with
1,815 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,15 +24,23 @@ | |
|
||
import org.apache.maven.artifact.ArtifactUtils; | ||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.scm.manager.NoSuchScmProviderException; | ||
import org.apache.maven.scm.provider.ScmProvider; | ||
import org.apache.maven.scm.repository.ScmRepository; | ||
import org.apache.maven.scm.repository.ScmRepositoryException; | ||
import org.apache.maven.settings.Settings; | ||
import org.apache.maven.shared.release.ReleaseExecutionException; | ||
import org.apache.maven.shared.release.ReleaseResult; | ||
import org.apache.maven.shared.release.config.ReleaseDescriptor; | ||
import org.apache.maven.shared.release.env.ReleaseEnvironment; | ||
import org.apache.maven.shared.release.policy.PolicyException; | ||
import org.apache.maven.shared.release.policy.version.VersionPolicy; | ||
import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; | ||
import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; | ||
import org.apache.maven.shared.release.util.ReleaseUtil; | ||
import org.apache.maven.shared.release.versions.VersionParseException; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
import org.codehaus.plexus.component.annotations.Requirement; | ||
import org.codehaus.plexus.components.interactivity.Prompter; | ||
import org.codehaus.plexus.components.interactivity.PrompterException; | ||
import org.codehaus.plexus.util.StringUtils; | ||
|
@@ -67,9 +75,16 @@ | |
* @author <a href="mailto:[email protected]">Brett Porter</a> | ||
* @author Robert Scholte | ||
*/ | ||
@Component( role = ReleasePhase.class, hint = "map-release-versions" ) | ||
public abstract class AbstractMapVersionsPhase | ||
extends AbstractReleasePhase | ||
{ | ||
/** | ||
* Tool that gets a configured SCM repository from release configuration. | ||
*/ | ||
@Requirement | ||
private ScmRepositoryConfigurator scmRepositoryConfigurator; | ||
|
||
/** | ||
* Component used to prompt for input. | ||
*/ | ||
|
@@ -275,14 +290,14 @@ else if ( releaseDescriptor.isBranchCreation() ) | |
{ | ||
suggestedVersion = | ||
resolveSuggestedVersion( baseVersion, | ||
releaseDescriptor.getProjectVersionPolicyId() ); | ||
releaseDescriptor ); | ||
} | ||
catch ( VersionParseException e ) | ||
{ | ||
if ( releaseDescriptor.isInteractive() ) | ||
{ | ||
suggestedVersion = | ||
resolveSuggestedVersion( "1.0", releaseDescriptor.getProjectVersionPolicyId() ); | ||
resolveSuggestedVersion( "1.0", releaseDescriptor ); | ||
} | ||
else | ||
{ | ||
|
@@ -347,16 +362,42 @@ private String getContextString( ReleaseDescriptor releaseDescriptor ) | |
return "new development"; | ||
} | ||
|
||
private String resolveSuggestedVersion( String baseVersion, String policyId ) | ||
private String resolveSuggestedVersion( String baseVersion, ReleaseDescriptor releaseDescriptor ) | ||
throws PolicyException, VersionParseException | ||
{ | ||
String policyId = releaseDescriptor.getProjectVersionPolicyId(); | ||
VersionPolicy policy = versionPolicies.get( policyId ); | ||
if ( policy == null ) | ||
{ | ||
throw new PolicyException( "Policy '" + policyId + "' is unknown, available: " + versionPolicies.keySet() ); | ||
} | ||
|
||
VersionPolicyRequest request = new VersionPolicyRequest().setVersion( baseVersion ); | ||
|
||
if ( releaseDescriptor.getProjectVersionPolicyConfig() != null ) | ||
{ | ||
request.setConfig( releaseDescriptor.getProjectVersionPolicyConfig().toString() ); | ||
} | ||
request.setWorkingDirectory( releaseDescriptor.getWorkingDirectory() ); | ||
|
||
if ( scmRepositoryConfigurator != null && releaseDescriptor.getScmSourceUrl() != null ) | ||
{ | ||
try | ||
{ | ||
ScmRepository repository = scmRepositoryConfigurator | ||
.getConfiguredRepository( releaseDescriptor, new Settings() ); | ||
|
||
ScmProvider provider = scmRepositoryConfigurator | ||
.getRepositoryProvider( repository ); | ||
|
||
request.setScmRepository( repository ); | ||
request.setScmProvider( provider ); | ||
} | ||
catch ( ScmRepositoryException | NoSuchScmProviderException e ) | ||
{ | ||
getLogger().warn( "Next Version will NOT be based on the version control: {}", e.getMessage() ); | ||
} | ||
} | ||
return convertToSnapshot ? policy.getDevelopmentVersion( request ).getVersion() | ||
: policy.getReleaseVersion( request ).getVersion(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.