build directory -> target
source directory -> src/main/java
test source directory -> /src/main/test
The goals or plugins are now configured in the pom.xml. When executing a task or goal, Maven looks for the POM in the current directory. It reads the POM, gets the needed configuration information, then executes the goal.
Configuration that can be specified in the POM are:
- project dependencies
- plugins
- goals
- build profiles
- project version
- description
- developers
- mailing lists
The minimum requirement for a POM are the following:
- project root
- modelVersion
- groupId
- artifactId
- version
Project: the top level element in all Maven pom.xml files
modelVersion This element indicates what version of the object model this POM is using.
groupId: This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of aproject and is typically based on the fully qualified domain name of your organization.
artifactId: this element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file.
Introduction to the Standard Directory Layout
Having a common directory layout would allow for users familiar with one Maven project to immediately feel at home in another Maven project. The advantages are analogous to adopting a site-wide look and feel.
src/main/java: Application/Library sources
src/main/resources: Application Library resources
src/main/filters: Resource filter files
src/main/assembly: Assembly descriptors
src/main/config: Configuration files
src/main/webapp: Web application sources
src/test/java: Test sources
src/test/resources: Test resources
src/test/filters: Test resource filter files
src/site: Site
Introduction to Repositories
A repository in Maven is used to hold build artifacts and dependencies of varying types.
There are strictly only two types of repositories: local and remote.
The local repository refers to a copy on your own installation that is a chache of the remote downloads, and also contains the temporary build artifacts that you have not yet released.
The remote repository refer to any other type of repository, accessed by a variety of protocols such as file://and http://. These repositories might be truely remote repository set up by a third party to provide their artifacts for downloading. Other "remote" repositories may be internal repositories set up on a file or HTTP server within your company, used to share private artifacts between development teams and for releases.
$mvn archetype:create -DgroupId=mavenbook -DartifactId=my-app
archetype:create is called a Maven "goal". The plugin is the prefix "archetype" and the the goal is to "create". -Dname=value pairs are arguments.
A phase is a step in what Maven calls the "build lifecycle".
ref
Maven war plugin
The default resource directory for all maven2 projects is src/main/resources which will end up in target/classes and in WEB-INF/classes in the war.
src/main/resources -> target/classes
src/main/resources -> WEB-INF/classes (war file)
ref
Maven2 step by step