Maven工程改造中如果實在脫離不開對於Ant 的依賴,這樣做:
view plaincopy to clipboardprint?
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>2.1</version>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>1.7.1</version>
</dependency>
<!-- ...其它包依賴 -->
</dependencies>
<executions>
<execution>
<id>ant-test</id>
<phase>package</phase>
<configuration>
<tasks>
<!-- 下面可以傳入一些Maven變量 -->
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<ant antfile="${basedir}/build.xml"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ... -->
<plugins>
</build>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>2.1</version>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>1.7.1</version>
</dependency>
<!-- ...其它包依賴 -->
</dependencies>
<executions>
<execution>
<id>ant-test</id>
<phase>package</phase>
<configuration>
<tasks>
<!-- 下面可以傳入一些Maven變量 -->
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<ant antfile="${basedir}/build.xml"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ... -->
<plugins>
</build>