My project runs perfectly fine with following commands:
C:\project\<project_name>\ant -lib ant\lib -buildfile applications/<sub-project-path>/ant/build.xml deploy
However, if I wrap this command either in maven-antrun-plugin or exec-maven-plugin in pom, I get all kinds of path issues.
For maven-antrun-plugin, it seems the certain properties can not be loaded due to path issue. In exec-maven-plugin, it seems that ant target never got passed in correctly.
Can someone please advice how I can apply this in a pom file? Much appreciated.
This is my pom for exec:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>ant</executable>
<workingDirectory>${basedir}</workingDirectory>
<arguments>
<argument>'-lib ant/lib'</argument>
<argument>'-buildfile $basedir/<project-path>/build.xml'</argument>
<argument>deploy</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
You should pass needed dependencies directly into antrun plugin declaration, right after
<executions>element.I’ve included some libraries that I use in our project, so that you have an example. Note, that if your build uses some non-standard ( i.e. something outside
java.lang) Java API classes, you have to passtools.jaras a dependency.Also, if you use
ant-contribdo not forget to excludeantas a dependency, because it is dependent on some ancient version of ant and you will get a version collision.Another annoying thing is that dependency assigned directly to plugin execution are not part of POM’s
<dependencyManagement>, so you have to spell out precise versions. One workaround is to declare version properties in the same place as your central<dependencyManagement>and use the properties instead of hardcoded versions.