Maven pom.xml in ant script

334 views Asked by At

This is part of my build.xml. I am triggering mvn build from ant script and then renaming the build and copying it to specific location. There is a concept of profile in maven. Can you help me out how to provide maven profile in the below snapshot.

<target name="_deployHubstarRESTAPI">
    <artifact:mvn pom="../HubstarRESTAPI/pom.xml">
        <arg value="clean"/>
        <arg value="install" />
      </artifact:mvn>
      <copy file="../HubstarRESTAPI/target/HubstarRESTAPI-0.0.1-SNAPSHOT.war" todir="${web.hubstarrestapi.dist.dir}"/>
      <move file="${web.hubstarrestapi.dist.dir}/HubstarRESTAPI-0.0.1-SNAPSHOT.war" tofile="${web.hubstarrestapi.dist.dir}/HubstarRESTAPI.war"/>
</target>
1

There are 1 answers

0
Sumit Bhardwaj On

Ant is actually creating the command with the arguments passed by you. Just add your profile entry as an argument. like this.

 <target name="_deployHubstarRESTAPI" >
<artifact:mvn pom="../HubstarRESTAPI/pom.xml">
   <arg value="clean"/>
   <arg value="install" />
   <arg value="-P${build.name}" />
 </artifact:mvn>
 <copy file="../HubstarRESTAPI/target/HubstarRESTAPI-0.0.1-SNAPSHOT.war" todir="${web.hubstarrestapi.dist.dir}"/>
 <move file="${web.hubstarrestapi.dist.dir}/HubstarRESTAPI-0.0.1-SNAPSHOT.war" tofile="${web.hubstarrestapi.dist.dir}/HubstarRESTAPI.war"/>
</target>