分类
Java Maven

Maven Aggregation Modules

内容纲要

Maven

What is Maven?

Getting Started

Guide To Configuring Maven

Here to download Maven.

On to creating your first project! In order to create the simplest of Maven projects, execute the following from the command line:

mvn -B archetype:generate \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DgroupId=com.mycompany.app \
  -DartifactId=my-app

Once you have executed this command, you will notice a few things have happened. First, you will notice that a directory named my-app has been created for the new project, and this directory contains a file named pom.xml that should look like this:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven Quick Start Archetype</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Introduction To The Standard Directory Layout

Index Subdirectory Description
1 src/main/java Application/Library sources
2 src/main/resources Application/Library resources
3 src/main/filters Resource filter files
4 src/main/webapp Web application sources
5 src/test/java Test sources
6 src/test/resources Test resources
7 src/test/filters Test resource filter files
8 src/it Integration Tests (primarily for plugins)
9 src/assembly Assembly descriptors
10 src/site Site
11 LICENSE.txt Project’s license
12 NOTICE.txt Notices and attributions required by libraries that the project depends on
13 README.txt Project’s readme
14 pom.xml

Introduction to Archetypes

Introduction to the Build Lifecycle

## Compile our application resources
mvn compile
## Packaging our project
mvn package
## Install our project
mvn install

## Compile out test sources
mvn test-compile
## Run our unit tests
mvn test

## Make Maven site
mvn site

## Clean the project
mvn clean

Note that the surefire plugin (which executes the test) looks for tests contained in files with a particular naming convention. By default the tests included are:

  • **/*Test.java
  • **/Test*.java
  • **/*TestCase.java

And the default excludes are:

  • **/Abstract*Test.java
  • **/Abstract*TestCase.java

Introduction to Repositories

Guide to Configuring Plugins

How do I create documentation

mvn archetype:generate \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-site \
  -DgroupId=com.mycompany.app \
  -DartifactId=my-app-site

Guide to creating a site

* How do I deploy my jar in my remote repository?

* How do I build more than one project at once?

See Project Aggregation.

* Introduction to the POM

* Reference for the Maven project descriptor used in Maven

Reference:

  1. Getting Started with Maven
  2. Maven Getting Started Guide
  3. Introduction to the Standard Directory Layout
  4. Introduction to the POM
  5. Introduction to the POM——翻译版

声明:
  未经特别说明,本站Blog均采用署名-非商业性使用-禁止演绎 2.5 中国大陆授权。任何违反本协议的行为均属于非法行为。如需非商业性转载,请保留署名。如需商业性转载出版,请直接和联系。

发表评论

邮箱地址不会被公开。 必填项已用*标注