简体   繁体   中英

Eclipse: Automatically run Ant scripts in sequent order

I am using Eclipse's Ant view to run my build files. I have to run a couple of files in a specific order and I wonder whether there is any possibility to automate this (I'm sure there is...). However, they need to run subsequently, ie script two may not start until script one finished successfully. Most of my Ant scripts trigger Maven commands.

Is there any Eclipse plugin or feature that can assist me in running my Ant files automatically? Maybe even shutdown and restart my Java EE server before and after building?

I'd like to double-click just once and have my toolchain work, while I... get myself another cup of coffee.

I can think of two options:

  1. Write a wrapper Ant script/target that calls the others in the desired order. It's been a number of years since I wrote any Ant but I remember doing that, probably using the <ant> task . It might make sense to simply define a target that has dependencies/prerequisites in the right sequence (in conjunction with the <import> task to pull in the separate buildfiles). Here is a discussion about the difference between these two approaches.

  2. Use Eclipse's External Tool feature to invoke a batch/shell script that calls each Ant target.

This is what I finally came up with:

<project default="all" basedir=".." name="Build all projects">

  <property name="folder.project.a" value="MyProjectA" />
  <property name="folder.project.b" value="MyOtherProjectB" />

  <!-- Target to build all projects -->
  <target name="all" depends="projectA, projectB" />

  <target name="projectA">
    <echo>Building project A.</echo>
    <ant antfile="${folder.project.a}/my_build_file.xml" />
  </target>

  <target name="projectB">
    <echo>Building project B.</echo>
    <ant antfile="${folder.project.b}/my_other_build_file.xml" />
  </target>

</project>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM