Common Maven Commands
Maven Commands I use most frequently
1. eclipse:eclipse
C:\mavenWorkspace> mvn -U eclipse:eclipse
In eclipse F5 to refresh project to pick up new .classpath generated by eclipse:eclipse
This is used to update with the latest source from repositories and to regenerate the eclipse .project and .classpath files. I often have to do a refresh (F5) on the project node since this is running as an external command. There is probably a way to integrate the maven external command to automatically refresh the project but I havent figured that out yet. I usually do this along with a subversion update each time I start editing a project again that I develop with others that they may have changed.
2. Clean and Install with a Profile for Integration Testing
C:\mavenWorkspace> mvn clean install –Pitest
Similar to
ant clean build
Where build is your compile target.
3. Deploy your Artifact
C:\mavenWorkspace> mvn install deploy
This places the artifcat in your internal repository. So that others in your organization pick up your dependincies. Of course you should do an update from subversion each time before deploying so that you don’t deploy over anyone elses changes. I’m workign on how to set up the deploy target so that it doesn’t work without using the scm plugin to automatically do an svn update, however I haven’t got that up yet. Once I'm satisfied that my tests are passing and that I'm ready to share my newly developed code with the rest of the organization I run this command and at the same time, just after I check the code into subversion.
Other Maven Commands
C:\mavenWorkspace> mvn install war:war
Install and create a war file for distribution
-DgroupId=tomcat-dbcp
-DartifactId=naming-factory-dbcp -Dversion=5.5.17 -Dpackaging=jar -Dfile=C:\opt\tomcat\common\lib\naming-factory-dbcp.jar -DrepositoryId=your-internal-repo -Durl=scp://your-internal-repo-server:port/mav_root/internal
mvn deploy:deploy-file -DgroupId=tomcat-dbcp -DartifactId=naming-factory-dbcp -Dversion=5.5.17 -Dpackaging=jar -Dfile=C:\opt\tomcat\common\lib\naming-factory-dbcp.jar -DrepositoryId=cms-internal -Durl=scp://baksvr.cms:222/usr2/mav_root/internal
Deploys a 3rd party JAR as a Dependency I also run most of these commands via the external tools dialog in eclipse. Ill write more about that in another post.
Archetypes
Archetypes are a template for new projects, you can use the standard archetypes(for jars and wars), or create your own
JAR
C:\mavenWorkspace> mvn archetype:create -DgroupId=com.cms -DartifactId= yourproject
C:\mavenWorkspace>
