| <project name="maven-ant-tasks" default="test-all" xmlns:artifact="urn:maven-artifact-ant"> |
| <!-- |
| <project name="foo" default="foo" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> |
| --> |
| <!-- |
| You either need to run the the 'initTaskDefs' task below and |
| define the artifact namespace like above (choose anything you |
| like except strings that start with 'antlib:'), |
| and be sure to supply the path to the maven-artifact-ant jars |
| |
| OR |
| |
| just define the artifact namespace as follows: |
| |
| xmlns:artifact="antlib:org.apache.maven.artifact.ant" |
| |
| and be sure to add the maven-artifact-ant jars to the ant |
| classpath (either by setting the CLASSPATH environment variable |
| before calling ant, or place the jars in the $ANT_HOME/lib directory). |
| |
| --> |
| |
| <target name="initTaskDefs"> |
| <xmlproperty file="pom.xml" prefix="pom.xml" /> |
| |
| <path id="maven-ant-tasks.classpath" path="target/maven-ant-tasks-${pom.xml.project.version}.jar" /> |
| <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" |
| classpathref="maven-ant-tasks.classpath"/> |
| |
| <artifact:localRepository id="local.repository" path="${basedir}/target/local-repo" layout="default"/> |
| |
| <property name="deploy.repository.url" value="${basedir}/target/deployment-repo" /> |
| <artifact:remoteRepository id="deploy.repository" url="file://localhost/${deploy.repository.url}" layout="default"/> |
| |
| <artifact:pom file="pom.xml" id="maven.project"/> |
| </target> |
| |
| <target name="installSshProvider" depends="initTaskDefs"> |
| <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-2"/> |
| </target> |
| |
| <target name="test-all-deps" description="All dependencies tests" |
| depends="test-pom,test-pom-with-parent,test-no-deps,test-pom-deps,test-deps-two-repos,test-deps,test-legacy-pom,test-deps-mirror,test-deps-order"> |
| <echo>test-bad-dep and test-invalid-pom-ref must be run manually, since they are intended to fail</echo> |
| </target> |
| |
| <target name="test-all-pubs" description="All publication tests (install/deploy)" |
| depends="test-deploy-spaces,test-deploy,test-no-dist-mgmt,test-install-attached,test-deploy-attached"/> |
| |
| <target name="test-all" description="All tests" |
| depends="test-all-deps,test-all-pubs,test-install-provider"> |
| <echo>test-scm not run, since it fails...</echo> |
| </target> |
| |
| <target name="test-no-deps" depends="initTaskDefs"> |
| <artifact:dependencies filesetId="runtime.fileset" pathId="empty.dependency.classpath"> |
| </artifact:dependencies> |
| <copy todir="target/test-no-deps" verbose="true"> |
| <fileset refid="runtime.fileset"/> |
| </copy> |
| <property name="empty.property" refid="empty.dependency.classpath"/> |
| </target> |
| |
| <target name="test-empty-settings" depends="initTaskDefs"> |
| <artifact:dependencies filesetId="runtime.fileset" settingsFile="${basedir}/src/test/settings-empty.xml"> |
| </artifact:dependencies> |
| </target> |
| |
| <target name="test-bad-dep" depends="initTaskDefs"> |
| <artifact:dependencies pathId="dependency.classpath" filesetId="dependency.fileset"> |
| <dependency groupId="foo" artifactId="foo" version="1.0-alpha-2"/> |
| </artifact:dependencies> |
| </target> |
| |
| <target name="test-pom" depends="initTaskDefs"> |
| <artifact:pom file="pom.xml" id="my.maven.project"/> |
| |
| <echo>Artifact ID = ${my.maven.project.artifactId}</echo> |
| |
| <echo>Parent Artifact ID = ${my.maven.project.parent.artifactId}</echo> |
| |
| <fail message="failed to get pom info ${my.maven.project.artifactId}"> |
| <condition> |
| <not><equals arg1="${my.maven.project.artifactId}" arg2="${pom.xml.project.artifactId}"/></not> |
| </condition> |
| </fail> |
| |
| <echo>Maven Core Version = ${my.maven.project.properties.mavenVersion}</echo> |
| |
| <fail message="failed to get pom properties ${my.maven.project.properties.mavenVersion}"> |
| <condition> |
| <not><equals arg1="${my.maven.project.properties.mavenVersion}" arg2="${pom.xml.project.properties.mavenVersion}"/></not> |
| </condition> |
| </fail> |
| </target> |
| |
| <target name="test-legacy-pom" depends="initTaskDefs"> |
| <artifact:dependencies> |
| <dependency groupId="geronimo-spec" artifactId="geronimo-spec-javamail" version="1.3.1-rc5" /> |
| <localRepository path="${basedir}/target/local-repo-legacy" /> |
| <remoteRepository url="http://repo1.maven.org/maven" layout="legacy" id="central" /> |
| </artifact:dependencies> |
| </target> |
| |
| <target name="test-deps" depends="initTaskDefs"> |
| <artifact:dependencies pathId="dependency.classpath" filesetId="dependency.fileset" sourcesFilesetId="sources.fileset" verbose="true" versionsId="dependency.versions"> |
| <dependency groupId="org.apache.maven.wagon" artifactId="wagon-provider-test" version="1.0-alpha-4"> |
| <exclusion groupId="junit" artifactId="junit"/> |
| </dependency> |
| <dependency groupId="org.apache.maven" artifactId="maven-core-it-support-old-location" version="1.1"/> |
| <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueFalse" version="2.0.7-SNAPSHOT"/> |
| <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueTrue" version="2.0.7-SNAPSHOT"/> |
| <localRepository refid="local.repository"/> |
| <remoteRepository url="http://repo1.maven.org/maven2" id="central" /> |
| <remoteRepository url="file://${user.dir}/src/test/repo" id="test.repo"> |
| <snapshots enabled="true"/> |
| <releases enabled="false"/> |
| </remoteRepository> |
| </artifact:dependencies> |
| |
| <copy todir="target/files/binaries"> |
| <fileset refid="dependency.fileset"/> |
| </copy> |
| <copy todir="target/files/sources"> |
| <fileset refid="sources.fileset"/> |
| </copy> |
| <available file="target/files/binaries/junit/junit" type="dir" property="exclusion.dependency"/> |
| <fail if="exclusion.dependency">excluded dependency junit:junit shouldn't be in target/files/binaries</fail> |
| <available file="target/files/binaries/it/ant-tasks/snapshotUniqueFalse" type="dir" property="snapshot.dependency.uniqueFalse"/> |
| <fail unless="snapshot.dependency.uniqueFalse">SNAPSHOT dependency it.ant-tasks:snapshotUniqueFalse:2.0.7-SNAPSHOT should be in target/files/binaries</fail> |
| <available file="target/files/binaries/it/ant-tasks/snapshotUniqueTrue" type="dir" property="snapshot.dependency.uniqueTrue"/> |
| <!-- MANTTASKS-18 --> |
| <fail unless="snapshot.dependency.uniqueTrue">SNAPSHOT dependency it.ant-tasks:snapshotUniqueTrue:2.0.7-SNAPSHOT should be in target/files/binaries</fail> |
| |
| <!-- MANTTASKS-84 --> |
| <copy todir="target/files/versionMapperFlatten"> |
| <fileset refid="dependency.fileset"/> |
| <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" |
| from="${dependency.versions}" to="flatten" /> |
| </copy> |
| <available file="target/files/versionMapperFlatten/it" type="dir" property="snapshot.dependency.flatten.failed"/> |
| <fail if="snapshot.dependency.flatten.failed">VersionMapper to="flatten" failed on SNAPSHOT</fail> |
| |
| <!-- MANTTASKS-33 --> |
| <available file="${it.ant-tasks:snapshotUniqueTrue:jar}" property="propertySnapshotUniqueTrue"/> |
| <fail unless="propertySnapshotUniqueTrue">property it.ant-tasks:snapshotUniqueFalse:jar should point to an existing file</fail> |
| |
| <available file="${org.apache.maven:maven-core-it-support:java-source:sources}" property="propertySources"/> |
| <fail unless="propertySources">property org.apache.maven:maven-core-it-support:java-source:sources should point to an existing file</fail> |
| </target> |
| |
| <target name="test-pom-deps" depends="initTaskDefs"> |
| <artifact:dependencies filesetId="maven-ant-tasks.dependency.fileset"> |
| <pom refid="maven.project"/> |
| </artifact:dependencies> |
| |
| <copy todir="target/maven-ant-tasks-dependencies"> |
| <fileset refid="maven-ant-tasks.dependency.fileset"/> |
| </copy> |
| |
| <artifact:dependencies filesetId="maven-ant-tasks.compile.dependency.fileset" versionsId="maven-ant-tasks.compile.dependency.versions" useScope="compile"> |
| <pom refid="maven.project"/> |
| </artifact:dependencies> |
| <echo>dependencies versions: ${maven-ant-tasks.compile.dependency.versions}</echo> |
| |
| <copy todir="target/maven-ant-tasks-compile-dependencies/fileset"> |
| <fileset refid="maven-ant-tasks.compile.dependency.fileset"/> |
| </copy> |
| |
| <copy todir="target/maven-ant-tasks-compile-dependencies/versionMapper"> |
| <fileset refid="maven-ant-tasks.compile.dependency.fileset"/> |
| <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" |
| from="${maven-ant-tasks.compile.dependency.versions}" /> |
| </copy> |
| |
| <copy todir="target/maven-ant-tasks-compile-dependencies/versionMapperFlatten"> |
| <fileset refid="maven-ant-tasks.compile.dependency.fileset"/> |
| <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" |
| from="${maven-ant-tasks.compile.dependency.versions}" to="flatten" /> |
| </copy> |
| |
| <copy todir="target/maven-ant-tasks-compile-dependencies/WEB-INF/lib"> |
| <fileset refid="maven-ant-tasks.compile.dependency.fileset"/> |
| <mapper type="flatten"/> |
| </copy> |
| </target> |
| |
| <target name="test-deps-mirror" depends="initTaskDefs"> |
| <delete dir="${basedir}/target/tmp"/> |
| <!-- the remoteRepository specified doesn't really exist, but settings declares an existing mirror --> |
| <artifact:dependencies settingsFile="${basedir}/src/test/settings-mirror.xml"> |
| <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueFalse" version="2.0.7-SNAPSHOT"/> |
| <localRepository path="${basedir}/target/tmp"/> |
| <remoteRepository url="file://${basedir}/target/fake/repository" id="fake-repository" /> |
| </artifact:dependencies> |
| |
| <delete dir="${basedir}/target/tmp"/> |
| <!-- the remoteRepository specified doesn't really exist, but settings declares an existing mirror for * --> |
| <artifact:dependencies settingsFile="${basedir}/src/test/settings-mirror-wildcard.xml"> |
| <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueFalse" version="2.0.7-SNAPSHOT"/> |
| <localRepository path="${basedir}/target/tmp"/> |
| <remoteRepository url="file://${basedir}/target/fake/repository" id="any" /> |
| </artifact:dependencies> |
| </target> |
| |
| <target name="test-deps-two-repos" depends="initTaskDefs"> |
| <delete dir="target/tmp"/> |
| <!-- MANTTASKS-78 --> |
| <artifact:dependencies verbose="true"> |
| <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueFalse" version="2.0.7-SNAPSHOT"/> |
| <localRepository path="target/tmp"/> |
| <remoteRepository url="file://${user.dir}/src/test/repo"/> <!-- intentionnally left without id --> |
| <remoteRepository url="file://${user.dir}/target/tmp/fake"/><!-- intentionnally left without id --> |
| </artifact:dependencies> |
| </target> |
| |
| <target name="test-deps-order" depends="initTaskDefs"> |
| <artifact:dependencies pathId="order.path"> |
| <dependency groupId="junit" artifactId="junit" version="3.8.1"/> |
| <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueFalse" version="2.0.7-SNAPSHOT"/> |
| <localRepository refid="local.repository"/> |
| <remoteRepository url="http://repo1.maven.org/maven2" id="central" /> |
| <remoteRepository url="file://${user.dir}/src/test/repo" id="test.repo"> |
| <snapshots enabled="true"/> |
| <releases enabled="false"/> |
| </remoteRepository> |
| </artifact:dependencies> |
| |
| <pathconvert property="order.property" targetos="unix" refid="order.path"> |
| <mapper type="flatten"/> |
| </pathconvert> |
| <condition property="order.ok"> |
| <equals arg1="${order.property}" arg2="junit-3.8.1.jar:snapshotUniqueFalse-2.0.7-SNAPSHOT.jar"/> |
| </condition> |
| <fail unless="order.ok">dependencies junit then it.ant-tasks should be preserved in path: ${order.property}</fail> |
| |
| <artifact:dependencies pathId="reverse.order.path"> |
| <dependency groupId="it.ant-tasks" artifactId="snapshotUniqueFalse" version="2.0.7-SNAPSHOT"/> |
| <dependency groupId="junit" artifactId="junit" version="3.8.1"/> |
| <localRepository refid="local.repository"/> |
| <remoteRepository url="http://repo1.maven.org/maven2" id="central" /> |
| <remoteRepository url="file://${user.dir}/src/test/repo" id="test.repo"> |
| <snapshots enabled="true"/> |
| <releases enabled="false"/> |
| </remoteRepository> |
| </artifact:dependencies> |
| |
| <pathconvert property="reverse.order.property" targetos="unix" refid="reverse.order.path"> |
| <mapper type="flatten"/> |
| </pathconvert> |
| <condition property="reverse.order.ok"> |
| <equals arg1="${reverse.order.property}" arg2="snapshotUniqueFalse-2.0.7-SNAPSHOT.jar:junit-3.8.1.jar"/> |
| </condition> |
| <fail unless="reverse.order.ok">dependencies junit then it.ant-tasks should be preserved in path: ${reverse.order.property}</fail> |
| |
| <artifact:pom file="src/test/pom-order.xml" id="order.project"/> |
| <artifact:dependencies pathId="pom.order.path" verbose="true"> |
| <pom refid="order.project"/> |
| </artifact:dependencies> |
| <pathconvert property="pom.order.property" targetos="unix" refid="pom.order.path"> |
| <mapper type="flatten"/> |
| </pathconvert> |
| <condition property="pom.order.ok"> |
| <equals arg1="${pom.order.property}" arg2="commons-io-1.3.2.jar:commons-lang-2.3.jar:commons-logging-1.1.1.jar:commons-collections-3.2.jar"/> |
| </condition> |
| <fail unless="pom.order.ok">order of dependencies defined in pom should be preserved in path: ${pom.order.property}</fail> |
| </target> |
| |
| <target name="test-deploy-spaces" depends="initTaskDefs,installSshProvider"> |
| <echo file="target/test file.txt">dummy</echo> |
| <artifact:deploy file="target/test file.txt"> |
| <remoteRepository url="scp://localhost/tmp/deployment-repo" id="scp.localhost.repo" /> |
| <pom refid="maven.project"/> |
| </artifact:deploy> |
| </target> |
| |
| <target name="test-deploy" depends="initTaskDefs,installSshProvider"> |
| <property name="outJar" value="${maven.project.build.directory}/${maven.project.build.finalName}.jar"/> |
| <property name="targetDir" value="${deploy.repository.url}/org/apache/maven/maven-ant-tasks/${pom.xml.project.version}"/> |
| <delete dir="${deploy.repository.url}"/> |
| |
| <artifact:install file="${outJar}"> |
| <pom refid="maven.project"/> |
| </artifact:install> |
| |
| <echo>Note: only works on snapshots!</echo> |
| <artifact:deploy file="${outJar}"> |
| <remoteSnapshotRepository refid="deploy.repository"/> |
| <pom refid="maven.project"/> |
| </artifact:deploy> |
| <available file="${targetDir}" property="deploymentArtifactDir"/> |
| <fail unless="deploymentArtifactDir">deployment in ${deploy.repository.url} should have created a directory</fail> |
| <available file="${targetDir}/maven-ant-tasks-${pom.xml.project.version}.jar" property="outJarWithoutUniqueVersion"/> |
| <fail if="outJarWithoutUniqueVersion">uniqueVersion="true" by default: file -SNAPSHOT.jar should not exist</fail> |
| |
| <artifact:deploy file="${outJar}" uniqueVersion="false"> |
| <remoteSnapshotRepository refid="deploy.repository"/> |
| <pom refid="maven.project"/> |
| </artifact:deploy> |
| <available file="${targetDir}/maven-ant-tasks-${pom.xml.project.version}.jar" property="outJarWithoutUniqueVersion"/> |
| <fail unless="outJarWithoutUniqueVersion">when uniqueVersion="false", file -SNAPSHOT.jar should be created</fail> |
| |
| <artifact:deploy file="${outJar}"> |
| <remoteRepository url="scp://localhost/tmp/deployment-repo" id="scp.localhost.repo"> |
| <authentication username="${user.name}" privateKey="${user.home}/.ssh/id_dsa"/> |
| </remoteRepository> |
| <pom refid="maven.project"/> |
| </artifact:deploy> |
| </target> |
| |
| <target name="test-scm" depends="initTaskDefs"> |
| <echo>Testing SCM Wagon</echo> |
| <mkdir dir="target"/> |
| |
| <pathconvert targetos="unix" property="repo.path.unix"> |
| <map from="c:" to=""/> |
| <path> |
| <pathelement location="${basedir}/target/deployment-repo-scm"/> |
| </path> |
| </pathconvert> |
| |
| <property name="scm.url" value="file://${repo.path.unix}"/> |
| |
| <delete dir="${repo.path.unix}"/> |
| |
| <exec executable="svnadmin" failonerror="true"> |
| <arg line="create ${repo.path.unix}"/> |
| </exec> |
| |
| <artifact:localRepository id="local.repository" path="${basedir}/target/local-repo" layout="default"/> |
| |
| <artifact:remoteRepository id="deploy.repository" url="scm:svn:${scm.url}" layout="default"/> |
| |
| <artifact:dependencies pathId="dependency.classpath"> |
| <dependency groupId="org.apache.maven.wagon" artifactId="wagon-provider-test" version="1.0-alpha-4"/> |
| <dependency groupId="org.apache.maven.archiva" artifactId="archiva-configuration" version="1.0-SNAPSHOT"/> |
| <localRepository refid="local.repository"/> |
| </artifact:dependencies> |
| |
| <exec executable="svn" dir="${basedir}/target/local-repo" failonerror="true"> |
| <arg line="import -m 'import' ${scm.url}"/> |
| </exec> |
| |
| <delete dir="${basedir}/target/local-repo-scm"/> |
| |
| <!-- Could the SCM provider initialise this? --> |
| <exec executable="svn" dir="${basedir}/target" failonerror="true"> |
| <arg line="co ${scm.url} -N local-repo-scm"/> |
| </exec> |
| |
| <artifact:localRepository id="local.repository.scm" path="${basedir}/target/local-repo-scm" layout="default"/> |
| |
| <artifact:dependencies pathId="dependency.classpath.scm"> |
| <dependency groupId="org.apache.maven.wagon" artifactId="wagon-provider-test" version="1.0-alpha-4"/> |
| <dependency groupId="org.apache.maven.archiva" artifactId="archiva-configuration" version="1.0-SNAPSHOT"/> |
| <localRepository refid="local.repository.scm"/> |
| <remoteRepository refid="deploy.repository"/> |
| </artifact:dependencies> |
| |
| <property name="outJar" value="${maven.project.build.directory}/${maven.project.build.finalName}.jar"/> |
| <artifact:deploy file="${outJar}"> |
| <localRepository refid="local.repository.scm"/> |
| <remoteRepository refid="deploy.repository"/> |
| <pom refid="maven.project"/> |
| </artifact:deploy> |
| </target> |
| |
| <target name="test-invalid-pom-ref" depends="initTaskDefs"> |
| <artifact:dependencies> |
| <pom refid="invalid-ref" /> |
| </artifact:dependencies> |
| </target> |
| |
| <target name="test-no-dist-mgmt" depends="initTaskDefs"> |
| <artifact:deploy file="sample-build-test.pom"> |
| <pom file="sample-build-test.pom" /> |
| <remoteRepository refid="deploy.repository" /> |
| </artifact:deploy> |
| </target> |
| |
| <target name="test-deploy-attached" depends="initTaskDefs"> |
| <echo message="test" file="${basedir}/target/sample-build-test.pom.asc"/> |
| |
| <artifact:deploy file="sample-build-test.pom"> |
| <pom file="sample-build-test.pom" /> |
| <remoteRepository refid="deploy.repository" /> |
| <attach file="${basedir}/target/sample-build-test.pom.asc" type="pom.asc"/> |
| </artifact:deploy> |
| </target> |
| |
| <target name="test-install-attached" depends="initTaskDefs"> |
| <echo message="test" file="${basedir}/target/sample-build-test.pom.asc"/> |
| |
| <artifact:install file="sample-build-test.pom"> |
| <pom file="sample-build-test.pom" /> |
| <localRepository refid="local.repository"/> |
| <attach file="${basedir}/target/sample-build-test.pom.asc" type="pom.asc"/> |
| </artifact:install> |
| </target> |
| |
| <target name="test-install-provider" depends="initTaskDefs"> |
| <artifact:install-provider groupId="it.ant-tasks" artifactId="wagon-foo" version="1.0-beta-2"> |
| <localRepository refid="local.repository"/> |
| <remoteRepository url="file://${user.dir}/src/test/repo" id="test.repo"/> |
| </artifact:install-provider> |
| </target> |
| |
| <target name="test-pom-with-parent" depends="initTaskDefs"> |
| <artifact:pom file="${user.dir}/src/test/pom-with-parent.xml" id="my.maven.project"> |
| <localRepository refid="local.repository"/> |
| <remoteRepository url="file://${user.dir}/src/test/repo" id="test.repo"/> |
| </artifact:pom> |
| |
| <echo>Artifact ID = ${my.maven.project.artifactId}</echo> |
| |
| <echo>Parent Artifact ID = ${my.maven.project.parent.artifactId}</echo> |
| </target> |
| |
| <target name="test-deps-MANTTASKS-91" depends="initTaskDefs"> |
| <artifact:pom id="MANTTASKS-91.pom" file="src/test/pom-MANTTASKS-91.xml" /> |
| |
| <artifact:dependencies filesetId="MANTTASKS-91.dependency.fileset" useScope="compile" verbose="true"> |
| <pom refid="MANTTASKS-91.pom" /> |
| <remoteRepository url="file://${user.dir}/src/test/repo" id="test.repo" /> |
| <localRepository refid="local.repository"/> |
| </artifact:dependencies> |
| |
| <delete includeEmptyDirs="true" quiet="true"> |
| <fileset dir="target/MANTTASKS-91" /> |
| </delete> |
| <mkdir dir="target/MANTTASKS-91" /> |
| <copy todir="target/MANTTASKS-91"> |
| <fileset refid="MANTTASKS-91.dependency.fileset" /> |
| <flattenmapper /> |
| </copy> |
| <available property="fileIsPresent" file="target/MANTTASKS-91/d-1.2.jar" /> |
| <fail unless="fileIsPresent">MANTTASKS-91 failed: d-1.2.jar should be in the resolved dependencies</fail> |
| </target> |
| </project> |