• 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

javac and directory structures

 
Author
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I avoid re-compilation with the javac task when I have a flattened directory structure like"
src/
    org.acme.project/
        Person.java
Using the following javac setup:
<javac destdir="${build.classes.dir}" srcdir="${src.dir}">
    <classpath refid="compile.classpath"/>
</javac>
I get:
build/
    classes/
        org/
            acme/
                project/
                    Project.class
This works OK, but since the source and destination directories don't match,
javac recompiles Person.java every time (even if I haven't modified it).
Is there any way I can have javac do the following destination directory structure:
build/
    classes/
        org.acme.project/
            Project.class
Then the directory structures would match and javac would only compile the .java files that have changed.
Does anyone know how to do this? Please provide an example if you get it to work. Thanks.
Tom
[ September 15, 2003: Message edited by: Tom Marrs ]
[ September 15, 2003: Message edited by: Tom Marrs ]
[ September 15, 2003: Message edited by: Tom Marrs ]
[ September 15, 2003: Message edited by: Tom Marrs ]
[ September 15, 2003: Message edited by: Tom Marrs ]
[ September 15, 2003: Message edited by: Tom Marrs ]
[ September 15, 2003: Message edited by: Tom Marrs ]
[ September 15, 2003: Message edited by: Tom Marrs ]
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to stick my neck out and say that it isn't possible. As you know, there is a strict relationship between the package name and the underlying directory structure.
If you have a class defintion:
package org.acme.myproject;
public class MyClass { ... }
Then the source should be in "{$src}/org/acme/myproject/MyClass.java" and the compiled results will always go to "{$build}/org/acme/myproject/MyClass.class". I don't think there is any way in Java to flatten out the resultant directory structure.
My advice is to un-flatten out your source directories and then ANT will be happy.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic