Eclipse - always autogenerate Ant build files - java

When I create a project in Eclipse, I have to manually export the Ant build files to be able to build from command line easily.
Is there any way to make Eclipse generate the Ant build files when creating the project without further interaction?

With standard Eclipse it's possible to generate ant build files (Right click on the project -> Export -> Ant build file) but you need external plugins to generate them automatically (Web Tools Platform if I recall correctly).

Related

How to import existing Ant build.xml into IntelliJ IDEA

I have an existing project that uses an Ant build.xml file to maintain the location of dependency jars.
In Eclipse it's very easy to import from an existing Ant file. I have searched online and looked through all of the "new project" options in IntelliJ but cannot figure out how to do this.
The closest thing I've done is File > New > Project from Existing Sources. But my whole project is full of errors because it didn't use the build.xml to include the jars.
Intellij supports Ant projects via built in Ant plugin which is included by default in IDE.
To check if it is enabled go to Settings > Plugins > Ant
After enabling plugin, you can use build.xml from View > Tool Windows > Ant Build
You should then have option(+) of importing your build.xml file.
Import the project "from existing sources" without choosing any build tool (ant is not on the list, only maven, sbt, etc...). Then after completing the import wizard, in the project files view, right click ant's build.xml file, and choose the option relating to ant which is hiding at the bottom of the menu.
You should use File > New > Module instead of File > New > Project from Existing Sources for Ant project. You also need to set your Content root and Module file location to your current Ant project directory.
You may also need to set right path to project output in Project Structure > Use module compile output path and set proper content route in Project Structure > Sources
Please, follow the steps below if you use the IntellIj:
Check the Ant plugin for the project.
select the build.xml file and add as the Ant build file
Use the side button to deploy the project

How to reuse classes with static methods as libraries, in Java? [duplicate]

I have Tapjoy sources sources, which have such sructure: Tapjoy/src/com/tapjoy/*.class
It must be compiled with Android API Level 9 and higher.
My project is in version Android API Level 8.
So I need to make from sources of Tapjoy -> tapjoy.jar file and include it to my main project.
How can I make .jar file properly with command line or from eclipse?
In Eclipse IDE, it's very easy to create a JAR file.
Just right click on your package > Export > Java > JAR File (and follow the wizard!)
Or from command line
jar cvf tapjoy.jar Tapjoy.class
both are possible
you can also use ant or maven for this kind of functionality.
check for the jar tool for commandline approach!
check eclipse ant build for eclipse approach and check the ant jar task for ant approach
In Netbeans IDE, you can easy create own jar library,
Projects on Right click -> Clean and build
Thats it. You can use it now your "Project Location"/dist/MyApplication.jar
All you need to do create new project and import your jar file How to import Jar File ?

How to launch ant clean target when executing eclipse Project clean

In order to simplify Eclipse use for our newbie users, we want to add this features to Eclipse :
1) If the user click on Project ---->Clean... , eclipse launches also the ant clean target which is implemented in the build.xml file of the concerned project.
2) When the user saves the code, the ant build is launched automatically.
Any link or a starting point.
Thank you in advance
You can add an Ant build file to the builders for a project in project Properties > Builders. Click New... and select Ant Builder. You can then specify the build.xml and select the targets used for clean, manual build and auto build (run during save).

How do I build ant's build.xml using NetBeans?

I've downloaded sources of one application using Subversion repository, but it turned out, that those sources were not composed to a NetBeans project. It was said in the manual, that I can build it using Apache Ant. I know, that NetBeans supports Ant by default. So here is the question - how can I tell NetBeans to run it's Ant on a specified build.xml?
File -> New Project
Then in Categories pick Java and then in Projects select Java Free-Form Project and hit Next. After that you will configure the project by selecting the location of the project the and build.xml and then associate targets in the build.xml with actions in the IDE.

How to distribute java project built in Eclipse?

Till now, I have been using Netbeans IDE for Java Applications. To distribute applications made in Netbeans, I just click on clean and build and it packs the application in .jar file which resides in a dist directory.
Now I have made a java project in Eclipse. Is Eclipse has any functionality similar to clean and build functionality of Netbeans by which we can pack java applications to distribute them.
You can right-click the project, select Export and choose Java, then JAR as the format.
File -> Export...
And choose Java -> JAR File. You will get a wizard to export any of your projects
Yes it has a clean and build functionality.
clean which clean all the developed a classes from the specified location
build which builds the class files at the same specified location respectively.
To distribute a project as a jar then you have to right click on the project and select export and in that select as jar.
Eclipse has a function to export the whole thing as a exetutable jar. It is under file>export.

Categories