Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Ant, Maven and Other Build Tools and the fly likes Including images and font Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Including images and font" Watch "Including images and font" New topic
Author

Including images and font

Dadaa Aressio
Greenhorn

Joined: Sep 04, 2012
Posts: 4
Hello. I'm trying to include some resources (images and fonts) in my project. As of now is works if I run the project from Eclipse or if I export a runnable jar via Eclipse (all files in one jar). But if I build my project with ant it doesn't work.

Here is the addImage method:

which I call like this:


Here is the setFont method:

which I call like this:


And finally here is my build.xml:


Can anyone point out what I'm doing wrong?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't see anything in your Ant code which writes images and fonts into the jar. Actually I don't even see anything there which writes java classes into the jar. Perhaps it's that "sonar" which is supposed to do those things? If so, you should look and see what it is doing and how it does it.

(Let me move this to our forum where Ant questions are asked, perhaps it will get better answers there.)
Dadaa Aressio
Greenhorn

Joined: Sep 04, 2012
Posts: 4
Ok so I changed the prepare task in the build.xml like this:

And it works as expected. It seems a bit bulky so now I'm wondering if it is the correct way of doing it. Again thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It seems to me that you would have to do something extra to copy the resources into the build directory, I don't see why it should happen automatically. And what you posted does that. However I would put the actual copying of the resources into the "compile" target rather than the "prepare" target.
Dadaa Aressio
Greenhorn

Joined: Sep 04, 2012
Posts: 4
Paul Clapham wrote:It seems to me that you would have to do something extra to copy the resources into the build directory, I don't see why it should happen automatically. And what you posted does that. However I would put the actual copying of the resources into the "compile" target rather than the "prepare" target.

Thanks for the advice
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4527
    
    5

Dadaa, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/new-java/62722-including-images-font.html


luck, db
There are no new questions, but there may be new answers.
Dadaa Aressio
Greenhorn

Joined: Sep 04, 2012
Posts: 4

I know it can be frustrating, and I am aware of that. I did so only because I wasted an hour on a couple IRC channels without getting an answer and wanted to maximize my chance of getting an answer. As you might notice I kept all three (you missed this) threads updated as not to leave hanging threads.
I hope you understand.

PS. I wont copy this answer to the other forum you moderate in, as far as I'm concerned you can mark as solved and close both threads you have power over. Thanks and sorry again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Including images and font