You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Aurelien Mazurie <au...@free.fr> on 2004/04/06 18:01:13 UTC

Javac and buildnumber

	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 ?

	Aurélien


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


Re: Javac and buildnumber

Posted by Peter Reilly <pe...@corvil.com>.
Peter Reilly wrote:

>          if (compiling || sequential != null) {

Should be compiling && sequential != null


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


Re: Javac and buildnumber

Posted by Peter Reilly <pe...@corvil.com>.
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