ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: Javac and buildnumber
Date Tue, 06 Apr 2004 17:07:59 GMT
Aurelien Mazurie wrote:

>
>     Hello,
>     I'm trying to have a conditional call to some tasks (buildnumber), 
> ONLY when the 'javac' task have done it's job; for example, here:
>
>     <target name="BUILD">
>         <javac ... />
>         <buildnumber />
>     </target>
>
>     I don't want to have buildnumber called if javac have compiled 
> nothing (because of no newer .java files, or even errors, ...).
>     How can we do this ? My goal is to not use the 'uptodate' task, 
> mainly because javac seems to check by itself for new .java files. 
> There is a way to use this behavior ?

Not unless you make a new task based on javac or modify the javac task.

This subject came up before, and I wrote a task for it:

      import org.apache.tools.ant.taskdefs.Javac;
      import org.apache.tools.ant.taskdefs.condition.Condition;
      import org.apache.tools.ant.taskdefs.Sequential;
      public class MyJavac extends Javac implements Condition {
        private String compileProperty;
        private boolean compiling = false;
        private Sequential sequential;
        public void setCompileProperty(String compileProperty) {
          this.compileProperty = compileProperty;
        }
        public boolean eval() {
           execute();
           return compiling;
        }
        public void addSequential(Sequential sequential) {
          this.sequential = sequential;
        }
        protected void compile() {
          if (getFileList().length > 0) {
             if (compileProperty != null) {
                getProject().setNewProperty(compileProperty, "true");
             }
             compiling = true;
          }
          super.compile();
          if (compiling || sequential != null) {
             sequential.perform();
          }
        }
      }

Peter

>
>     Aurélien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message