You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stephen Connolly <st...@gmail.com> on 2009/03/12 12:00:45 UTC
Maven-Ant-Tasks and deploy
So we have this legacy build that uses ANT.
Normally I would just convert the build to Maven... but this one is too
crufty for me... and time is too tight.
So enter maven-ant-tasks...
I'm having problems deploying to our internal repository (which is using
nexus)
To try and resolve this I created a stripped down ant build like so:
<project name="ant-mvn-deploy-test" basedir="."
xmlns:artifact="urn:maven-artifact-ant">
<property name="groupId" value="local.test"/>
<property name="artifactId" value="ant-mvn-deploy-test"/>
<property name="version" value="1.0-SNAPSHOT"/>
<property name="src.dir" value="${basedir}/src/main/java"/>
<property name="build.dir" value="${basedir}/target"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="finalName" value="${artifactId}-${version}.jar"/>
<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.0.9.jar"
/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="maven-ant-tasks.classpath" />
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}"/>
</target>
<target name="package" depends="compile">
<jar destfile="${build.dir}/${finalName}" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="HelloWorld"/>
</manifest>
</jar>
</target>
<target name="install" depends="package">
<artifact:pom id="maven.project" file="pom.xml"/>
<artifact:install file="${build.dir}/${finalName}">
<pom refid="maven.project"/>
</artifact:install>
</target>
<target name="deploy" depends="install">
<artifact:pom id="maven.project" file="pom.xml"/>
<artifact:deploy file="${build.dir}/${finalName}">
<pom refid="maven.project"/>
</artifact:deploy>
</target>
</project>
And I have the pom.xml that this should deploy with like so:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>local.test</groupId>
<artifactId>ant-mvn-deploy-test</artifactId>
<version>1.0-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>
<id>local.snapshot</id>
<name>Local snapshot repository</name>
<url>${snapshot.deploy.url}</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
<repository>
<id>local</id>
<name>Local release repository</name>
<url>${release.deploy.url}</url>
</repository>
</distributionManagement>
</project>
If I run mvn clean deploy everything works just fine and dandy
If I run ant clean deploy it bombs out with a 401 error code.
[artifact:deploy] Deploying to http://_______/nexus/content/groups/public
[artifact:deploy] [INFO] Retrieving previous build number from
local.snapshot
[artifact:deploy] [INFO] repository metadata for: 'snapshot
local.test:ant-mvn-deploy-test:1.0-SNAPSHOT' could not be found on
repository: local.snapshot, so will be created
[artifact:deploy] Uploading:
local/test/ant-mvn-deploy-test/1.0-SNAPSHOT/ant-mvn-deploy-test-1.0-SNAPSHOT.jar
to local.snapshot
[artifact:deploy] Uploaded 1K
[artifact:deploy] An error has occurred while processing the Maven artifact
tasks.
[artifact:deploy] Diagnosis:
[artifact:deploy]
[artifact:deploy] Error deploying artifact
'local.test:ant-mvn-deploy-test:jar': Error deploying artifact: Failed to
transfer file: http://______/nexus/content/groups/public/local/test/ant-mvn-deploy-test/1.0-SNAPSHOT/ant-mvn-deploy-test-1.0-SNAPSHOT.jar.
Return code is: 401
BUILD FAILED
I've tried adding wagon-http, wagon-webdav, etc. with no luck... anyone have
any suggestions?
-Stephen
Re: Maven-Ant-Tasks and deploy
Posted by Stephen Connolly <st...@gmail.com>.
OK I found the work-around.... although I do not think this should be
necessary (at least according to the docs)
<artifact:remoteRepository id="local.release" url="http://
_____/nexus/content/repositories/local">
<releases enabled="true"/>
<snapshots enabled="false"/>
</artifact:remoteRepository>
<artifact:remoteRepository id="local.snapshot" url="http://
_____/nexus/content/repositories/local-snapshots">
<releases enabled="false"/>
<snapshots enabled="true"/>
</artifact:remoteRepository>
<artifact:pom id="maven.project" file="pom.xml"/>
<artifact:deploy file="${build.dir}/${finalName}">
<remoteRepository refid="local.release"/>
<remoteRepository refid="local.snapshot"/>
<pom refid="maven.project"/>
</artifact:deploy>
But still at least it works now!
2009/3/12 Stephen Connolly <st...@gmail.com>
> So we have this legacy build that uses ANT.
>
> Normally I would just convert the build to Maven... but this one is too
> crufty for me... and time is too tight.
>
> So enter maven-ant-tasks...
>
> I'm having problems deploying to our internal repository (which is using
> nexus)
>
> To try and resolve this I created a stripped down ant build like so:
>
> <project name="ant-mvn-deploy-test" basedir="."
> xmlns:artifact="urn:maven-artifact-ant">
>
> <property name="groupId" value="local.test"/>
> <property name="artifactId" value="ant-mvn-deploy-test"/>
> <property name="version" value="1.0-SNAPSHOT"/>
>
> <property name="src.dir" value="${basedir}/src/main/java"/>
> <property name="build.dir" value="${basedir}/target"/>
> <property name="classes.dir" value="${build.dir}/classes"/>
> <property name="finalName" value="${artifactId}-${version}.jar"/>
>
> <path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.0.9.jar"
> />
> <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
> uri="urn:maven-artifact-ant"
> classpathref="maven-ant-tasks.classpath" />
>
> <target name="clean">
> <delete dir="${build.dir}"/>
> </target>
>
> <target name="compile">
> <mkdir dir="${classes.dir}"/>
> <javac srcdir="${src.dir}" destdir="${classes.dir}"/>
> </target>
>
> <target name="package" depends="compile">
> <jar destfile="${build.dir}/${finalName}" basedir="${classes.dir}">
> <manifest>
> <attribute name="Main-Class" value="HelloWorld"/>
> </manifest>
> </jar>
> </target>
>
> <target name="install" depends="package">
> <artifact:pom id="maven.project" file="pom.xml"/>
> <artifact:install file="${build.dir}/${finalName}">
> <pom refid="maven.project"/>
> </artifact:install>
> </target>
>
> <target name="deploy" depends="install">
> <artifact:pom id="maven.project" file="pom.xml"/>
> <artifact:deploy file="${build.dir}/${finalName}">
> <pom refid="maven.project"/>
> </artifact:deploy>
> </target>
>
> </project>
>
> And I have the pom.xml that this should deploy with like so:
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>local.test</groupId>
> <artifactId>ant-mvn-deploy-test</artifactId>
> <version>1.0-SNAPSHOT</version>
> <distributionManagement>
> <snapshotRepository>
> <id>local.snapshot</id>
> <name>Local snapshot repository</name>
> <url>${snapshot.deploy.url}</url>
> <uniqueVersion>false</uniqueVersion>
> </snapshotRepository>
> <repository>
> <id>local</id>
> <name>Local release repository</name>
> <url>${release.deploy.url}</url>
> </repository>
> </distributionManagement>
> </project>
>
> If I run mvn clean deploy everything works just fine and dandy
>
> If I run ant clean deploy it bombs out with a 401 error code.
>
> [artifact:deploy] Deploying to http://_______/nexus/content/groups/public
> [artifact:deploy] [INFO] Retrieving previous build number from
> local.snapshot
> [artifact:deploy] [INFO] repository metadata for: 'snapshot
> local.test:ant-mvn-deploy-test:1.0-SNAPSHOT' could not be found on
> repository: local.snapshot, so will be created
> [artifact:deploy] Uploading:
> local/test/ant-mvn-deploy-test/1.0-SNAPSHOT/ant-mvn-deploy-test-1.0-SNAPSHOT.jar
> to local.snapshot
> [artifact:deploy] Uploaded 1K
> [artifact:deploy] An error has occurred while processing the Maven artifact
> tasks.
> [artifact:deploy] Diagnosis:
> [artifact:deploy]
> [artifact:deploy] Error deploying artifact
> 'local.test:ant-mvn-deploy-test:jar': Error deploying artifact: Failed to
> transfer file: http://______/nexus/content/groups/public/local/test/ant-mvn-deploy-test/1.0-SNAPSHOT/ant-mvn-deploy-test-1.0-SNAPSHOT.jar.
> Return code is: 401
>
> BUILD FAILED
>
>
> I've tried adding wagon-http, wagon-webdav, etc. with no luck... anyone
> have any suggestions?
>
> -Stephen
>
>
>
>