So far so good. But how will Ant access these User Libraries? As far as I can determine, there's no out-of-the-box way for Ant to reference an Eclipse's User Library in it's classpath. Here's a couple of relevant forum posts on the topic:
- Eclipse: Ant script to export User Library/Libraries for project
- How to reference "Eclipse (user) libraries" from Ant script?
- Use the Eclipse User Library as-is then configure the Ant build file separately for the jars you need in your classpath. I consider this option the "hard way" and of course it's what I'm doing for now.
- Use Apache Maven instead of Ant for build and project dependencies. I'd like to give this a try when I have time.
- I've seen a few people suggest using Ant4Eclipse. I haven't had time to try it myself yet but it sounds like a potential solution.
- Don't utilize Eclipse User Libraries and copy your required jars to a /lib folder in your project. Of course, this is just ignoring the issue isn't it. :)
Trying to solve this same issue, would love to see an elegant solution myself.
ReplyDeleteI used to have multiple copies of the same jars in each project and have finally moved them all to user libraries. Of course I then ran into the same headache as you.
ReplyDeleteI'm not sure the method I've gone for is any better, but here it is.
1. I have a common.properties file that defines a variable the base folder (common.lib.folder) for all the user libraries and then further variables for each user library (e.g. common.log4j). I place this file in the root folder of all the library folders.
2. For a project, in the build.properies I define a variable named common.properties which points to the file in step 1 (in case other developers have the libraries in a different folder).
3. The variables from the common file are now available to use in the command.
Hope that makes sense.
Step 3 means:
ReplyDeleteAh the joys of filtering out anything that looks like cross-site scripting.
ReplyDeleteWhat I was trying to write was I reference a fileset with dir="${common.lib.folder}/${common.log4}"
Thank you !!!
ReplyDeleteJava Books