ant task retrieve maven profile dependency
i have a java project with a automatically generated ant files. so i'm forced to use ant to build the project. I needed to add some new libraries and i used the below maven pom file. i then use an ant task to retrieve the pom dependencies and copy them into a lib folder. however the following ant task misses the profile dependencies in the pom. what i want to do is an ant task so that based on current os it will include the corresponding xurlrunner jar for the os. this is done by maven in the pom but how can i do it with ant ?
---ant target task----
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="maven-ant-tasks.classpath"/>
<target name="retrieve-dependencies">
<artifact:dependencies filesetId="dependency.fileset"
sourcesFilesetId="profiles.dependency.fileset"
versionsId="dependency.versions">
<pom file="${basedir}/nbproject/pom.xml"/>
</artifact:dependencies>
<delete dir="${lib.dir}/browser"/>
<copy todir="${lib.dir}/browser">
<fileset refid="dependency.fileset"/>
<mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper"
from="${dependency.versions}" to="flatten"/>
</copy>
</target>
---pom.xml-------
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.drOffice.browser</groupId>
<artifactId>embedded-browser</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.6</compilerVersion>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugins>
</build>
<repositories>
<repository>
<id>atomation-repository</id>
<name>atomation maven repository</name>
<url>http://atomation-repository.googlecode.com/svn/trunk</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>ru.atomation.jbrowser</groupId>
<artifactId>jbrowser</artifactId>
<version>1.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>generic</id>
<activation>
<activeByDefault></activeByDefault>
</activation>
</profile>
<profile>
<id>linux</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-linux</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>solaris</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-solaris</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>macosx</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-macosx</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>windows</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-windows</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
If you only use Ant to copy the dependencies, I assume it would be by far simpler to use maven to copy these dependencies.
If you really want to use Ant, you can simply define the property in your pom (in the profile), and use it in the Ant script.
Something like
<profile>
<id>linux</id>
<properties>
<custom.property>linux</custom.property>
<properties>
.....
链接地址: http://www.djcxy.com/p/44322.html
上一篇: 在pom.xml中执行特定的Ant任务
下一篇: ant任务检索Maven配置文件依赖关系