Saturday, July 2, 2016

quick maven note for myself

If you are java developer and maven should be very familiar. So I was surprise I never write a blog about maven but now I might as well write a short one. A note to keep myself reminded and can be revisited later.

To start a new maven java project, specify groupId, artifactId and archetypeArtifacId.
 start a mvn project  
 $ mvn archetype:generate -DgroupId=co.weetech -DartifactId=my-webapp -DarchetypeArtifacId=maven-archetype-quickstart -DinteractiveMode=false  

Once you have the directory build, start to add code and then when it is time to compile, let's do it!

 compile the project  
 $ mvn compile  

Sometime you have unit test and you write your unit test in the path ./src/test and then you can run them together using this command.

 test the project  
 $ mvn test

and if everything is compile and tested properly , you can start package them. Well, maven does that as well.

 package the project  
 $ mvn package  

the built library should be in the target directory. Finally if you want to install the package in your local directory, under home .m2, you can run the following command.

 to install the package, into your home .m2 directory  
 $ mvn install  

and if your project grows bigger and you want to edit your source code in eclipse, run the following command to generate the file descriptors.

 maven eclipse  
 $ mvn eclipse:eclipse  

That's it, these should get you started and if you encountered problem, google is your friend :-D and of cause maven documentation.

No comments:

Post a Comment