You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sc...@apache.org on 2015/12/17 17:11:58 UTC
svn commit: r1720607 - in /maven/plugins/trunk/maven-jarsigner-plugin:
pom.xml
src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java
Author: schulte
Date: Thu Dec 17 16:11:58 2015
New Revision: 1720607
URL: http://svn.apache.org/viewvc?rev=1720607&view=rev
Log:
[MJARSIGNER-17] The plugin should pass proxy information to the jarsigner command.
o Updated to pass the active proxy from the Maven settings to 'jarsigner'.
o Updated to pass the 'file.encoding' the plugin is executed with to 'jarsigner'.
Modified:
maven/plugins/trunk/maven-jarsigner-plugin/pom.xml
maven/plugins/trunk/maven-jarsigner-plugin/src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java
Modified: maven/plugins/trunk/maven-jarsigner-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jarsigner-plugin/pom.xml?rev=1720607&r1=1720606&r2=1720607&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jarsigner-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-jarsigner-plugin/pom.xml Thu Dec 17 16:11:58 2015
@@ -86,6 +86,11 @@ under the License.
<version>${mavenVersion}</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-settings</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
Modified: maven/plugins/trunk/maven-jarsigner-plugin/src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jarsigner-plugin/src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java?rev=1720607&r1=1720606&r2=1720607&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jarsigner-plugin/src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java (original)
+++ maven/plugins/trunk/maven-jarsigner-plugin/src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java Thu Dec 17 16:11:58 2015
@@ -26,6 +26,7 @@ import org.apache.maven.plugin.MojoExecu
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.settings.Settings;
import org.apache.maven.shared.jarsigner.JarSigner;
import org.apache.maven.shared.jarsigner.JarSignerRequest;
import org.apache.maven.shared.jarsigner.JarSignerUtil;
@@ -42,11 +43,13 @@ import org.sonatype.plexus.components.se
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.ResourceBundle;
+import org.apache.maven.shared.utils.ReaderFactory;
/**
* Maven Jarsigner Plugin base class.
@@ -217,6 +220,14 @@ public abstract class AbstractJarsignerM
private MavenProject project;
/**
+ * The Maven settings.
+ *
+ * @since 1.5
+ */
+ @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+ private Settings settings;
+
+ /**
* Location of the working directory.
*
* @since 1.3
@@ -495,9 +506,61 @@ public abstract class AbstractJarsignerM
request.setProviderName( providerName );
request.setWorkingDirectory( workingDirectory );
request.setMaxMemory( maxMemory );
- request.setArguments( arguments );
request.setProtectedAuthenticationPath( protectedAuthenticationPath );
+ // Preserves 'file.encoding' the plugin is executed with.
+ final List<String> additionalArguments = new ArrayList<String>();
+
+ boolean fileEncodingSeen = false;
+
+ if ( this.arguments != null )
+ {
+ for ( final String argument : this.arguments )
+ {
+ if ( argument.trim().startsWith( "-J-Dfile.encoding=" ) )
+ {
+ fileEncodingSeen = true;
+ }
+
+ additionalArguments.add( argument );
+ }
+ }
+
+ if ( !fileEncodingSeen )
+ {
+ additionalArguments.add( "-J-Dfile.encoding=" + ReaderFactory.FILE_ENCODING );
+ }
+
+ // Adds proxy information.
+ if ( this.settings != null && this.settings.getActiveProxy() != null
+ && StringUtils.isNotEmpty( this.settings.getActiveProxy().getHost() ) )
+ {
+ additionalArguments.add( "-J-Dhttp.proxyHost=" + this.settings.getActiveProxy().getHost() );
+ additionalArguments.add( "-J-Dhttps.proxyHost=" + this.settings.getActiveProxy().getHost() );
+ additionalArguments.add( "-J-Dftp.proxyHost=" + this.settings.getActiveProxy().getHost() );
+
+ if ( this.settings.getActiveProxy().getPort() > 0 )
+ {
+ additionalArguments.add( "-J-Dhttp.proxyPort=" + this.settings.getActiveProxy().getPort() );
+ additionalArguments.add( "-J-Dhttps.proxyPort=" + this.settings.getActiveProxy().getPort() );
+ additionalArguments.add( "-J-Dftp.proxyPort=" + this.settings.getActiveProxy().getPort() );
+ }
+
+ if ( StringUtils.isNotEmpty( this.settings.getActiveProxy().getNonProxyHosts() ) )
+ {
+ additionalArguments.add( "-J-Dhttp.nonProxyHosts=\""
+ + this.settings.getActiveProxy().getNonProxyHosts() + "\"" );
+
+ additionalArguments.add( "-J-Dftp.nonProxyHosts=\""
+ + this.settings.getActiveProxy().getNonProxyHosts() + "\"" );
+
+ }
+ }
+
+ request.setArguments( !additionalArguments.isEmpty()
+ ? additionalArguments.toArray( new String[ additionalArguments.size() ] )
+ : null );
+
// Special handling for passwords through the Maven Security Dispatcher
request.setStorepass( decrypt( storepass ) );