Maven Mini Guide
From Lift
Maven is the default tool use to create, build, test and manage lift based webapp.
Contents |
Command mememto
- Create a new project (interactive)
-
From the parent directory of the future project
mvn archetype:generate -DarchetypeCatalog=http://scala-tools.org/
- Create a new project (non-interactive)
-
From the parent directory of the future project
mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create \ -DarchetypeGroupId=net.liftweb \ -DarchetypeArtifactId=lift-archetype-blank \ -DarchetypeVersion=0.7.1 \ -DremoteRepositories=http://scala-tools.org/repo-releases \ -DgroupId=your.proj.gid -DartifactId=your-proj-id
or
mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create \ -DarchetypeGroupId=net.liftweb \ -DarchetypeArtifactId=lift-archetype-basic \ -DarchetypeVersion=0.7.1 \ -DremoteRepositories=http://scala-tools.org/repo-releases \ -DgroupId=your.proj.gid -DartifactId=your-proj-id
- Building the war file
-
From the project directory (where the pom.xml file is located)
mvn package
- Running the webapp
-
From the project directory (where the pom.xml file is located)
(with Jetty for development and test only)mvn jetty:run -U
This command compiles and runs the tests before starting Jetty
- Compiling the code in a loop (non-stop)
-
From the project directory (where the pom.xml file is located)
mvn scala:cc
- Generate/update the eclipse configuration file
-
mvn eclipse:eclipse
(see Using eclipse hotdeploy)
Maven usage
usage: mvn [options] [<goal(s)>] [<phase(s)>]
Options:
-q,--quiet Quiet output - only show errors
-C,--strict-checksums Fail the build if checksums don't match
-c,--lax-checksums Warn if checksums don't match
-P,--activate-profiles Comma-delimited list of profiles to
activate
-ff,--fail-fast Stop at first failure in reactorized builds
-fae,--fail-at-end Only fail the build afterwards; allow all
non-impacted builds to continue
-B,--batch-mode Run in non-interactive (batch) mode
-fn,--fail-never NEVER fail the build, regardless of project
result
-up,--update-plugins Synonym for cpu
-N,--non-recursive Do not recurse into sub-projects
-npr,--no-plugin-registry Don't use ~/.m2/plugin-registry.xml for
plugin versions
-U,--update-snapshots Forces a check for updated releases and
snapshots on remote repositories
-cpu,--check-plugin-updates Force upToDate check for any relevant
registered plugins
-npu,--no-plugin-updates Suppress upToDate check for any relevant
registered plugins
-D,--define Define a system property
-X,--debug Produce execution debug output
-e,--errors Produce execution error messages
-f,--file Force the use of an alternate POM file.
-h,--help Display help information
-o,--offline Work offline
-r,--reactor Execute goals for project found in the
reactor
-s,--settings Alternate path for the user settings file
-v,--version Display version information
Main phases
- validate - Validate that the project is correct and that all necessary information is available
- compile - Compile the source code of the project
- test - Test the compiled source code using a suitable unit testing framework. These tests should not require the code to be packaged or deployed
- package - Take the compiled code and package it in its distributable format, such as a JAR.
- integration-test - Process and deploy the package if necessary into an environment where integration tests can be run
- verify - Run any checks to verify that the package is valid and meets quality criteria
- install - Install the package into the local repository, for use as a dependency in other projects locally
- deploy - Done in an integration or release environment,
deploycopies the final package to the remote repository for sharing with other developers and projects.
Info "en vrac"
- archetype
- A project template in Maven's terminology
- artifact
- The main result of a project (e.g., a jar, a war, an ear, etc.)
- goal
- An available command on a maven plugin
- groupId (of an artifact)
- The unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org.apache.maven.plugins is the designated groupId for all Maven plug-ins.
- artifactId (of an artifact)
- The unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form <artifactId>-<version>.<extension> (for example, myapp-1.0.jar ).
- version (of an artifact)
- The version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the SNAPSHOT designator in a version, which indicates that a project is in a state of development.
- WAR file (Web ARchive)
- The archive of the webapp, following JEE convention
- Maven is a command line tool
- "mvn" is the name of the command line tool to call maven 2.x. To display help, run mvn help
- the project descriptor
- The file ([project]/pom.xml) where all project information is stored (e.g., name, version, dependencies, license, mailing-list, etc.)
- the build lifecycle
- The build lifecycle is defined by a sequence of phases. The main phases are:
- compile - Compile the source code of the project
- test - Test the compiled source code using a suitable unit testing framework. These tests should not require that the code be packaged or deployed
- package - Take the compiled code and package it in its distributable format, such as a JAR or WAR.
- integration-test - Process and deploy the package if necessary into an environment where integration tests can be run
- install - Install the package into the local repository, for use as a dependency in other projects locally
- deploy - Done in an integration or release environment,
deploycopies the final package to the remote repository for sharing with other developers and projects.
- A phase depends on the previous one, so when you request the phase
test, then the phasecompileis done first - repository
- Maven uses repositories (local and remote) to store and to retrieve artifacts and their descriptors (pom). Artifacts include jar files, war files, etc., and they can be used as dependencies, maven plugins, and more. By default, maven searches for artifacts in the central repository. This is a "dedicated" repository for Scala stuff and is available at http://scala-tools.org/repo-releases/ (it hosts lift's artifacts). If you wish to search for artifacts in the central repository, there is a search engine at http://mvnrepository.com .
Links
General Documentation
- maven's official site
- Maven: The Definitive Guide (online book)
Plugins
- Plugins use in the memento :
- maven-scala-plugin : the plugin use to compile scala source code
- maven-war-plugin : the plugin to build/assemble war and webapp
- maven-eclipse-plugin : generate an Eclipse project file for the current project
- maven-jetty-plugin : the plugin use to run jetty from maven
- Plugins usefull for web projects
- yuicompressor-maven-plugin : compress (Minify + Ofuscate) Javascript files and CSS files using YUI Compressor
- winstone-maven-plugin : embed your warfile into/with the winstone JAR itself. This allows an all-in-one container plus web-application JAR file to run as a standalone application
- others links
- Some Catalogs
Doc about maven + scala/lift
- maven for scala : an introduction to maven for scala user
- Archetypes : info about the lift's archetype

