In the eclipse directory, there is .classpath file. What's the purpose of this file?
I have ant build.xml available, why Eclipse still need its own?
Eclipse has its own mechanism for building your project. The .classpath file contains information that the IDE uses to create the classpath used at build-time, runtime etc. You can directly edit this file if you want but it is created by the IDE based on the settings that you provide via the project properties dialog.
There is Ant integration within Eclipse insofar as it provides you a specific editor for build files, but it can't use any of the information in the build file for its own builders. Ant files are custom, so there is no way Eclipse could know what info to use.
The reason for this is that it doesn't matter if you have an Ant file or not. The reason for the presence of this file is that this is a Java Project, and the corresponding Project nature always generate such a file. Create a normal Project (New->Project->General->Project) and you'll see that there is no .classpath file.
In general I would recommend to split those functionalities in separate projects, that means one Java Project for developing, one non-Java-Project for executing your Ant scripts.
HTH Tom
Related
I currently have a basic Java project, that I want to deliver as an executable JAR. The program within it is based on several resource files, which must be editable by the user, or by a third-party program, which means that those files must not be embedded into the JAR archive.
I am using Eclipse to develop my project. The question is :
How to make the exportation of those files automatic, to end up with the JAR, and right next to it, a folder containing the resources for exemple (if that is possible of course) ?
Every thing I've tried or found on the net concerns resources delivered within the JAR, which avoids any modification of those resources. The ideal solution would copy the files right next to the JAR when it is exported.
Eclipse's "export executable JAR" functionality can't do this directly, it's limited to the contents of the JAR. I recommend you investigate doing this with a build tool like Gradle, Maven, or Ant, and then invoking that from Eclipse or via command-line.
I have inherited an old java project, where different team members are using different development tools; some use emacs, some netbeans, I use eclipse. Hence when this project is checked into the version control, it's just a bunch of java files and ant build files.
Every time there is a new branch or so, I checkout the project in my eclipse through subclipse plugin and generate some dependent jars, put them in classpath, then set up the source folder etc etc. This is becoming very tedious as I help out others with same configuration if they're using eclipse. Is there a way I could have some script which I can run on the project to convert and restructure it to an eclipse project?
You could have the Ant build create the .project and .classpath files for you. I've done this myself with the XMLTask suite, since those files are just XML documents. Add them to the svn:ignore property so your twitchy teammates don't get upset.
There appears to be an old ant task that does this for you, but I haven't used it myself.
So I have this Java project made up of several classes, some external JAR files and an executable Java program. I would like to export the whole code and external JARS to an external directory and to produce a Makefile to build the program with all the dependencies. Is there an automated way to do it?
Thank you
Tunnuz
I think I understand the question. Of course if you use an external build system like maven or ant, then we are decoupling the build process from the IDE. (But in some cases the IDE does integrate pretty closely with the build tool.)
But if you want to continue building using eclipse and to generate an ant file one fine day, then there is a tool for that. Its called EBuild. It leverages all the classpath information that eclipse already has and builds an generic ant file out of it.
Do you use maven?
If so this can be easily achieved with maven assembly.
If not, you can use ant to bundle exactly what you need.
When you right-click your project in Eclipse, there is an option called "Export". It can create build.xml for ant for your project.
I tried to create a project in WTK which I'm using for SVN commits. My problem is that every time I create the .jar package those .svn/ directories appear in it...
Is there any build script the Wireless Toolkit uses that I could modify to avoid including .svn folders to the packages? Or maybe better solution?
You can build an Ant script to package explicitly the directories you need using the jar task. Ant also includes an SVN extension to allow exporting a clean tree without the .svn files. Ant by default excludes .svn directories as noted here.
I have a running Java GWT application, that I can compile using Eclipse.
Now I wan't to also be able to build this application from the command line using ant.
As of my understanding I therefore need a build.xml file.
I used the webAppCreator tool, that comes with the SDK to create this build.xml file and adapted it to my needs and got it working.
But how do I tell Eclipse now to automatically update the build.xml file upon code changes?
I know it is possible for it works in projects created with webAppCreator. But I just copied the build.xml to another project. So what do I need to adapt? Or where do I need to set up the link to the build.xml?
You could use Ant4Eclipse to get the Eclipse classpath into your ant build file. That's probably only part of the solution you're looking for... I'm not sure, how useful this will actually be when used together with a GWT project (do you want automatic copying of the libraries to WEB-INF/lib, too? Etc...)