Skip to content

Commit 6f9c8b7

Browse files
authored
[MRELEASE-1097] rework plugin output to clarify goal's phases (#135)
1 parent ac65bef commit 6f9c8b7

19 files changed

+131
-174
lines changed

maven-release-manager/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@
238238
<executions>
239239
<execution>
240240
<goals>
241-
<goal>xpp3-reader</goal>
242241
<goal>java</goal>
243-
<goal>xpp3-writer</goal>
244242
</goals>
245243
</execution>
246244
</executions>

maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ public class DefaultReleaseManager
7272
*/
7373
private final AtomicReference<ReleaseDescriptorStore> configStore;
7474

75-
private static final int PHASE_SKIP = 0, PHASE_START = 1, PHASE_END = 2, GOAL_END = 12, ERROR = 99;
76-
7775
@Inject
7876
public DefaultReleaseManager( Map<String, Strategy> strategies,
7977
Map<String, ReleasePhase> releasePhases,
@@ -187,7 +185,7 @@ public ReleaseDescriptorBuilder addDependencyDevelopmentVersion( String dependen
187185

188186
for ( int idx = 0; idx <= index; idx++ )
189187
{
190-
updateListener( prepareRequest.getReleaseManagerListener(), preparePhases.get( idx ), PHASE_SKIP );
188+
phaseSkip( prepareRequest.getReleaseManagerListener(), preparePhases.get( idx ) );
191189
}
192190

193191
if ( index == preparePhases.size() - 1 )
@@ -212,7 +210,7 @@ else if ( index >= 0 )
212210
throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" );
213211
}
214212

215-
updateListener( prepareRequest.getReleaseManagerListener(), name, PHASE_START );
213+
phaseStart( prepareRequest.getReleaseManagerListener(), name );
216214

217215
ReleaseResult phaseResult = null;
218216
try
@@ -249,10 +247,10 @@ else if ( index >= 0 )
249247
throw new ReleaseExecutionException( "Error writing release properties after completing phase", e );
250248
}
251249

252-
updateListener( prepareRequest.getReleaseManagerListener(), name, PHASE_END );
250+
phaseEnd( prepareRequest.getReleaseManagerListener() );
253251
}
254252

255-
updateListener( prepareRequest.getReleaseManagerListener(), "prepare", GOAL_END );
253+
goalEnd( prepareRequest.getReleaseManagerListener() );
256254
}
257255

258256
@Override
@@ -277,16 +275,16 @@ public void rollback( ReleaseRollbackRequest rollbackRequest )
277275
throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" );
278276
}
279277

280-
updateListener( rollbackRequest.getReleaseManagerListener(), name, PHASE_START );
278+
phaseStart( rollbackRequest.getReleaseManagerListener(), name );
281279
phase.execute( releaseDescriptor,
282280
rollbackRequest.getReleaseEnvironment(),
283281
rollbackRequest.getReactorProjects() );
284-
updateListener( rollbackRequest.getReleaseManagerListener(), name, PHASE_END );
282+
phaseEnd( rollbackRequest.getReleaseManagerListener() );
285283
}
286284

287285
//call release:clean so that resume will not be possible anymore after a rollback
288286
clean( rollbackRequest );
289-
updateListener( rollbackRequest.getReleaseManagerListener(), "rollback", GOAL_END );
287+
goalEnd( rollbackRequest.getReleaseManagerListener() );
290288
}
291289

292290
@Override
@@ -363,7 +361,7 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result
363361
throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" );
364362
}
365363

366-
updateListener( performRequest.getReleaseManagerListener(), name, PHASE_START );
364+
phaseStart( performRequest.getReleaseManagerListener(), name );
367365

368366
ReleaseResult phaseResult = null;
369367
try
@@ -389,7 +387,7 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result
389387
}
390388
}
391389

392-
updateListener( performRequest.getReleaseManagerListener(), name, PHASE_END );
390+
phaseEnd( performRequest.getReleaseManagerListener() );
393391
}
394392

395393
if ( BooleanUtils.isNotFalse( performRequest.getClean() ) )
@@ -398,7 +396,7 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result
398396
clean( performRequest );
399397
}
400398

401-
updateListener( performRequest.getReleaseManagerListener(), "perform", GOAL_END );
399+
goalEnd( performRequest.getReleaseManagerListener() );
402400
}
403401

404402
@Override
@@ -445,7 +443,7 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key,
445443
throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" );
446444
}
447445

448-
updateListener( branchRequest.getReleaseManagerListener(), name, PHASE_START );
446+
phaseStart( branchRequest.getReleaseManagerListener(), name );
449447

450448
if ( dryRun )
451449
{
@@ -459,15 +457,16 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key,
459457
branchRequest.getReleaseEnvironment(),
460458
branchRequest.getReactorProjects() );
461459
}
462-
updateListener( branchRequest.getReleaseManagerListener(), name, PHASE_END );
460+
461+
phaseEnd( branchRequest.getReleaseManagerListener() );
463462
}
464463

465464
if ( !dryRun )
466465
{
467466
clean( branchRequest );
468467
}
469468

470-
updateListener( branchRequest.getReleaseManagerListener(), "branch", GOAL_END );
469+
goalEnd( branchRequest.getReleaseManagerListener() );
471470
}
472471

473472
@Override
@@ -513,16 +512,16 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key,
513512
throw new ReleaseExecutionException( "Unable to find phase '" + name + "' to execute" );
514513
}
515514

516-
updateListener( updateVersionsRequest.getReleaseManagerListener(), name, PHASE_START );
515+
phaseStart( updateVersionsRequest.getReleaseManagerListener(), name );
517516
phase.execute( releaseDescriptor,
518517
updateVersionsRequest.getReleaseEnvironment(),
519518
updateVersionsRequest.getReactorProjects() );
520-
updateListener( updateVersionsRequest.getReleaseManagerListener(), name, PHASE_END );
519+
phaseEnd( updateVersionsRequest.getReleaseManagerListener() );
521520
}
522521

523522
clean( updateVersionsRequest );
524523

525-
updateListener( updateVersionsRequest.getReleaseManagerListener(), "updateVersions", GOAL_END );
524+
goalEnd( updateVersionsRequest.getReleaseManagerListener() );
526525
}
527526

528527
/**
@@ -560,15 +559,10 @@ private ReleaseDescriptorBuilder loadReleaseDescriptorBuilder( ReleaseDescriptor
560559
{
561560
try
562561
{
563-
updateListener( listener, "verify-release-configuration", PHASE_START );
564-
ReleaseDescriptorBuilder result = configStore.get().read( builder );
565-
updateListener( listener, "verify-release-configuration", PHASE_END );
566-
return result;
562+
return configStore.get().read( builder );
567563
}
568564
catch ( ReleaseDescriptorStoreException e )
569565
{
570-
updateListener( listener, e.getMessage(), ERROR );
571-
572566
throw new ReleaseExecutionException( "Error reading stored configuration: " + e.getMessage(), e );
573567
}
574568
}
@@ -592,8 +586,6 @@ protected void clean( AbstractReleaseRequest releaseRequest ) throws ReleaseFai
592586
@Override
593587
public void clean( ReleaseCleanRequest cleanRequest ) throws ReleaseFailureException
594588
{
595-
updateListener( cleanRequest.getReleaseManagerListener(), "cleanup", PHASE_START );
596-
597589
logger.info( "Cleaning up after release..." );
598590

599591
ReleaseDescriptor releaseDescriptor =
@@ -616,8 +608,6 @@ public void clean( ReleaseCleanRequest cleanRequest ) throws ReleaseFailureExcep
616608
( (ResourceGenerator) phase ).clean( cleanRequest.getReactorProjects() );
617609
}
618610
}
619-
620-
updateListener( cleanRequest.getReleaseManagerListener(), "cleanup", PHASE_END );
621611
}
622612

623613
void goalStart( ReleaseManagerListener listener, String goal, List<String> phases )
@@ -628,27 +618,43 @@ void goalStart( ReleaseManagerListener listener, String goal, List<String> phase
628618
}
629619
}
630620

631-
void updateListener( ReleaseManagerListener listener, String name, int state )
621+
void goalEnd( ReleaseManagerListener listener )
632622
{
633623
if ( listener != null )
634624
{
635-
switch ( state )
636-
{
637-
case GOAL_END:
638-
listener.goalEnd();
639-
break;
640-
case PHASE_SKIP:
641-
listener.phaseSkip( name );
642-
break;
643-
case PHASE_START:
644-
listener.phaseStart( name );
645-
break;
646-
case PHASE_END:
647-
listener.phaseEnd();
648-
break;
649-
default:
650-
listener.error( name );
651-
}
625+
listener.goalEnd();
626+
}
627+
}
628+
629+
void phaseSkip( ReleaseManagerListener listener, String name )
630+
{
631+
if ( listener != null )
632+
{
633+
listener.phaseSkip( name );
634+
}
635+
}
636+
637+
void phaseStart( ReleaseManagerListener listener, String name )
638+
{
639+
if ( listener != null )
640+
{
641+
listener.phaseStart( name );
642+
}
643+
}
644+
645+
void phaseEnd( ReleaseManagerListener listener )
646+
{
647+
if ( listener != null )
648+
{
649+
listener.phaseEnd();
650+
}
651+
}
652+
653+
void error( ReleaseManagerListener listener, String name )
654+
{
655+
if ( listener != null )
656+
{
657+
listener.error( name );
652658
}
653659
}
654660

@@ -726,7 +732,10 @@ private void logInfo( ReleaseResult result, String message )
726732

727733
private void captureException( ReleaseResult result, ReleaseManagerListener listener, Exception e )
728734
{
729-
updateListener( listener, e.getMessage(), ERROR );
735+
if ( listener != null )
736+
{
737+
listener.error( e.getMessage() );
738+
}
730739

731740
result.appendError( e );
732741

maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManagerListener.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void nextPhase( String name )
7777

7878
public void goalStart( String goal, List<String> phases )
7979
{
80-
log.info( "starting " + buffer().strong( goal ) + " goal" + ( dryRun ? " in dry-run mode" : "" )
80+
log.info( "starting " + buffer().mojo( goal ) + " goal" + ( dryRun ? " in dry-run mode" : "" )
8181
+ ", composed of " + phases.size() + " phases: " + StringUtils.join( phases.iterator(), ", " ) );
8282
currentPhase = -1;
8383
this.phases = phases;
@@ -86,16 +86,9 @@ public void goalStart( String goal, List<String> phases )
8686

8787
public void phaseStart( String name )
8888
{
89-
if ( goal == null || ( ( currentPhase + 1 ) >= phases.size() ) )
90-
{
91-
// out of goal phase
92-
log.info( "phase " + buffer().strong( name ) + ( dryRun ? " (dry-run)" : "" ) );
93-
return;
94-
}
95-
9689
nextPhase( name );
97-
log.info( buffer().strong( "[" + goal + ( dryRun ? " dry-run" : "" ) + "] " ).toString() + ( currentPhase + 1 )
98-
+ "/" + phases.size() + " " + buffer().strong( name ) );
90+
log.info( ( currentPhase + 1 ) + "/" + phases.size() + ' ' + buffer().mojo( goal + ':' + name )
91+
+ ( dryRun ? " dry-run" : "" ) );
9992
}
10093

10194
/**

maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public abstract class AbstractBackupPomsPhase
3333
extends AbstractReleasePhase
3434
{
35-
private final String backupSuffix = ".releaseBackup";
35+
protected static final String BACKUP_SUFFIX = ".releaseBackup";
3636

3737
/**
3838
* <p>getPomBackup.</p>
@@ -46,7 +46,7 @@ protected File getPomBackup( MavenProject project )
4646

4747
if ( pomFile != null )
4848
{
49-
return new File( pomFile.getAbsolutePath() + backupSuffix );
49+
return new File( pomFile.getAbsolutePath() + BACKUP_SUFFIX );
5050
}
5151
else
5252
{

maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.codehaus.plexus.util.StringUtils;
5353

5454
import static java.util.Objects.requireNonNull;
55+
import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
5556

5657
/**
5758
* Input any variables that were not yet configured.
@@ -230,16 +231,18 @@ else if ( scmTagNameFormat != null )
230231
if ( branchOperation )
231232
{
232233
tag = prompter.get().prompt( "What is the branch name for \"" + project.getName() + "\"? ("
233-
+ project.getGroupId() + ":" + project.getArtifactId() + ")" );
234+
+ buffer().project( project.getArtifactId() ) + ")" );
234235
if ( StringUtils.isEmpty( tag ) )
235236
{
236237
throw new ReleaseExecutionException( "No branch name was given." );
237238
}
238239
}
239240
else
240241
{
241-
tag = prompter.get().prompt( "What is the SCM release tag or label for \"" + project.getName()
242-
+ "\"? (" + project.getGroupId() + ":" + project.getArtifactId() + ")", suggestedName );
242+
tag = prompter.get().prompt(
243+
"What is the SCM release tag or label for \"" + project.getName()
244+
+ "\"? (" + buffer().project( project.getArtifactId() ) + ")",
245+
suggestedName );
243246
}
244247
}
245248
catch ( PrompterException e )

0 commit comments

Comments
 (0)