Running all targets in ant through command prompt

Suppose you have an ant script build.xml to build the project which contains multiple targets inside it.If you are running the script through eclipse then you can enable or disable the targets by right clicking on build.xml and click on  "Run As" and in the popup window opened check or uncheck the targets.
But how to do the same thing in command prompt. I have one little solution that worked for me.
Suppose your build.xml contains some target like this :

   <target name="init">
  <tstamp>
  <mkdir dir="${build}">
  </mkdir></tstamp></target>

  <target depends="init" description="compile the source " name="compile">
  <javac destdir="${build}" srcdir="${src}">
  </javac></target>

  <target depends="compile" description="generate the distribution" name="dist"  >
  <mkdir dir="${dist}/lib"  >
  <jar basedir="${build}" jarfile="${dist}/lib/MyProject-${DSTAMP}.jar">
  </jar>
  </mkdir>
  </target>
 

 When you run this xml through ant it will run the target having the name "usage" leaving other targets.
 So to run other targets as well ,we can add one more target which will be responsible for running the
 other targets.
 So you can write :

  <target  name="all" depends="init,compile,dist" description="run all targets">
  </target>

Now open your command prompt and type 
ant all
 

This will run your all targets.  :)  



Comments

Popular posts from this blog

Arrays.sort() and Collections.sort() NullPointerException

org.xml.sax. SAXParseException: Element type "web-app" must be declared.

Sentimental Analysis : PART 1