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

Simplify PerformReleaseMojo #145

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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 @@ -20,14 +20,11 @@
*/

import java.io.File;
import java.util.Map;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.shared.release.DefaultReleaseManagerListener;
import org.apache.maven.shared.release.ReleaseExecutionException;
import org.apache.maven.shared.release.ReleaseFailureException;
Expand All @@ -46,7 +43,7 @@
*/
@Mojo( name = "perform", aggregator = true, requiresProject = false )
public class PerformReleaseMojo
extends AbstractReleaseMojo
extends AbstractScmReleaseMojo
{
/**
* A space separated list of goals to execute on release perform. Default value is either <code>deploy</code> or
Expand Down Expand Up @@ -88,18 +85,6 @@ public class PerformReleaseMojo
@Parameter( defaultValue = "false", property = "localCheckout" )
private boolean localCheckout;

/**
* The SCM username to use.
*/
@Parameter( property = "username" )
private String username;

/**
* The SCM password to use.
*/
@Parameter( property = "password" )
private String password;

/**
* When cloning a repository if it should be a shallow clone or a full clone.
*/
Expand All @@ -125,23 +110,6 @@ public class PerformReleaseMojo
@Parameter( defaultValue = "false", property = "dryRun" )
private boolean dryRun;

/**
* Add a new or overwrite the default implementation per provider.
* The key is the scm prefix and the value is the role hint of the
* {@link org.apache.maven.scm.provider.ScmProvider}.
*
* @since 2.5.3
* @see ScmManager#setScmProviderImplementation(String, String)
*/
@Parameter
private Map<String, String> providerImplementations;

/**
* The SCM manager.
*/
@Component
private ScmManager scmManager;

@Override
protected String getAdditionalProfiles()
{
Expand All @@ -152,15 +120,7 @@ protected String getAdditionalProfiles()
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( providerImplementations != null )
{
for ( Map.Entry<String, String> providerEntry : providerImplementations.entrySet() )
{
getLog().info( "Change the default '" + providerEntry.getKey() + "' provider implementation to '"
+ providerEntry.getValue() + "'." );
scmManager.setScmProviderImplementation( providerEntry.getKey(), providerEntry.getValue() );
}
}
super.execute();

// goals may be splitted into multiple line in configuration.
// Let's build a single line command
Expand All @@ -179,16 +139,6 @@ public void execute()
releaseDescriptor.setScmSourceUrl( connectionUrl );
}

if ( username != null )
{
releaseDescriptor.setScmUsername( username );
}

if ( password != null )
{
releaseDescriptor.setScmPassword( password );
}

Comment on lines -182 to -191
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure this should be removed?
Now the releaseDescriptor no longer has these values.
There is no scenario when during the perform release the username/password are needed?
If there is no such scenario: Why do you keep the scm source url? I the ScmSourceUrl is needed then I would suspect the username and password are also needed in some cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is IMHO already part of AbstractScmReleaseMojo.createReleaseDescriptor()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwin You are right.

releaseDescriptor.setScmShallowClone( scmShallowClone );

releaseDescriptor.setLocalCheckout( localCheckout );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/**
* <p>Stub for a MavenProject with a flat structure.</p>
*
*
* <p>TODO: shouldn't need to do this, but the "stub" in the harness just throws away values you set.
* Just overriding the ones I need for this plugin.</p>
*
Expand All @@ -40,7 +40,7 @@
*/
public class FlatMultiModuleMavenProjectStub
extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
{
{
public void setDistributionManagement( DistributionManagement distributionManagement )
{
getModel().setDistributionManagement( distributionManagement );
Expand All @@ -57,46 +57,57 @@ public Model getModel()
return model;
}

@Override
public Model getOriginalModel() {
Model originalModel = super.getOriginalModel();
if ( originalModel == null )
{
originalModel = new Model();
setOriginalModel( originalModel );
}
return originalModel;
}

public DistributionManagement getDistributionManagement()
{
return getModel().getDistributionManagement();
}

public List<String> getModules()
{
List<String> modules = new ArrayList<String>();
modules.add( "../core" );
modules.add( "../webapp" );
modules.add( "../commons" );

return modules;
}

public File getBasedir()
{
return new File( "/flat-multi-module/root-project" ).getAbsoluteFile();
}

public Scm getScm()
{
Scm scm = new Scm();
scm.setConnection( "scm:svn:file://localhost/target/svnroot/flat-multi-module/trunk/root-project" );

return scm;
}

@Override
public String getGroupId()
{
return "GROUPID";
}

@Override
public String getArtifactId()
{
return "ARTIFACTID";
}

@Override
public String getVersion()
{
Expand Down