I am trying to use "if" ant tasks in maven build.
I found many articles that suggest using the ant -nodeps dependency. In the end, all these tricks did not work on maven3 + ant 1.8.1 + maven-antrun-plugin 1.6.
"Ant BuildException event raised: Problem: Could not create task or type if"
Can anything help?
Here is the real code (rather, it is not needed, but just in case):
<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>
Oleg Chirukhin
source share