Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
NXCM-2190 - Problematic behavior of nexus-maven-plugin parameters in …
Browse files Browse the repository at this point in the history
…staging-build-promotion goal

git-svn-id: file:///opt/svn/repositories/sonatype.org/plugins/trunk/nexus-maven-plugin@526 c2a14038-686d-4adc-8740-a14e5738cb64
  • Loading branch information
velo committed Sep 28, 2010
1 parent bbb349c commit c8765db
Showing 1 changed file with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public class PromoteToStageProfileMojo
/**
* @parameter
*/
private List<String> repositoryIds;
private Set<String> repositoryIds = new LinkedHashSet<String>();

/**
* @parameter expression="${description}"
*/
private String description;
private String description;

/**
* @parameter expression="${stagingBuildPromotionProfileId}"
Expand Down Expand Up @@ -98,23 +98,23 @@ public void execute()
getLog().info( "\n\nNo closed repositories found. Nothing to do!\n\n" );
return;
}
if( profiles == null || profiles.isEmpty() )

if ( profiles == null || profiles.isEmpty() )
{
getLog().info( "\n\nNo build promotion profiles found. Nothing to do!\n\n" );
return;
}

// select build promotion profile
promptForStagingBuildPromotionProfileId( profiles );

// select repositories
// prompt if not already set
if( (this.getRepositoryIds() == null || this.getRepositoryIds().isEmpty()) )
if ( ( this.getRepositoryIds() == null || this.getRepositoryIds().isEmpty() ) )
{
promptForRepositoryIds( repos );
}

// enter description
promptForDescription();

Expand All @@ -124,9 +124,9 @@ public void execute()
builder.append( "\n\n" );
for ( String repoId : getRepositoryIds() )
{
builder.append( "- " ).append( repoId );
builder.append( "- " ).append( repoId );
}

builder.append( "\n\n" );

getLog().info( builder.toString() );
Expand Down Expand Up @@ -178,9 +178,9 @@ private void promptForStagingBuildPromotionProfileId( List<StageProfile> profile
{
throw new MojoExecutionException( "Failed to read from CLI prompt: " + e.getMessage(), e );
}
catch( NumberFormatException e )
catch ( NumberFormatException e )
{
this.getLog().debug( "Invalid entry: "+ e.getMessage() );
this.getLog().debug( "Invalid entry: " + e.getMessage() );
}
}
}
Expand Down Expand Up @@ -213,23 +213,24 @@ private void promptForRepositoryIds( List<StageRepository> allClosedRepos )
for ( int ii = 0; ii < allClosedRepos.size(); ii++ )
{
StageRepository repo = allClosedRepos.get( ii );
buffer.append( ii + 1 ).append( ". " ).append( repo.getRepositoryId() ).append( " - " ).append( repo.getDescription() ).append( "\n" );
buffer.append( ii + 1 ).append( ". " ).append( repo.getRepositoryId() ).append( " - " ).append(
repo.getDescription() ).append( "\n" );
}

while ( !finished )
{
try
{
getPrompter().showMessage( buffer.toString() );

String answer = getPrompter().prompt( "Repository: " );
int pos = Integer.parseInt( answer ) - 1;

// validate the result
if ( pos >= 0 && pos < allClosedRepos.size() )
{
getRepositoryIds().add( allClosedRepos.get( pos ).getRepositoryId() );

if ( !PromptUtil.booleanPrompt( getPrompter(), "Add another Repository? [Y/n]", Boolean.TRUE ) )
{
// signal end of loop
Expand All @@ -242,9 +243,9 @@ private void promptForRepositoryIds( List<StageRepository> allClosedRepos )
{
throw new MojoExecutionException( "Failed to read from CLI prompt: " + e.getMessage(), e );
}
catch( NumberFormatException e )
catch ( NumberFormatException e )
{
this.getLog().debug( "Invalid entry: "+ e.getMessage() );
this.getLog().debug( "Invalid entry: " + e.getMessage() );
}
}
}
Expand All @@ -253,14 +254,15 @@ public Set<String> getRepositoryIds()
{
if ( ( repositoryIds == null || repositoryIds.isEmpty() ) && super.getRepositoryId() != null )
{
this.repositoryIds = Collections.singletonList( getRepositoryId() );
this.repositoryIds = Collections.singleton( getRepositoryId() );
}
return new LinkedHashSet<String>( repositoryIds );

return repositoryIds;
}

public void setRepositoryIds( Set<String> repositoryIds )
{
this.repositoryIds = new ArrayList<String>( repositoryIds );
this.repositoryIds = repositoryIds;
}

public String getDescription()
Expand Down

0 comments on commit c8765db

Please sign in to comment.