Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRELEASE-1097] rework plugin output to clarify goal's phases #135

Merged
merged 5 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() ) )
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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 )
{
Expand All @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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(),
michael-o marked this conversation as resolved.
Show resolved Hide resolved
buffer().project( project.getArtifactId() ) );
nextVersion = prompter.prompt( message, suggestedVersion );

Expand Down Expand Up @@ -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
Expand All @@ -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() );
}
}

This file was deleted.

This file was deleted.