Developing with Maven and Eclipse
The core CONGO build process is based on Maven (see BuildWithMaven for details), but it's convenient to be able to access the build features from inside your IDE. If your IDE is Eclipse, you have a few approaches available to you.
Maven's eclipse support is implemented by maven-eclipse-plugin
, which generates (and cleans up after) Eclipse projects based on the build settings. The plugin generates projects which refer to dependencies in your local Maven repository via an Eclipse Classpath Variable, M2_REPO
, which must be added to your workspace (m2eclipse, below, automates this).
Initial Setup
To add the variable, open the Eclipse Preferences and go to Java > Build Path > Classpath Variables. Add a variable named M2_REPO
and point it to your local repository (normally ~/.m2/repository
or C:\Documents and Settings\username\.m2\repositoiry
).
With WTP
To generate a WTP-compatible project from maven, run mvn eclipse:eclipse -Dwtpversion=1.5
, then use File > Import > General > Existing Project to bring the project into Eclipse. Use the standard WTP UI actions to load CONGO into your server of choice.
Whenever the dependencies in pom.xml
change, run mvn eclipse:eclipse -Dwtpversion=1.5
to update the Eclipse project, then refresh the project inside Eclipse.
Without WTP
To generate an Eclipse project from maven, run mvn eclipse:eclipse
, then use File > Import > General > Existing Project to bring the project into Eclipse.
Eclipse supports setting up external commands and tools as builders for a project, including Maven. I recommend setting up, at the very minimum, an external tools configuration for 'mvn clean install':
- Go to Run > External Tools > External Tools Configurations...
- Create a new configuration named "Build Congo"
- On the Main tab, configure the following:
- Location: enter or browse to the path to the
mvn
(or mvn.bat
, for Windows) program.
- Working Directory:
${workspace_loc:/congo}
- Arguments:
clean install
- On the Refresh tab, configure it to Refresh resources on completion, and tell it to refresh the selected resource.
- On the Build tab, uncheck Build before launch.
Whenever the dependencies in pom.xml
change, run mvn eclipse:eclipse
to update the Eclipse project, then refresh the project inside Eclipse.
Or you can run mvn
commands from a shell, like I do. -oj
m2eclipse
dbs?
See Also
http://maven.apache.org/plugins/maven-eclipse-plugin/usage.html