Ant selector question

C

chunji08

Try to create a build.xml for my project. Right now I am trying to
avoid build one file, SupplierClient.java, as it imports a non-existing
package, "com.bank.database". But somehow, this java file is still
being built, and leaves me lots of errors. I do not have
com/bank/database in my source tree. Can somebody help me to find out
why. Thanks a lot !

Here is the highlights of my build.xml file.

<project name="testng" default="all" basedir=".">
.......
<selector id="reason.notReady" >
<or>
<filename name="com/bank/domain/supplier/SupplierClient.java"
/>
</or>
</selector>
....
<target name="check_for_package">
<available property="database.present"
classname="com.bank.database" classpathref="runtime.cp" />
...
</target>
<target build depends="prepare, check_for_package">
<javac srcdir="${src.dir}"
destdir="${classes}"
debug="true"
optimize="{optimize}">
<classpath refid="runtime.cp"/>
<selector id="conditional-patterns">
<not><or>
<selector refid="reason.notReady"
unless="database.present"/>
</or></not>
</selector>
</javac>
</target>
 
D

dimitar

Errr, my head is swaying ;-P

Why don't you use exclude and include of the implicit fileset of javac?
Here are 2 example from the Ant manual:

<javac srcdir="${src}:${src2}"
destdir="${build}"
includes="mypackage/p1/**,mypackage/p2/**"
excludes="mypackage/p1/testpackage/**"
classpath="xyz.jar"
/>

<javac destdir="${build}"
classpath="xyz.jar"<src path="${src}"/>
<src path="${src2}"/>
<include name="mypackage/p1/**"/>
<include name="mypackage/p2/**"/>
<exclude name="mypackage/p1/testpackage/**"/>
</javac>
 
C

chunji08

Well, If I am using the "exclude" to filter out which file not to be
built, eventually I have to change this xml file, when that file is
ready for build. The way that I am using now will automatically detect
whether this file is to be built or not, beased on the availablity of
its depends. I do not need to touch this makefile any more.

But anyway your suggestion may be a temp solution for my current
situation.

Thanks a lot.


-Charlie
 
D

dimitar

Well, If I am using the "exclude" to filter out which file not to be
built, eventually I have to change this xml file, when that file is
ready for build.

But it will work, while your current script doesn't...

There's nothing bad in using a simple solution to the problem. Even I
would argue that even if the construction from the first script worked,
you shouldn't use it, because it unnecessarily complicates the script.
It took me more than 10 mins to figure what are you trying to do even
*after* you explained it in your first post.

Regarding the reasons of that file being compiled, I'm pretty sure that
it's being used by some of the included files, so the javac
autodependency resolution pools it in the build even if not explicitly
specified. You can try running ant with '-d -v' to get better diagnostic
output.

Dimitar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top