From 35f467b4d61e0ec94ac279974146d27d48c2531f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 29 May 2022 16:24:14 +0200 Subject: [PATCH 1/5] [MRELEASE-1097] rework plugin output to clarify goal's phases --- maven-release-manager/pom.xml | 2 - .../shared/release/DefaultReleaseManager.java | 103 ++++++++++-------- .../DefaultReleaseManagerListener.java | 13 +-- .../phase/AbstractBackupPomsPhase.java | 4 +- .../phase/AbstractInputVariablesPhase.java | 9 +- .../phase/AbstractMapVersionsPhase.java | 6 +- .../phase/AbstractRewritePomsPhase.java | 10 +- .../release/phase/AbstractRunGoalsPhase.java | 8 +- .../release/phase/CheckoutProjectFromScm.java | 10 +- .../release/phase/CreateBackupPomsPhase.java | 2 + .../release/phase/RunPerformGoalsPhase.java | 4 +- .../release/strategies/DefaultStrategy.java | 2 +- .../release/DefaultReleaseManagerTest.java | 6 +- maven-release-plugin/pom.xml | 7 -- .../perform/MRELEASE-818/verify.groovy | 2 +- .../site/apt/examples/perform-release.apt.vm | 2 +- .../src/site/apt/usage.apt.vm | 6 +- 17 files changed, 106 insertions(+), 90 deletions(-) diff --git a/maven-release-manager/pom.xml b/maven-release-manager/pom.xml index 60b10618b..7b3d442c5 100644 --- a/maven-release-manager/pom.xml +++ b/maven-release-manager/pom.xml @@ -238,9 +238,7 @@ - xpp3-reader java - xpp3-writer diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java index c2732d9f5..199dc7fd1 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java @@ -72,8 +72,6 @@ public class DefaultReleaseManager */ private final AtomicReference configStore; - private static final int PHASE_SKIP = 0, PHASE_START = 1, PHASE_END = 2, GOAL_END = 12, ERROR = 99; - @Inject public DefaultReleaseManager( Map strategies, Map releasePhases, @@ -187,7 +185,7 @@ public ReleaseDescriptorBuilder addDependencyDevelopmentVersion( String dependen for ( int idx = 0; idx <= index; idx++ ) { - updateListener( prepareRequest.getReleaseManagerListener(), preparePhases.get( idx ), PHASE_SKIP ); + phaseSkip( prepareRequest.getReleaseManagerListener(), preparePhases.get( idx ) ); } if ( index == preparePhases.size() - 1 ) @@ -212,7 +210,7 @@ else if ( index >= 0 ) throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" ); } - updateListener( prepareRequest.getReleaseManagerListener(), name, PHASE_START ); + phaseStart( prepareRequest.getReleaseManagerListener(), name ); ReleaseResult phaseResult = null; try @@ -249,10 +247,10 @@ else if ( index >= 0 ) throw new ReleaseExecutionException( "Error writing release properties after completing phase", e ); } - updateListener( prepareRequest.getReleaseManagerListener(), name, PHASE_END ); + phaseEnd( prepareRequest.getReleaseManagerListener() ); } - updateListener( prepareRequest.getReleaseManagerListener(), "prepare", GOAL_END ); + goalEnd( prepareRequest.getReleaseManagerListener() ); } @Override @@ -277,16 +275,16 @@ public void rollback( ReleaseRollbackRequest rollbackRequest ) throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" ); } - updateListener( rollbackRequest.getReleaseManagerListener(), name, PHASE_START ); + phaseStart( rollbackRequest.getReleaseManagerListener(), name ); phase.execute( releaseDescriptor, rollbackRequest.getReleaseEnvironment(), rollbackRequest.getReactorProjects() ); - updateListener( rollbackRequest.getReleaseManagerListener(), name, PHASE_END ); + phaseEnd( rollbackRequest.getReleaseManagerListener() ); } //call release:clean so that resume will not be possible anymore after a rollback clean( rollbackRequest ); - updateListener( rollbackRequest.getReleaseManagerListener(), "rollback", GOAL_END ); + goalEnd( rollbackRequest.getReleaseManagerListener() ); } @Override @@ -363,7 +361,7 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" ); } - updateListener( performRequest.getReleaseManagerListener(), name, PHASE_START ); + phaseStart( performRequest.getReleaseManagerListener(), name ); ReleaseResult phaseResult = null; try @@ -389,7 +387,7 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result } } - updateListener( performRequest.getReleaseManagerListener(), name, PHASE_END ); + phaseEnd( performRequest.getReleaseManagerListener() ); } if ( BooleanUtils.isNotFalse( performRequest.getClean() ) ) @@ -398,7 +396,7 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result clean( performRequest ); } - updateListener( performRequest.getReleaseManagerListener(), "perform", GOAL_END ); + goalEnd( performRequest.getReleaseManagerListener() ); } @Override @@ -445,7 +443,7 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key, throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" ); } - updateListener( branchRequest.getReleaseManagerListener(), name, PHASE_START ); + phaseStart( branchRequest.getReleaseManagerListener(), name ); if ( dryRun ) { @@ -459,7 +457,8 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key, branchRequest.getReleaseEnvironment(), branchRequest.getReactorProjects() ); } - updateListener( branchRequest.getReleaseManagerListener(), name, PHASE_END ); + + phaseEnd( branchRequest.getReleaseManagerListener() ); } if ( !dryRun ) @@ -467,7 +466,7 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key, clean( branchRequest ); } - updateListener( branchRequest.getReleaseManagerListener(), "branch", GOAL_END ); + goalEnd( branchRequest.getReleaseManagerListener() ); } @Override @@ -513,16 +512,16 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key, throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" ); } - updateListener( updateVersionsRequest.getReleaseManagerListener(), name, PHASE_START ); + phaseStart( updateVersionsRequest.getReleaseManagerListener(), name ); phase.execute( releaseDescriptor, updateVersionsRequest.getReleaseEnvironment(), updateVersionsRequest.getReactorProjects() ); - updateListener( updateVersionsRequest.getReleaseManagerListener(), name, PHASE_END ); + phaseEnd( updateVersionsRequest.getReleaseManagerListener() ); } clean( updateVersionsRequest ); - updateListener( updateVersionsRequest.getReleaseManagerListener(), "updateVersions", GOAL_END ); + goalEnd( updateVersionsRequest.getReleaseManagerListener() ); } /** @@ -560,15 +559,10 @@ private ReleaseDescriptorBuilder loadReleaseDescriptorBuilder( ReleaseDescriptor { try { - updateListener( listener, "verify-release-configuration", PHASE_START ); - ReleaseDescriptorBuilder result = configStore.get().read( builder ); - updateListener( listener, "verify-release-configuration", PHASE_END ); - return result; + return configStore.get().read( builder ); } catch ( ReleaseDescriptorStoreException e ) { - updateListener( listener, e.getMessage(), ERROR ); - throw new ReleaseExecutionException( "Error reading stored configuration: " + e.getMessage(), e ); } } @@ -592,8 +586,6 @@ protected void clean( AbstractReleaseRequest releaseRequest ) throws ReleaseFai @Override public void clean( ReleaseCleanRequest cleanRequest ) throws ReleaseFailureException { - updateListener( cleanRequest.getReleaseManagerListener(), "cleanup", PHASE_START ); - logger.info( "Cleaning up after release..." ); ReleaseDescriptor releaseDescriptor = @@ -616,8 +608,6 @@ public void clean( ReleaseCleanRequest cleanRequest ) throws ReleaseFailureExcep ( (ResourceGenerator) phase ).clean( cleanRequest.getReactorProjects() ); } } - - updateListener( cleanRequest.getReleaseManagerListener(), "cleanup", PHASE_END ); } void goalStart( ReleaseManagerListener listener, String goal, List phases ) @@ -628,27 +618,43 @@ void goalStart( ReleaseManagerListener listener, String goal, List phase } } - void updateListener( ReleaseManagerListener listener, String name, int state ) + void goalEnd( ReleaseManagerListener listener ) { if ( listener != null ) { - switch ( state ) - { - case GOAL_END: - listener.goalEnd(); - break; - case PHASE_SKIP: - listener.phaseSkip( name ); - break; - case PHASE_START: - listener.phaseStart( name ); - break; - case PHASE_END: - listener.phaseEnd(); - break; - default: - listener.error( name ); - } + listener.goalEnd(); + } + } + + void phaseSkip( ReleaseManagerListener listener, String name ) + { + if ( listener != null ) + { + listener.phaseSkip( name ); + } + } + + void phaseStart( ReleaseManagerListener listener, String name ) + { + if ( listener != null ) + { + listener.phaseStart( name ); + } + } + + void phaseEnd( ReleaseManagerListener listener ) + { + if ( listener != null ) + { + listener.phaseEnd(); + } + } + + void error( ReleaseManagerListener listener, String name ) + { + if ( listener != null ) + { + listener.error( name ); } } @@ -726,7 +732,10 @@ private void logInfo( ReleaseResult result, String message ) private void captureException( ReleaseResult result, ReleaseManagerListener listener, Exception e ) { - updateListener( listener, e.getMessage(), ERROR ); + if ( listener != null ) + { + listener.error( e.getMessage() ); + } result.appendError( e ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManagerListener.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManagerListener.java index 192951873..d177879ea 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManagerListener.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManagerListener.java @@ -77,7 +77,7 @@ private void nextPhase( String name ) public void goalStart( String goal, List phases ) { - log.info( "starting " + buffer().strong( goal ) + " goal" + ( dryRun ? " in dry-run mode" : "" ) + log.info( "starting " + buffer().mojo( goal ) + " goal" + ( dryRun ? " in dry-run mode" : "" ) + ", composed of " + phases.size() + " phases: " + StringUtils.join( phases.iterator(), ", " ) ); currentPhase = -1; this.phases = phases; @@ -86,16 +86,9 @@ public void goalStart( String goal, List phases ) public void phaseStart( String name ) { - if ( goal == null || ( ( currentPhase + 1 ) >= phases.size() ) ) - { - // out of goal phase - log.info( "phase " + buffer().strong( name ) + ( dryRun ? " (dry-run)" : "" ) ); - return; - } - nextPhase( name ); - log.info( buffer().strong( "[" + goal + ( dryRun ? " dry-run" : "" ) + "] " ).toString() + ( currentPhase + 1 ) - + "/" + phases.size() + " " + buffer().strong( name ) ); + log.info( ( currentPhase + 1 ) + "/" + phases.size() + ' ' + buffer().mojo( goal + ':' + name ) + + ( dryRun ? " dry-run" : "" ) ); } /** diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java index 25770ecbe..c0fe0d181 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java @@ -32,7 +32,7 @@ public abstract class AbstractBackupPomsPhase extends AbstractReleasePhase { - private final String backupSuffix = ".releaseBackup"; + protected static final String BACKUP_SUFFIX = ".releaseBackup"; /** *

getPomBackup.

@@ -46,7 +46,7 @@ protected File getPomBackup( MavenProject project ) if ( pomFile != null ) { - return new File( pomFile.getAbsolutePath() + backupSuffix ); + return new File( pomFile.getAbsolutePath() + BACKUP_SUFFIX ); } else { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java index bae1798be..7a00671c7 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java @@ -52,6 +52,7 @@ import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; /** * Input any variables that were not yet configured. @@ -230,7 +231,7 @@ else if ( scmTagNameFormat != null ) if ( branchOperation ) { tag = prompter.get().prompt( "What is the branch name for \"" + project.getName() + "\"? (" - + project.getGroupId() + ":" + project.getArtifactId() + ")" ); + + buffer().project( project.getArtifactId() ) + ")" ); if ( StringUtils.isEmpty( tag ) ) { throw new ReleaseExecutionException( "No branch name was given." ); @@ -238,8 +239,10 @@ else if ( scmTagNameFormat != null ) } else { - tag = prompter.get().prompt( "What is the SCM release tag or label for \"" + project.getName() - + "\"? (" + project.getGroupId() + ":" + project.getArtifactId() + ")", suggestedName ); + tag = prompter.get().prompt( + "What is the SCM release tag or label for \"" + project.getName() + + "\"? (" + buffer().project( project.getArtifactId() ) + ")", + suggestedName ); } } catch ( PrompterException e ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java index b75a4b1d8..61940e08e 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java @@ -41,6 +41,7 @@ import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; /** * Map projects to their new versions after release / into the next development cycle. @@ -308,9 +309,8 @@ else if ( releaseDescriptor.isBranchCreation() ) { messageKey = getMapversionPromptKey( releaseDescriptor ); } - String message = - MessageFormat.format( resourceBundle.getString( messageKey ), project.getName(), - projectId ); + String message = MessageFormat.format( resourceBundle.getString( messageKey ), project.getName(), + buffer().project( project.getArtifactId() ) ); nextVersion = prompter.prompt( message, suggestedVersion ); //@todo validate next version, maybe with DefaultArtifactVersion diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java index 47525a469..9fc6b0564 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java @@ -20,6 +20,7 @@ */ import java.io.File; +import java.net.URI; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -64,6 +65,7 @@ import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; /** * Base class for rewriting phases. @@ -199,9 +201,15 @@ private void transform( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment { result.setStartTime( ( startTime >= 0 ) ? startTime : System.currentTimeMillis() ); + URI root = ReleaseUtil.getRootProject( reactorProjects ).getBasedir().toURI(); + for ( MavenProject project : reactorProjects ) { - logInfo( result, "Transforming '" + project.getName() + "'..." ); + URI pom = project.getFile().toURI(); + logInfo( result, + "Transforming " + root.relativize( pom ).getPath() + ' ' + + buffer().project( project.getArtifactId() ) + " '" + project.getName() + "'" + + ( simulate ? " with ." + getPomSuffix() + " suffix" : "" ) + "..." ); transformProject( project, releaseDescriptor, releaseEnvironment, simulate, result ); } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java index 67d4aed6f..ce5df05c2 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java @@ -33,6 +33,7 @@ import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; /** * Abstract phase to run a Maven invocation on the project. @@ -71,11 +72,12 @@ protected ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnv String goals = getGoals( releaseDescriptor ); if ( !StringUtils.isEmpty( goals ) ) { - logInfo( result, "Executing goals '" + goals + "'..." ); - if ( logArguments && ( additionalArguments != null ) ) + logInfo( result, "Executing goals '" + buffer().strong( goals ) + "'..." ); + if ( logArguments ) { // logging arguments may log secrets: should be activated only on dryRun - logInfo( result, " with additional arguments: " + additionalArguments ); + logInfo( result, " with additional arguments: " + + ( additionalArguments == null ? "" : additionalArguments ) ); } MavenExecutor mavenExecutor = mavenExecutors.get( releaseEnvironment.getMavenExecutorId() ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java index 1eb3682bd..406d2ac6a 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java @@ -270,13 +270,19 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir { ReleaseResult result = new ReleaseResult(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + File checkoutDirectory = + FileUtils.resolveFile( rootProject.getBasedir(), releaseDescriptor.getCheckoutDirectory() ); + if ( releaseDescriptor.isLocalCheckout() ) { - logInfo( result, "This would be a LOCAL check out to perform the release ..." ); + logInfo( result, + "This would be a LOCAL check out to perform the release from " + checkoutDirectory + "..." ); } else { - logInfo( result, "The project would be checked out to perform the release ..." ); + logInfo( result, + "The project would be checked out to perform the release from " + checkoutDirectory + "..." ); } result.setResultCode( ReleaseResult.SUCCESS ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java index 866c9a20e..3a9ba41be 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java @@ -52,6 +52,8 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro // remove previous backups, if any clean( reactorProjects ); + logInfo( result, "Creating pom.xml backup with " + BACKUP_SUFFIX + " suffix" ); + for ( MavenProject project : reactorProjects ) { createPomBackup( project ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java index 4c0087883..32bf357cc 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java @@ -23,6 +23,8 @@ import javax.inject.Named; import javax.inject.Singleton; +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; + import java.io.File; import java.util.List; import java.util.Map; @@ -99,7 +101,7 @@ private ReleaseResult runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvi { ReleaseResult result = new ReleaseResult(); - logInfo( result, "Simulating perform goals '" + getGoals( releaseDescriptor ) + logInfo( result, "Simulating perform goals '" + buffer().strong( getGoals( releaseDescriptor ) ) + "' - since this is simulation mode these goals are skipped." ); logInfo( result, " with additional arguments: " + additionalArguments ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java index 866af8f89..60b51485a 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java @@ -39,7 +39,7 @@ public class DefaultStrategy implements Strategy { /** - * The phases of release to run, and in what order. + * The phases of release to run to prepare. */ private final List preparePhases; diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java index 376b8a02d..a7fcf7028 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java @@ -612,6 +612,7 @@ public void testPerformWithDefaultClean() // prepare ReleasePerformRequest performRequest = new ReleasePerformRequest(); performRequest.setDryRun( true ); + performRequest.setReactorProjects( createReactorProjects() ); ReleaseManagerListener managerListener = mock( ReleaseManagerListener.class ); performRequest.setReleaseManagerListener( managerListener ); @@ -627,12 +628,10 @@ public void testPerformWithDefaultClean() releaseManager.perform( performRequest ); // verify - verify( managerListener ).phaseStart( "verify-release-configuration" ); verify( managerListener ).phaseStart( "verify-completed-prepare-phases" ); verify( managerListener ).phaseStart( "checkout-project-from-scm" ); verify( managerListener ).phaseStart( "run-perform-goals" ); - verify( managerListener ).phaseStart( "cleanup" ); - verify( managerListener, times( 5 ) ).phaseEnd(); + verify( managerListener, times( 3 ) ).phaseEnd(); // not part of actual test, but required to confirm 'no more interactions' verify( managerListener ).goalStart( anyString(), any() ); @@ -756,6 +755,7 @@ public void testKeepProfilesOnPerform() // prepare ReleasePerformRequest performRequest = new ReleasePerformRequest(); performRequest.setDryRun( true ); + performRequest.setReactorProjects( createReactorProjects() ); ReleaseManagerListener managerListener = mock( ReleaseManagerListener.class ); performRequest.setReleaseManagerListener( managerListener ); diff --git a/maven-release-plugin/pom.xml b/maven-release-plugin/pom.xml index 7e8a7174f..3e582d6f4 100644 --- a/maven-release-plugin/pom.xml +++ b/maven-release-plugin/pom.xml @@ -116,13 +116,6 @@ - - org.apache.maven.plugins - maven-site-plugin - - scp://people.apache.org/www/maven.apache.org/plugins/${project.artifactId}-${project.version} - - org.apache.maven.plugins maven-plugin-plugin diff --git a/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy b/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy index 9057a5624..a2dfd3bbb 100644 --- a/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy +++ b/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy @@ -20,7 +20,7 @@ File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() -def localCheckoutExpr = /\Q[INFO] This would be a LOCAL check out to perform the release ...\E/ +def localCheckoutExpr = /\Q[INFO] This would be a LOCAL check out to perform the release from / def matcher = ( buildLog.getText() =~ localCheckoutExpr ) assert matcher.find() diff --git a/maven-release-plugin/src/site/apt/examples/perform-release.apt.vm b/maven-release-plugin/src/site/apt/examples/perform-release.apt.vm index 002c9fa31..d3dca4b6e 100644 --- a/maven-release-plugin/src/site/apt/examples/perform-release.apt.vm +++ b/maven-release-plugin/src/site/apt/examples/perform-release.apt.vm @@ -29,7 +29,7 @@ Perform a Release Performing a release runs the following release phases {{{../../maven-release-manager/#perform}by default}}: - * Checkout from an SCM URL with optional tag + * Checkout from an SCM URL with optional tag to <<>> (<<>> by default) * Run the perform Maven goals to release the project (by default, <<>>), eventually with release profile(s) active diff --git a/maven-release-plugin/src/site/apt/usage.apt.vm b/maven-release-plugin/src/site/apt/usage.apt.vm index 1e609d442..8353bc6ce 100644 --- a/maven-release-plugin/src/site/apt/usage.apt.vm +++ b/maven-release-plugin/src/site/apt/usage.apt.vm @@ -80,7 +80,7 @@ mvn release:prepare -DdryRun ------ This will ask all the same questions, run the same tests, and output a copy of how the POMs will look after - transformation. You can check the output and review the POMs, then run: + transformation. You can check the output and review the POMs (with <<<.tag>>> and <<<.next>>> suffixes), then run: ------ mvn release:perform -DdryRun @@ -94,9 +94,9 @@ mvn release:perform -DdryRun builds through a build server). To use the default inputs for the versions and tag information and not prompt for any values, use Maven's <<<--batch-mode>>> setting: -+------ +------ mvn --batch-mode release:prepare -+------ +------ * Use a staging repository From dbd8587d9de6d6f1fb0a84a36656d30cf85414c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 29 May 2022 19:24:21 +0200 Subject: [PATCH 2/5] [MRELEASE-1097] strong("local") instead of "LOCAL" --- .../maven/shared/release/phase/CheckoutProjectFromScm.java | 4 +++- .../src/it/projects/perform/MRELEASE-818/verify.groovy | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java index 406d2ac6a..719610d72 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java @@ -54,6 +54,7 @@ import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; /** * @author Emmanuel Venisse @@ -277,7 +278,8 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir if ( releaseDescriptor.isLocalCheckout() ) { logInfo( result, - "This would be a LOCAL check out to perform the release from " + checkoutDirectory + "..." ); + "The project would have a " + buffer().strong( "local" ) + + " check out to perform the release from " + checkoutDirectory + "..." ); } else { diff --git a/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy b/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy index a2dfd3bbb..89f178ae3 100644 --- a/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy +++ b/maven-release-plugin/src/it/projects/perform/MRELEASE-818/verify.groovy @@ -20,7 +20,7 @@ File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() -def localCheckoutExpr = /\Q[INFO] This would be a LOCAL check out to perform the release from / +def localCheckoutExpr = /\Q[INFO] The project would have a local check out to perform the release from / def matcher = ( buildLog.getText() =~ localCheckoutExpr ) assert matcher.find() From 731ee7ce5ebf795e36bb82f710520f3ff5fb513f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 29 May 2022 19:44:20 +0200 Subject: [PATCH 3/5] [MRELEASE-079] drop under-used message bundle --- .../phase/AbstractMapVersionsPhase.java | 38 +++++++------------ .../resources/release-messages.properties | 21 ---------- .../resources/release-messages_en.properties | 23 ----------- 3 files changed, 14 insertions(+), 68 deletions(-) delete mode 100644 maven-release-manager/src/main/resources/release-messages.properties delete mode 100644 maven-release-manager/src/main/resources/release-messages_en.properties diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java index 61940e08e..6a3df9c8b 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java @@ -21,9 +21,7 @@ import java.text.MessageFormat; import java.util.List; -import java.util.Locale; import java.util.Map; -import java.util.ResourceBundle; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.project.MavenProject; @@ -110,8 +108,6 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro { ReleaseResult result = new ReleaseResult(); - ResourceBundle resourceBundle = getResourceBundle( releaseEnvironment.getLocale() ); - MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); if ( releaseDescriptor.isAutoVersionSubmodules() && ArtifactUtils.isSnapshot( rootProject.getVersion() ) ) @@ -121,7 +117,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); - String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor, resourceBundle ); + String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor ); if ( !convertToSnapshot ) { @@ -187,7 +183,7 @@ else if ( ArtifactUtils.isSnapshot( subProject.getVersion() ) ) { String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); - String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor, resourceBundle ); + String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor ); if ( !convertToSnapshot ) { @@ -211,8 +207,7 @@ else if ( releaseDescriptor.isBranchCreation() && convertToBranch ) private String resolveNextVersion( MavenProject project, String projectId, - ReleaseDescriptor releaseDescriptor, - ResourceBundle resourceBundle ) + ReleaseDescriptor releaseDescriptor ) throws ReleaseExecutionException { String defaultVersion; @@ -257,7 +252,7 @@ else if ( releaseDescriptor.isBranchCreation() ) String suggestedVersion = null; String nextVersion = defaultVersion; - String messageKey = null; + String messageFormat = null; try { while ( nextVersion == null || ArtifactUtils.isSnapshot( nextVersion ) != convertToSnapshot ) @@ -305,11 +300,11 @@ else if ( releaseDescriptor.isBranchCreation() ) if ( releaseDescriptor.isInteractive() ) { - if ( messageKey == null ) + if ( messageFormat == null ) { - messageKey = getMapversionPromptKey( releaseDescriptor ); + messageFormat = getMapversionPromptFormat( releaseDescriptor ); } - String message = MessageFormat.format( resourceBundle.getString( messageKey ), project.getName(), + String message = MessageFormat.format( messageFormat, project.getName(), buffer().project( project.getArtifactId() ) ); nextVersion = prompter.prompt( message, suggestedVersion ); @@ -385,26 +380,26 @@ private String getReleaseVersion( String projectId, ReleaseDescriptor releaseDes } - private String getMapversionPromptKey( ReleaseDescriptor releaseDescriptor ) + private String getMapversionPromptFormat( ReleaseDescriptor releaseDescriptor ) { - String messageKey; + String context; if ( convertToBranch ) { - messageKey = "mapversion.branch.prompt"; + context = "branch"; } else if ( !convertToSnapshot ) { - messageKey = "mapversion.release.prompt"; + context = "release"; } else if ( releaseDescriptor.isBranchCreation() ) { - messageKey = "mapversion.workingcopy.prompt"; + context = "new working copy"; } else { - messageKey = "mapversion.development.prompt"; + context = "new development"; } - return messageKey; + return "What is the " + context + " version for \"{0}\"? ({1})"; } @Override @@ -421,9 +416,4 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir return result; } - - private ResourceBundle getResourceBundle( Locale locale ) - { - return ResourceBundle.getBundle( "release-messages", locale, AbstractMapVersionsPhase.class.getClassLoader() ); - } } diff --git a/maven-release-manager/src/main/resources/release-messages.properties b/maven-release-manager/src/main/resources/release-messages.properties deleted file mode 100644 index 2083f31fb..000000000 --- a/maven-release-manager/src/main/resources/release-messages.properties +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -mapversion.branch.prompt = What is the branch version for "{0}"? ({1}) -mapversion.development.prompt = What is the new development version for "{0}"? ({1}) -mapversion.release.prompt = What is the release version for "{0}"? ({1}) -mapversion.workingcopy.prompt = What is the new working copy version for "{0}"? ({1}) diff --git a/maven-release-manager/src/main/resources/release-messages_en.properties b/maven-release-manager/src/main/resources/release-messages_en.properties deleted file mode 100644 index 96cf40750..000000000 --- a/maven-release-manager/src/main/resources/release-messages_en.properties +++ /dev/null @@ -1,23 +0,0 @@ -# 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. - -# NOTE: -# This bundle is intentionally empty because English strings are provided by the base bundle via the parent chain. It -# must be provided nevertheless such that a request for locale "en" will not errorneously pick up the bundle for the -# JVM's default locale (which need not be "en"). See the method javadoc about -# ResourceBundle.getBundle(String, Locale, ClassLoader) -# for a full description of the lookup strategy. From 134a1bed7cc67ee8dffde0da4007d414d0931ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 29 May 2022 19:49:51 +0200 Subject: [PATCH 4/5] [MRELEASE-1097] display "(none)" in case of no value --- .../maven/shared/release/phase/AbstractRunGoalsPhase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java index ce5df05c2..9b8bdcac1 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java @@ -77,7 +77,7 @@ protected ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnv { // logging arguments may log secrets: should be activated only on dryRun logInfo( result, " with additional arguments: " - + ( additionalArguments == null ? "" : additionalArguments ) ); + + ( additionalArguments == null ? "(none)" : additionalArguments ) ); } MavenExecutor mavenExecutor = mavenExecutors.get( releaseEnvironment.getMavenExecutorId() ); From 0c752889a9686dcf884aa6e213c034041e5bb75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 29 May 2022 19:59:23 +0200 Subject: [PATCH 5/5] [MRELEASE-1097] use basic String.format() instead of MessageFormat --- .../phase/AbstractMapVersionsPhase.java | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java index 6a3df9c8b..97617f35a 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java @@ -19,7 +19,6 @@ * under the License. */ -import java.text.MessageFormat; import java.util.List; import java.util.Map; @@ -302,10 +301,10 @@ else if ( releaseDescriptor.isBranchCreation() ) { if ( messageFormat == null ) { - messageFormat = getMapversionPromptFormat( releaseDescriptor ); + messageFormat = "What is the " + getContextString( releaseDescriptor ) + + " version for \"%s\"? (" + buffer().project( "%s" ) + ")"; } - String message = MessageFormat.format( messageFormat, project.getName(), - buffer().project( project.getArtifactId() ) ); + String message = String.format( messageFormat, project.getName(), project.getArtifactId() ); nextVersion = prompter.prompt( message, suggestedVersion ); //@todo validate next version, maybe with DefaultArtifactVersion @@ -331,6 +330,23 @@ else if ( convertToSnapshot ) return nextVersion; } + private String getContextString( ReleaseDescriptor releaseDescriptor ) + { + if ( convertToBranch ) + { + return "branch"; + } + if ( !convertToSnapshot ) + { + return "release"; + } + if ( releaseDescriptor.isBranchCreation() ) + { + return "new working copy"; + } + return "new development"; + } + private String resolveSuggestedVersion( String baseVersion, String policyId ) throws PolicyException, VersionParseException { @@ -379,29 +395,6 @@ private String getReleaseVersion( String projectId, ReleaseDescriptor releaseDes return projectVersion; } - - private String getMapversionPromptFormat( ReleaseDescriptor releaseDescriptor ) - { - String context; - if ( convertToBranch ) - { - context = "branch"; - } - else if ( !convertToSnapshot ) - { - context = "release"; - } - else if ( releaseDescriptor.isBranchCreation() ) - { - context = "new working copy"; - } - else - { - context = "new development"; - } - return "What is the " + context + " version for \"{0}\"? ({1})"; - } - @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects )