Saturday, 5 March 2016

Maven : mvn package in Eclipse

Guys, as you maybe aware the command "mvn package" creates a package and stores it in the target directory. On the other side if you run "mvn install" it will create a package and then store it in your local repository.

I assume you have created a project from the archetypes from command line and then converted it to a Maven project after importing it in Eclipse.

Make sure the pom.xml has packaging set to jar by default. You could also change the package to war if needed.

Now simple right click the project to choose Run as -> Run Configurations.


Here you can specify the goals. In this case, we just want to create a simple package. So do this :


As you see, we also get various options for e.g. to build offline, skip tests, debug output etc. Now just enter the goals "clean package" and click Run.

You'll see that after a while a jar package gets created in the target directory of the project. Similarly if you run "clean install", it will install the jar to your local repository location. Make sure to double check the timestamp of the package from Terminal.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker