Hello Lewis,

there is a project in the commons sandbox at Apache with which you can PGP sign 
artifacts in an Ant build

The source code is there [1]

There is an example of usage of this here [2] 

We use that when producing releases of Ant.

Maybe this can help you ?

Regards,

Antoine

[1]  http://svn.apache.org/repos/asf/commons/sandbox/openpgp/trunk/
[2] http://svn.apache.org/repos/asf/ant/core/trunk/release/signit.xml



On Jan 29, 2013, at 6:47 PM, Lewis John Mcgibbney wrote:

> Hi,
> Having looked high and low for a resolution, I've been unable to find one.
> I'm in the process of pushing a release on a small project which uses ant
> tasks + maven for the build lifecycle.
> I am attempting to deploy to sonatype staging repository with the following
> configuration
> 
> ...
>     <!-- defined maven snapshots and staging repository id and url -->
>     <property name="maven-snapshots-repository-id"
> value="sonatype-nexus-snapshots" />
>     <property name="maven-snapshots-repository-url"
>         value="https://oss.sonatype.org/content/repositories/snapshots/";;
> />
>     <property name="maven-staging-repository-id"
> value="sonatype-nexus-staging" />
>     <property name="maven-staging-repository-url"
>         value="
> https://oss.sonatype.org/service/local/staging/deploy/maven2/";;
> />
> ...
>     <target name="stage" depends="dist"
>         description="--> deploy release version to Maven staging
> repository"
>         xmlns:artifact="urn:maven-artifact-ant">
>         <!-- sign and deploy the main artifact -->
>         <artifact:mvn>
>             <arg
> 
> value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file"
> />
>             <arg value="-Durl=${maven-staging-repository-url}" />
>             <arg value="-DrepositoryId=${maven-staging-repository-id}" />
>             <arg value="-DpomFile=pom.xml" />
>             <arg value="-Dfile=${maven-jar}" />
>             <arg value="-Pgpg" />
>         </artifact:mvn>
> 
>         <!-- sign and deploy the sources artifact -->
>         <artifact:mvn>
>             <arg
> 
> value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file"
> />
>             <arg value="-Durl=${maven-staging-repository-url}" />
>             <arg value="-DrepositoryId=${maven-staging-repository-id}" />
>             <arg value="-DpomFile=pom.xml" />
>             <arg value="-Dfile=${maven-sources-jar}" />
>             <arg value="-Dclassifier=sources" />
>             <arg value="-Pgpg" />
>         </artifact:mvn>
> 
>         <!-- sign and deploy the javadoc artifact -->
>         <artifact:mvn>
>             <arg
> 
> value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file"
> />
>             <arg value="-Durl=${maven-staging-repository-url}" />
>             <arg value="-DrepositoryId=${maven-staging-repository-id}" />
>             <arg value="-DpomFile=pom.xml" />
>             <arg value="-Dfile=${maven-javadoc-jar}" />
>             <arg value="-Dclassifier=javadoc" />
>             <arg value="-Pgpg" />
>         </artifact:mvn>
>     </target>
> 
> However when I run the stage target, I get the following
> 
> [artifact:mvn] [INFO]    task-segment:
> [org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file]
> (aggregator-style)
> [artifact:mvn] [INFO]
> ------------------------------------------------------------------------
> [artifact:mvn] [INFO] [gpg:sign-and-deploy-file]
> [artifact:mvn] [INFO]
> ------------------------------------------------------------------------
> [artifact:mvn] [ERROR] BUILD FAILURE
> [artifact:mvn] [INFO]
> ------------------------------------------------------------------------
> [artifact:mvn] [INFO] Cannot obtain passphrase in batch mode
> [artifact:mvn] [INFO]
> ------------------------------------------------------------------------
> [artifact:mvn] [INFO] For more information, run Maven with the -e switch
> [artifact:mvn] [INFO]
> ------------------------------------------------------------------------
> [artifact:mvn] [INFO] Total time: 2 seconds
> [artifact:mvn] [INFO] Finished at: Sun Jan 27 21:37:35 PST 2013
> [artifact:mvn] [INFO] Final Memory: 16M/40M
> [artifact:mvn] [INFO]
> ------------------------------------------------------------------------
> [artifact:mvn] Java Result: 1
> 
> There is very little on the dreaded "Cannot obtain passphrase in batch
> mode".
> Even when I use overrides on the command line e.g. ant stage
> -Dpassphrase=${passphrase}, I still get the above.
> 
> Does anyone have a suggestion on how I can run Maven (from an Ant
> task) to operate in interactive (non-batch) mode?
> 
> Any ideas? Thanks very much in advance
> 
> Lewis
> 
> 
> 
> -- 
> *Lewis*

Reply via email to