ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <>
Subject Re: how to only do stuff if javac compiled something?
Date Fri, 14 Nov 2003 18:07:45 GMT
The easiest way I can think of is to extend/modify Javac
and set a property if is actually calls the compiler
which is done in Javac#compile().

Using my beanshelldef task to extend javac in-line:

 <project default="all">
  <target name="init">
    <beanshelldef name="my.javac" classname="MyJavac">
      public class MyJavac extends Javac {
        private String compileProperty;
        public void setCompileProperty(String compileProperty) {
          this.compileProperty = compileProperty;
        protected void compile() {
          if (compileList.length &gt; 0) {
             if (compileProperty != null) {
                getProject().setNewProperty(compileProperty, "true");

  <target name="compile_classes" depends="init">
    <my.javac srcdir="src" destdir="classes"
    <echo>compiled_classes is ${compiled_classes}</echo>

  <target name="test_classes" depends="compile_classes" if="classes.compiled">
    <echo>Test the classes</echo>

  <target name="package_classes" 
                depends="compile_classes" if="classes.compiled">
    <echo>Package the classes</echo>

  <target name="all" depends="compile_classes,test_classes,package_classes"/>


On Friday 14 November 2003 17:36, Caoilte O'Connor wrote:
> I have the following tasks,
> compile-X
> test-X
> package-X
> other tasks has dependencies on package-X.
> When package-X gets called and no changes have been made to
> the source the compile-X doesn't recompile but the test-X
> and package-X still repeat their processes.
> Is there anyway I can adjust my compile-X command to call
> the test-X and package-X directly, dependent on there being
> some changed/new java files compiled? It would speed up
> average usage enormously.
> thanks for any pointers,
> c
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message