[Maven] tutorials
1.Create a Project
$ mvn archetype:generate
$ mvn archetype:generate -Dfilter=org.apache:struts
The displayed list will contain only archetypes with a groupId containing org.apache AND an artifactId containing struts-B [-DinteractiveMode=false] batch mode
$ mvn -B archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app
Or
$ mvn archetype:generate \
-DgroupId=com.mycompany.app \
-DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false
Creating a simple java project
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart
Maven Webapp Archetype
Creating a webapp
$ mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DarchetypeArtifactId=maven-archetype-webapp \
-DgroupId=com.mycompany.app \
-DartifactId=my-webapp
2.Frequently used commands
$ mvn compile
compile your application sources
$ mvn package
You can now take a look in the ${basedir}/target directory and you will see the generated JAR file.
$ mvn install
install the artifact you've generated (the JAR file) in your local repository (${user.home}/.m2/repository is the default location).
$ mvn clean
remove the target directory with all the build data before starting so that it is fresh.
$ mvn clean dependency:copy-dependencies package
An interesting thing to note is that phases and goals may be executed in sequence.This command will clean the project, copy dependencies, and package the project (executing all phases up to package, of course).
$ mvn eclipse:eclipse
Generates the following eclipse configuration files:.project and .classpath files
.setting/org.eclipse.jdt.core.prefs with project specific compiler settings
various configuration files for WTP (Web Tools Project), if the parameter wtpversion is set to a valid version (WTP configuration is not generated by default)
If this goal is run on a multiproject root, dependencies between modules will be configured as direct project dependencies in Eclipse (unless useProjectReferences is set to false).
Comments
Post a Comment