• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with exclude in javac task

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm new to Ant and I can't get exclude to work in javac. I think I'm doing something wrong, but can't figure out what. I'm hoping someone can point me to the right direction.
This is what my directory structure looks like:
.
build.xml
+src
+my
+stuff
|
|-+server
| *.java
|
|-+printer
| *.java
|
|-+ver-1
| *.java
| *
|
|-+ver-2
| *.java
| *
|
|-+ver-3
*.java
*
I want to compile everything except the stufff in ver-* directories, so I put this in my build.xml file:
<target name="compile">
<javac srcdir="${src}" destdir="${build}" excludes="${src}/**/ver*/"/>
</target>
but it doesn't work, all the java files in all three ver-* directories are still included.
Then I try this,
<target name="compile">
<javac srcdir="${src}" destdir="${build}">
<exclude name="${src}/**/ver*/*.java"/>
</javac>
</target>
I still get the same result. Could anyone tell me what I did wrong?
Thank you very much.
 
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. I'm having trouble understanding your directory structure.
2. javac knows a lot about dependency rules. Could it be that the javac wants those other files so it compiles them without your explicit command?
 
Harry Cheng
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry! The directory structure didn't come out the way I wanted. Here is what I mean:
./build.xml
./src/my/stuff/server/*.java
./src/my/stuff/printer/*.java
./src/my/stuff/printer/ver-1/*.java
./src/my/stuff/printer/ver-2/*.java
./src/my/stuff/printer/ver-3/*.java
I want to compile everything except the java files in ver-1, ver-2, and ver-3 directories, but both "exclude" and "excludes" didn't work for me as described in the original post. Could anyone tell me what I did wrong?
Thank you very much.
 
Rufus BugleWeed
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you see this note in the javac task?

Note: If you wish to compile only source files located in certain packages below a common root, use the include/exclude attributes or <include>/<exclude> nested elements to filter for these packages. Do not include part of your package structure in the srcdir attribute (or nested <src> elements), or Ant will recompile your source files every time you run your compile target. See the Ant FAQ for additional information.


I'm not 100% certain but it looks like it applies.
HTH
 
Harry Cheng
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this again, if I said
excludes="**/ver*/*"
then it worked, but if I said
excludes="${src}/**/ver*/*"
then it didn't work. Does anyone know why?
 
reply
    Bookmark Topic Watch Topic
  • New Topic