There are many advantages of having an IDE-independent build process including: automation, portability, flexibility, customization, documentation and the ability to introduce continuous integration processes. Indeed, most IDE vendors are recognizing this by building good Ant support into their products.
A good design practice is to adapt your IDE to a well thought out IDE-independent build process, rather than the other way around. This page provides a few techniques for achieving that goal.
JAM is basically Ant, which is supported by most IDEs. Just make sure your IDE uses Ant 1.6 or newer.
Once your POM (project.xml) file is defined, you can use Maven to automate project setup for Eclipse, JDeveloper, IntelliJ or JBuilder. For example, as shown below, you can create a new Eclipse project using the eclipse plugin's three goals:
maven eclipse:generate-project maven eclipse:generate-classpath maven eclipse:add-maven-repo
This section demonstrates various techniques for using JAM, Maven and Ant with Eclipse 3.x.
To create an Eclipse project using Maven, execute the following goals from the directory containing your POM file:
maven eclipse:generate-project maven eclipse:generate-classpath
These commands generate the Eclipse .project and .classpath files
containing project name and classpath information respectively. You can then import these projects into Eclipse by
choosing File -> Import, selecting Existing Project into Workspace, then clicking
Next >, followed by Browse..., then navigating to the directory containing the generated
files and finally clicking Finish.
If this is your first time integrating Maven and Eclipse, you can set the
the MAVEN_REPO global classpath variable to Maven's repository directory by typing:
maven eclipse:add-maven-repo
You can verify this setting (or set it manually) by selecting Window -> Preferences which
should look something like this:
If you wish to add a jar from the local repository to an Eclipse classpath, go to the Project Properties dialog select
Add Variable..., select MAVEN_REPO, then click Extend... and finally pick
the desired jar file. This process looks something this:
JAM will run within Eclipse if it can find two critical variables: jam.home
and maven.repo. These must be specified by selecting Window -> Preferences,
then navigating to Ant -> Runtime, selecting the Properties tab,
pressing Add Property... and finally defining the names and paths for these properties.
Note that in the following example diagram Eclipse-specific env_var variable is used to pull in environmental
variables. Note as well that USERPROFILE is a Windows-specific environmental variable which
will not work on other platforms. Of course hard-coding the paths works equally as well.
Cactus complains unless you place the JUnit jar in Ant's classpath. JAM avoids this issue by
installing a copy of the junit.jar under ${user.home}/.ant/lib which is
the standard location from which Ant loads library extensions on startup.
To run Cactus tests within Eclipse you must also add junit.jar to Ant's classpath from the
Window -> Preferences dialog as follows:
You can use the Eclipse Ant editor on JAM-generated files by adding their names to the
file association list found under Window -> Preferences.