Maven knowledge

From JazzTeamWiki
Jump to: navigation, search

Maven base info


In the case you have problems running your web application through maven command in eclipse (e.g. mvn jetty:run), and this problem is about com:sun:tools.jar - please specify in your eclipse in Installed JRE workspace settings Java SDK, but not JRE, as otherwise tools.jar is not found in JRE.

More details with screenshots could be found here

base goals

  • compile
  • test runs tests
  • eclipse:eclipse generates eclipse .classpath and .project files
  • eclipse:add-maven-repo adds maven repo to the workspace
  • jar:jar
  • install base goal, does all the work we need - compile, test, create jars and install at local repo
  • clean
  • package
  • site makes a site

additional goals

  • process-resources
  • validate
  • generate-sources
  • process-sources
  • generate-resources
  • process-resources
  • verify

base archetypes

  • simple project
mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \ \
  • site
  mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-site \ \
  • web application
mvn archetype:create \
    -DarchetypeGroupId=org.apache.maven.archetypes \
    -DarchetypeArtifactId=maven-archetype-webapp \ \

useful tips

say where eclipse workspace is
mvn eclipse:eclipse -Declipse.workspaсe=..
access java docs and sources
-DdownloadJavadocs=true -DdownloadSources=true
check mvn version 
mvn --version
official repo to check if dependencies are available
skipping tests
maven and JVM arguments
set MAVEN_OPTS=-Xmx512M -XX:MaxPermSize=128M
local pom file
		    <name>Maven Codehaus snapshot repository</name>
JPDA options to maven
export JPDA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
export MAVEN_OPTS="-XX:MaxPermSize=192m -Xmx512M $JPDA_OPTS"

Maven eclipse plugin

update maven eclipse 
remove plugin .m2\repository\org\apache\maven\plugins\maven-eclipse-plugin\ and run mvn eclipse:eclipse, what will push maven to download a new version of maven eclipse plugin. Otherwise some functionality may not be supported if you have old version of plugin
why it could be used
  • to analyze dependencies in a graphical way
  • to run maven config files from eclipse
  • to simplify editing of pom file

useful links

Apache CXF project how-to, build environment is entirely based on maven

Book on maven for eclipse plugin