[英]maven3 - maven-antrun-plugin - “failed to create task or type if”
我正在嘗試在maven構建中使用“if”ant任務。
我發現許多文章建議使用“ant-nodeps”依賴。 最終所有這些技巧都不適用於maven3 + ant 1.8.1 + maven-antrun-plugin 1.6。
“出現了一個Ant BuildException:問題:如果創建任務或輸入失敗”
有什么幫助嗎?
這是真正的代碼(相反,它沒有必要,但以防萬一):
<profiles>
<profile>
<id>smtpConfigurationProfile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<if>
<isset property="${smtpFile}"/>
<then>
<delete file="${project.build.outputDirectory}/smtp.properties"/>
<copy file="${smtpFile}"
tofile="${project.build.outputDirectory}/smtp.properties"/>
</then>
<elseif>
<isset property="${smtpProfile}"/>
<then>
<delete file="${project.build.outputDirectory}/smtp.properties"/>
<copy file="src/main/resources/${smtpProfile}.smtp.properties"
tofile="${project.build.outputDirectory}/smtp.properties"/>
</then>
<else>
<delete file="${project.build.outputDirectory}/smtp.properties"/>
<copy file="src/main/resources/production.smtp.properties"
tofile="${project.build.outputDirectory}/smtp.properties"/>
</else>
</elseif>
</if>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
1)在目標部分中的ant任務之前添加此行:
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpathref="maven.plugin.classpath" />
2)添加完全以下的依賴關系插件:
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
在這里查看我遇到同樣問題的問題。
我通過將我的ant-contrib依賴項從插件移動到項目中來解決它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.