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

Commit

Permalink
[MGPG-3, MGPG-5, MGPG-6, MGPG-8]
Browse files Browse the repository at this point in the history
Bunch of fixes that have been sitting on my hard disk for way too long.  
Update pom to declare all depenencies explicitely.




git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@533089 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Apr 27, 2007
1 parent 8af28dc commit ac97a13
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 19 deletions.
22 changes: 19 additions & 3 deletions maven-gpg-plugin/pom.xml
Expand Up @@ -20,18 +20,34 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0</version>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>2.0</version>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.2</version>
</dependency>


<dependency>
<groupId>commons-lang</groupId>
Expand Down
Expand Up @@ -34,6 +34,7 @@
import org.codehaus.plexus.util.cli.Commandline;
import org.codehaus.plexus.util.cli.DefaultConsumer;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.SelectorUtils;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -62,6 +63,11 @@ public class GpgSignAttachedMojo
extends AbstractMojo
{
public static final String SIGNATURE_EXTENSION = ".asc";
private static final String DEFAULT_EXCLUDES[] = new String[] {
"**/*.md5",
"**/*.sha1",
"**/*.asc"
};

/**
* The passphrase to use when signing.
Expand Down Expand Up @@ -95,6 +101,16 @@ public class GpgSignAttachedMojo
*/
private boolean skip;


/**
* A list of files to exclude from being signed. Can contain ant-style
* wildcards and double wildcards. The default includes are
* <code>**&#47;*.md5 **&#47;*.sha1 **&#47;*.asc</code>
*
* @parameter
* @since 1.0-alpha-4
*/
private String[] excludes;

/**
* The maven project.
Expand Down Expand Up @@ -142,6 +158,25 @@ public void execute()
return;
}

if ( excludes == null || excludes.length == 0 )
{
excludes = DEFAULT_EXCLUDES;
}
String newExcludes[] = new String[excludes.length];
for ( int i = 0; i < excludes.length; i++ )
{
String pattern;
pattern = excludes[i].trim().replace( '/', File.separatorChar ).replace(
'\\', File.separatorChar );
if ( pattern.endsWith( File.separator ) )
{
pattern += "**";
}
newExcludes[i] = pattern;
}
excludes = newExcludes;


if ( !useAgent && null == pass )
{
if ( !settings.isInteractiveMode() )
Expand Down Expand Up @@ -175,7 +210,10 @@ public void execute()

File projectArtifactSignature = generateSignatureForArtifact( projectArtifact, pass );

signingBundles.add( new SigningBundle( project.getArtifact().getType(), projectArtifactSignature ) );
if ( projectArtifactSignature != null )
{
signingBundles.add( new SigningBundle( project.getArtifact().getType(), projectArtifactSignature ) );
}
}

// ----------------------------------------------------------------------------
Expand All @@ -195,7 +233,10 @@ public void execute()

File pomSignature = generateSignatureForArtifact( pomToSign, pass );

signingBundles.add( new SigningBundle( "pom", pomSignature ) );
if ( pomSignature != null )
{
signingBundles.add( new SigningBundle( "pom", pomSignature ) );
}

// ----------------------------------------------------------------------------
// Attached artifacts
Expand All @@ -209,7 +250,10 @@ public void execute()

File signature = generateSignatureForArtifact( file, pass );

signingBundles.add( new SigningBundle( artifact.getType(), artifact.getClassifier(), signature ) );
if ( signature != null )
{
signingBundles.add( new SigningBundle( artifact.getType(), artifact.getClassifier(), signature ) );
}
}

// ----------------------------------------------------------------------------
Expand All @@ -230,9 +274,9 @@ public void execute()

ArtifactHandler ah = artifactHandlerManager.getArtifactHandler( bundle.getArtifactType() );

if ( bundle.getClassifier() != null )
if ( bundle.getClassifier() != null
&& !"".equals( bundle.getClassifier() ) )
{

projectHelper.attachArtifact( project, "asc", bundle.getClassifier() + "." + ah.getExtension(),
bundle.getSignature() );
}
Expand Down Expand Up @@ -287,7 +331,12 @@ private File generateSignatureForArtifact( File file , String pass)
cmd.createArgument().setValue( "--armor" );

cmd.createArgument().setValue( "--detach-sign" );


if ( !settings.isInteractiveMode() )
{
cmd.createArgument().setValue( "--no-tty" );
}

cmd.createArgument().setFile( file );


Expand All @@ -308,15 +357,6 @@ private File generateSignatureForArtifact( File file , String pass)
return signature;
}

//TODO: This must be made to work generally or the packaging plugins must
// set the project artifact as part of what they do. We should not have to
// guess or synthesize what project artifact is here. It should have happened
// already. We'll settle for JAR files right now.
protected File getProjectFile( String basedir,
String finalName )
{
return new File( basedir, finalName + ".jar" );
}

private MavenProject findReactorProject(MavenProject prj) {
if ( prj.getParent() != null )
Expand All @@ -328,6 +368,25 @@ private MavenProject findReactorProject(MavenProject prj) {
}
return prj;
}
/**
* Tests whether or not a name matches against at least one exclude
* pattern.
*
* @param name The name to match. Must not be <code>null</code>.
* @return <code>true</code> when the name matches against at least one
* exclude pattern, or <code>false</code> otherwise.
*/
protected boolean isExcluded( String name )
{
for ( int i = 0; i < excludes.length; i++ )
{
if ( SelectorUtils.matchPath( excludes[i], name ) )
{
return true;
}
}
return false;
}

protected String getPassphrase() throws IOException
{
Expand All @@ -349,7 +408,7 @@ protected String getPassphrase() throws IOException
System.in.read();
}

System.out.print("GPG Passphrase: ");
System.out.print("GPG Passphrase: ");
MaskingThread thread = new MaskingThread();
thread.start();

Expand Down

0 comments on commit ac97a13

Please sign in to comment.