• 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

Ant does not output property file in classes folder.

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I am using Ant 1.7.0 2008 build and jdk 1.6 on Windows Vista Home Basic Edition OS. I am trying to compile my project using ant.
But the property file is not getting outputted in the classes folder. The folder and file organisation of my project is as follows: -



for the above structure i have made the build.xml as follows: -



I execute the ant tool as : -


The Build is successfull ... that is the Tester.class file is created in appropriate packag structure ....
but when i check the build directory which contains the classes created after compilation, then its found that the resources directory is not created, also the property file is not outputted as the resources directory is not available.
Tester.java is expected to use the property file, but currently Tester.java just contains one line of System.out.println("Hello World!"); that's it.

The structure after executing ant ...looks as follows: -


As you can see, the package structure for property file was not created.
Why does the ant task does not create the package structure for property file?
How do i make ant do that? ......So that i can refer to that in the Tester.java code later?

Thanks in advance!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure that using the "includes" attribute means that non-Java files will be copied. If it doesn't, you'll have to move non-Java files via a copy.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Thank you for the reply.

Actually, in the user manual of Ant 1.7, the includes attribute has been defined as :-

includes Comma- or space-separated list of files (may be specified using wildcard patterns) that must be included; all .java files are included when omitted.

So i thought of using "includes" in my build file.
It says "list of files" .... and since i have used the wildcard "**" i thought, all directories and files will be considered.
But either my understanding is wrong and as you suggested i might have to use the "copy" task.
But in that case, does that mean for any non ".java" files, ... like ".xml" or ".properties" or ".log" or ".txt" etc.,
i will have to configure the ant build task to "copy" the files with their package structure individually ?
... is their any facility in ant that will take care of this automatically?

Thanks and Regards
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the "includes" attribute exists to explicitly specify which files to include in the *javac* task--which compiles Java files.

If copying files manually I don't know any other way than to specify which files you want copied; how else would it know?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Omkar,

Please try with the following code snippet, hope it will help you!!

<target name="compile" description="Compiles all source java files">
<copy verbose="${verbose}" todir="${build.main.dir}" preservelastmodified="false">
<fileset dir="${src.main.dir}">
<include name="**/*.properties" />
<include name="**/*.xml" />
</fileset>
</copy>
</target>


 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

Sorry for the late reply, actually internet connection @ my end had problems which got resolved today.
I did search over for finding if there is any way by which, non java files with its package (directory)
structure is maintained as is when source code is compiled... but i did not get any information where ant provides a readymade facility to do so
in compile task.

Therefore, i guess, ... as per David Newton and Diptirmay Rout i will have to copy non java files along with their directories
as a copy task separately.

Thank you so much David and Diptirmay...thank you Cheers !

Thanks and Regards
Omkar Patkar
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tip: using straight relative paths is not as flexible as "${basedir}/src/main/java" (for example).

Better yet: "${build.classes}".

I often construct an entire hierarchy of definitions. It allows me the freedom to use alternate resource locations if I need to.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim,

Thats a nice suggestion which i will follow

Thanks and Regards
Omkar Patkar
reply
    Bookmark Topic Watch Topic
  • New Topic