You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jan Almås <JA...@oslo.WesternGeco.slb.com> on 2005/04/28 13:00:01 UTC

Problem with Ant javac includes

Hi all Ant users,

we have been using Ant in our projects for 2+ years now. We have 
recently discovered a potential dangerous error (or we believe it's an 
error at least).

When using Ant to compile our package with an explicit includes 
statement, Ant ignores the fact that the file can't be found. Since we 
are using some reflection to minimize coupling, we need this feature but 
this can be dangerous since parts of the package might be omitted from 
the distribution jar.

  <target name="compile_server" depends="init">
     <javac
        includes="mypackage/ExportService.java,
                  mypackage/RetrieveService.java,
                  separate/package/UpdateProperty.java"       <-- 
MISSING FROM ${source}, build successful
        srcdir="${source}"
        destdir="${classes}"
        debug="on">
        <classpath>
           <pathelement 
location="${3plib}/servlet/servlet2.3/servlet.jar"/>
           <path refid="cb.depend.class.path"/>
           <path refid="crewlist.depend.class.path"/>
        </classpath>
     </javac>
  </target>



Does anyone have any experience with this?


Rgds,

Jan Almaas

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


Re: Problem with Ant javac includes

Posted by Peter Reilly <pe...@apache.org>.
Includes acts as a filter, not as a list of files.
It is more often uses as "mypackage/*.java" or "mypackage/**/*.java" - 
i.e. a filter.

To do what you want, you would need to use the <fail> task with a 
<condition> with the <available> condition.

Something like
<fail message="missing a source file">
   <condition>
       <not>
           <and>
               <available file="${source}/mypackage/ExportService.java"/>
               <available file="${source}/mypackage/RetrieveService.java"/>
               <available 
file="${source}/separate/package/UpdateProperty.java"/>
           </and>
        </not>
    </condition>
</fail>

Peter

Jan Almås wrote:

> Hi all Ant users,
>
> we have been using Ant in our projects for 2+ years now. We have 
> recently discovered a potential dangerous error (or we believe it's an 
> error at least).
>
> When using Ant to compile our package with an explicit includes 
> statement, Ant ignores the fact that the file can't be found. Since we 
> are using some reflection to minimize coupling, we need this feature 
> but this can be dangerous since parts of the package might be omitted 
> from the distribution jar.
>
>  <target name="compile_server" depends="init">
>     <javac
>        includes="mypackage/ExportService.java,
>                  mypackage/RetrieveService.java,
>                  separate/package/UpdateProperty.java"       <-- 
> MISSING FROM ${source}, build successful
>        srcdir="${source}"
>        destdir="${classes}"
>        debug="on">
>        <classpath>
>           <pathelement 
> location="${3plib}/servlet/servlet2.3/servlet.jar"/>
>           <path refid="cb.depend.class.path"/>
>           <path refid="crewlist.depend.class.path"/>
>        </classpath>
>     </javac>
>  </target>
>
>
>
> Does anyone have any experience with this?
>
>
> Rgds,
>
> Jan Almaas
>
> ---------------------------------------------------------------------
> 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


Re: Problem with Ant javac includes

Posted by Conor MacNeill <co...@apache.org>.
I think you may be misunderstanding what "includes" means here. The 
"includes" attribute is used against the source directory to decide 
which files to include in the compilation. In other words, "includes" 
functions as a filter on the set of files from your srcDir. If you add 
something to that filter which does not exist in the set, it has no 
effect - it's not there to include to start with. "Includes" is not an 
explicit specification of which files are to be compiled.

Nevertheless, I understand the issue you are raising. I'd say the best 
way to catch these sorts of issues is with adequate testing.

Conor

Jan Almås wrote:
> Hi all Ant users,
> 
> we have been using Ant in our projects for 2+ years now. We have 
> recently discovered a potential dangerous error (or we believe it's an 
> error at least).
> 
> When using Ant to compile our package with an explicit includes 
> statement, Ant ignores the fact that the file can't be found. Since we 
> are using some reflection to minimize coupling, we need this feature but 
> this can be dangerous since parts of the package might be omitted from 
> the distribution jar.
> 
>  <target name="compile_server" depends="init">
>     <javac
>        includes="mypackage/ExportService.java,
>                  mypackage/RetrieveService.java,
>                  separate/package/UpdateProperty.java"       <-- MISSING 
> FROM ${source}, build successful
>        srcdir="${source}"
>        destdir="${classes}"
>        debug="on">
>        <classpath>
>           <pathelement location="${3plib}/servlet/servlet2.3/servlet.jar"/>
>           <path refid="cb.depend.class.path"/>
>           <path refid="crewlist.depend.class.path"/>
>        </classpath>
>     </javac>
>  </target>
> 
> 
> 
> Does anyone have any experience with this?
> 
> 
> Rgds,
> 
> Jan Almaas
> 
> ---------------------------------------------------------------------
> 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