Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Ant selector question

Thread view: 
chunji08@gmail.com - 02 Jun 2006 22:38 GMT
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>
dimitar - 04 Jun 2006 03:52 GMT
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>
chunji08@gmail.com - 04 Jun 2006 07:02 GMT
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

> Errr, my head is swaying ;-P
>
[quoted text clipped - 17 lines]
>      <exclude name="mypackage/p1/testpackage/**"/>
>    </javac>
dimitar - 04 Jun 2006 12:24 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.