File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes ANT: Getting resource files moved to classes folder for JAR Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "ANT: Getting resource files moved to classes folder for JAR" Watch "ANT: Getting resource files moved to classes folder for JAR" New topic
Author

ANT: Getting resource files moved to classes folder for JAR

Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Alright, this is probably something simple, but I can't figure out what the heck to do. I have a project where I have some image files and some .obj files I need access to from within my JAR file. So I just packaged them up in my src folder like so.



Hopefully, you get the idea. So when I run my ANT compile task, the image folder and files are moved to the classes folder. However, the models folder and files are ignored. I tried doing a copy task before the JAR task but I can't seem to get the correct syntax to copy the complete directory structure for the models folder. Can someone help me out on this? Is there another way to do this?

FYI - interestingly enough, in IDEA, building the project with it's builder (not ANT) also moved the images but not the models to the classes folder from the src folder.


My Blog | DZone Articles
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Whadoyagot?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11945
Try this:


Author of Test Driven (Manning Publications, 2007) [Blog] [HowToAskQuestionsOnJavaRanch]
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Originally posted by Lasse Koskela:
Try this:


Lasse, that almost works and that's almost what I had. Problem is it excludes creating the data folder which I need.
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Ok, nevermind. I got it to work. Now I have:



And all is well in my strange little world. Thanks!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 9980

Hi Gregg,

Try this:



Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
This is what I do:



Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Daniel Mayer
Ranch Hand

Joined: Sep 09, 2004
Posts: 103
In some languages, obj-files are intermediary files that are created during compilation but not necessary for program execution, if I remember correctly. That might explain why some tools ignore them by default. Mhh, on the other hand they don't seem to be in the default excludes: http://ant.apache.org/manual/dirtasks.html
 
 
subject: ANT: Getting resource files moved to classes folder for JAR
 
Threads others viewed
Eclipse 3: problem setting up output folders
Packaging, naming and directory structure.
how to copy resources with maven?
ant javac task not copying directory with no java files
Runnable jar is not including the files
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture