Basic Maven (m2eclipse / pom.xml) configuration

5 05 2012

Introducing Maven to Eclipse projects from scratch was described in my previous post. Now the basic usage and configuration will be described.

1a. Adding external jars (Maven dependencies)
To add some external jar file or reference to another workspace project you will need to:

Right Click on project -> Maven -> Add dependency

You can add it by filling in groupId, version etc. manually or search Maven repository by keyowrds. For example searching for JSON lib looks like in the picture below. After confirm, you will see changes reflected in pom.xml file.

1b. Another workspace project dependency
It is also possible to refer to another project, however it also has to be the Maven one (has its own pom.xml). Some instructions can be found here. Sample snippet of dependency in pom.xml is:


2. Setting the src folder
The issue after adding Maven nature to project in my case was Eclipse missing the source folder in project. src was present in workspace, however it was not recognized as source folder. The solution is to add following lines in pom.xml file (if more info is needed look at this source):


Note: Setting source folder by eclipse standard way (Build path -> Configure Build Path) will have no effect, because it will be reverted after Updating Maven Configuration.

3. Set JRE for project
If you want to use specific Java version in Maven project, you can use Maven plugin: compiler-plugin, as described here. It’s easy and requires only adding this entry to pom.xml file:


4. Problem with selecting targets for Maven builds
If You have problem with selecting targets (empty goals list), see solution here and corresponding bug description here.

It did not help me :D However solution makes sense and worth to try it anyway :)

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!



2 responses

12 05 2012
Use Maven with Android project « Looks OK!

[…] you need some more info on basic configuration of pom.xml for m2eclipse, look  here. Share this:Like this:LikeBe the first to like this […]

17 11 2012
Maven & Android: complete pom.xml files contents « Looks OK!

[…] files are operational, after performing all maven, m2eclipse and maven for android plugin […]

Give Your feedback:

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: