Reputation: 1345
This may be a very basic question but I am really confused.
I want to add a few jar files to the build, so that when the build is generated using ant
, the jars will be correctly included.
In my IDE eclipse
, I have added the jar file to build path but have not selected it for export. Now I want to make sure the jar is exported when build is generated. If I go to build path > order and export
and select the jars to be added for export, I can see that its entry is added in .classpath
file of the project. i.e. if the project was X then X.classpath file will be modified.
My question is, is doing what I have described above enough to export a jar? Or Am I supposed to change the build.xml file of the project?
Should I change both the .classpath file & build.xml file or just one of them? Whats the difference between these two files?
Upvotes: 1
Views: 2447
Reputation: 72884
The difference is related to the way you want to generate your build with the included Jar. If you want to use Ant
, as you described in the question, then the file to be updated is the build.xml
. This is the XML file that Ant
reads to build your project. The .classpath
file has nothing to do with Ant
. It is a "meta" file that the Eclipse JDT plugin/feature reads to build your project. The .classpath
file contains the path to your source files, the location of your binary (where to compile your classes), and any classpath dependencies (e.g. external Jars, other projects referenced in your IDE).
When you update the project's build path, Eclipse will automatically update the project's .classpath
by adding an entry in the classpath corresponding to the Jar you added. Then when you build your Jar using the "Export" feature of Eclipse, this Jar will be included in the exported project's jarfile.
In contrast, when you build using Ant, you need to manually edit the build.xml
to include the Jar in your build. This post may help in doing it.
Upvotes: 1