aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant does not output property file in classes folder. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant does not output property file in classes folder." Watch "Ant does not output property file in classes folder." New topic
Author

Ant does not output property file in classes folder.

omkar patkar
Ranch Hand

Joined: Aug 25, 2005
Posts: 231
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!


Thanks and Regards
Omkar Patkar (SCJP 1.4)[url]http://javacollectionsnotes.blogspot.com[/url] | [url]http://omkar-myscjpexp.blogspot.com[/url]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Aug 25, 2005
Posts: 231
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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?
Diptirmaya Rout
Greenhorn

Joined: Sep 21, 2009
Posts: 2
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

Joined: Aug 25, 2005
Posts: 231
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
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
omkar patkar
Ranch Hand

Joined: Aug 25, 2005
Posts: 231
Thanks Tim,

Thats a nice suggestion which i will follow

Thanks and Regards
Omkar Patkar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant does not output property file in classes folder.