RSS feed
All(28) Eclipse(4) Java(5) JDBC(5) JSP(3) Maven(7) Personal (1) Spring(3) Tomcat(5)
<< Integrate Tomcat and Apache on Windows with mod_jk | Home | Helpful Debugging MYSQL JDBC URL Parameters >>

Common Maven Commands

Maven Commands I use most frequently

The 3 commands that I use the most are:

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. This also places the artifact in your local maven repository.

Running with profile itest this profile is used to run my integration tests.  For Web Services the itest profile is useful because it seperates your unit tests  from your integration tests. Integration Tests can then be run after war is installed to a container for example.  There is an additional pom configuration to really use the profile, Ill come back to that in a later post. This I will run many times during the course of development, and is the most common command I use.

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

C:\mavenWorkspace> 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=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

WAR (Wep Application)

C:\mavenWorkspace> mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.yourcompany.yourdept -DartifactId=yourproject

Tags :



Add a comment Send a TrackBack