Integrate Maven with Eclipse via External Tool Configuration

During Eclipse development, it’s not practical to go outside of the Eclipse’s environment and execute Maven command in external console.

In this article, we show you how to integrate Maven command with Eclipse IDE, via Eclipse’s “External Tool Configuration“. Normally, this external tool is used to run external command within Eclipse environment, and it works prefectly with Maven command.

1. Configure “External Tool Configuration”

In Eclipse , menu bar, select “Run” –> “External Tool” –> “External Tool Configuration“. Create a new “program”, and link it to your Maven run command (mvn.bat in Windows), select the working project to run with Maven, and defined your Maven arguments, like “clean“, “clean package” , “test“, “install” and etc.

See following figure :

Integrate Maven with Eclipse

2. Run Maven in Eclipse

To run your new “External Tool Configuration“, select “Run” –> “External Tool” –> “tool name defined by you“. It will execute the Maven command and output the result in the Eclipse console view.

run maven command in eclipse
m2eclipse
Alternatively, you can install “m2eclipse Eclipse plugin“, which provides complete Maven integration for Eclipse IDE.

But, i do not like the plugin, because, Maven syntax comes with complete XSD support, and “External Tool Configuration” is work pretty well for me, just do not see any obvious benefits of installing this m2eclipse plugin.

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
5 Comment threads
4 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
5 Comment authors
amitavGubsJose AyerdisFandy Akhmadmkyong Recent comment authors
newest oldest most voted
Jose Ayerdis
Guest
Jose Ayerdis

Still It is tedious to be clicking over and over the External Tool> maven test | clean

No even m2eclipse has support for running maven quickly (whats up with that??)

Fandi
Guest
Fandi

Hy, Mkyong. can you show all configuration with external tools. ?
Thank you.

trackback
Organizziamoci con Maven – Parte II | Cose Non Javiste

[…] farlo sempre da riga di comando). Possiamo farlo usando Maven da external tool, come descritto in questo articolo postato su mkyong.com. Se questo vi sembra troppo oneroso per arrivare ad utilizzare Maven con il […]

amitav
Guest
amitav

[INFO] Scanning for projects… [WARNING] The POM for org.apache.tomcat.maven:tomcat7-compiler-plugin:jar:7 is missing, no dependency information available [WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-compiler-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-compiler-plugin:7 or one of its dependencies could not be resolved: Failure to find org.apache.tomcat.maven:tomcat7-compiler-plugin:jar:7 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO] [INFO] ———————————————————————— [INFO] Building onLineExam 0.0.1-SNAPSHOT [INFO] ———————————————————————— [WARNING] The POM for org.apache.tomcat.maven:tomcat7-compiler-plugin:jar:7 is missing, no dependency information available [WARNING] Failed to retrieve plugin… Read more »

Gubs
Guest
Gubs

Hi Mkyong,

What’s the content available in .bat file ? Because i want to do the same for linux machine.

Gubs

Gubs
Guest
Gubs

Hi Mkyong,

I installed maven in windows box also and found mvn.bat file is available in maven/bin directory. I will find the same in linux

Thanks

Gubs