<commit_before>---
layout: post
title: Maven
date:  2016-5-6 20:56:13 +0800
categories: [apache]
tags: [maven]
---
* any list
{:toc}

## Maven

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM),
Maven can manage a project's build, reporting and documentation from a central piece of information.

> [maven](https://maven.apache.org/)


## Use

<uml>
download->install:
install->run:
</uml>


### Download

> [Download](https://maven.apache.org/download.cgi)

Requirements:

- JDK: Maven 3.3 requires **JDK 1.7** or above to execute - it still allows you to build against 1.3 and other JDK versions by Using Toolchains

- Disk: Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository.

The size of your local repository will vary depending on usage but expect at least **500MB**.

### Installing

> [Install](https://maven.apache.org/install.html)

> [doc zh_CN](http://blog.csdn.net/xxb2008/article/details/8772634)

- environment variable

```
   MAVEN_HOME: D:\Maven\apache-maven-3.3.9
```

- path

```
 %MAVEN_HOME%/bin;
```

- test:

```
Mvn -v
```

result

```java
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:4
7+08:00)
Maven home: D:\Maven\apache-maven-3.3.9\bin\..
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: D:\Program Files\Java\jdk1.7.0_79\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
```

### settings.xml

- open the settings.xml in **%MAVEN_HOME%\conf\settings.xml**

you will find code like this...

```java
<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository

  <localRepository>/path/to/local/repo</localRepository>
-->
```

You can change the path any you want;

### Create maven

you can create maven project in idea like this:

```
File-> new Module -> Maven
```

- STEP 1: select one from archetype

![maven]({{ site.url }}/static/app/img/2016-05-07-maven.jpg)

- STEP 2: add GroupId,ArtifactId,Version

![GroupId]({{ site.url }}/static/app/img/2016-05-07-groupId.jpg)

- STEP 3: set Properties

![Properties]({{ site.url }}/static/app/img/2016-05-07-properties.jpg)

> you can add code as following if maven build is very slow.

```
archetypeCatalog=internal
```



### Run project

- elegant way in cmd

```
mvn clean install

mvn tomcat7:run
```

- common way

[tomcat zh_CN](http://www.cnblogs.com/jifeng/p/4658765.html)

### Tips

- you can config the maven setting

<kbd>crtl</kbd>+<kbd>alt</kbd>+<kbd>s</kbd>

search maven

![maven setting]({{ site.url }}/static/app/img/2016-05-07-setting-config.jpg)

- Error like this.

```
-Dmaven.multiModuleProjectDirectory system propery is not set
```

1. you can use **Low version** maven to fit your idea.

2. or solve it like this.

```
-Dmaven.multiModuleProjectDirectory=$M2_HOME<commit_msg>maven<commit_after>---
layout: post
title: Maven
date:  2016-5-6 20:56:13 +0800
categories: [apache]
tags: [maven]
---
* any list
{:toc}

## Maven

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM),
Maven can manage a project's build, reporting and documentation from a central piece of information.

> [maven](https://maven.apache.org/)


## Use

<uml>
download->install:
install->run:
</uml>


### Download

> [Download](https://maven.apache.org/download.cgi)

Requirements:

- JDK: Maven 3.3 requires **JDK 1.7** or above to execute - it still allows you to build against 1.3 and other JDK versions by Using Toolchains

- Disk: Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository.

The size of your local repository will vary depending on usage but expect at least **500MB**.

### Installing

> [Install](https://maven.apache.org/install.html)

> [doc zh_CN](http://blog.csdn.net/xxb2008/article/details/8772634)

- environment variable

```
   MAVEN_HOME: D:\Maven\apache-maven-3.3.9
```

- path

```
 %MAVEN_HOME%/bin;
```

- test:

```
Mvn -v
```

result

```java
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:4
7+08:00)
Maven home: D:\Maven\apache-maven-3.3.9\bin\..
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: D:\Program Files\Java\jdk1.7.0_79\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
```

### settings.xml

- open the settings.xml in **%MAVEN_HOME%\conf\settings.xml**

you will find code like this...

```java
<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository

  <localRepository>/path/to/local/repo</localRepository>
-->
```

You can change the path any you want;

### Create maven

you can create maven project in idea like this:

```
File-> new Module -> Maven
```

- STEP 1: select one from archetype

![maven]({{ site.url }}/static/app/img/2016-05-07-maven.jpg)

- STEP 2: add GroupId,ArtifactId,Version

![GroupId]({{ site.url }}/static/app/img/2016-05-07-groupId.jpg)

- STEP 3: set Properties

![Properties]({{ site.url }}/static/app/img/2016-05-07-properties.jpg)

> you can add code as following if maven build is very slow.

```
archetypeCatalog=internal
```



### Run project

- elegant way in cmd

```
mvn clean install

mvn tomcat7:run
```

- common way

[tomcat zh_CN](http://www.cnblogs.com/jifeng/p/4658765.html)

### Tips

<label class="label label-info">Setting</label>

You can config the maven setting use

<kbd>crtl</kbd>+<kbd>alt</kbd>+<kbd>s</kbd>

then search **maven**

![maven setting]({{ site.url }}/static/app/img/2016-05-07-setting-config.jpg)


<label class="label label-danger">Error</label>

```
-Dmaven.multiModuleProjectDirectory system propery is not set
```

1. you can use **Low version** maven to fit your idea.

2. or solve it like this.

```
-Dmaven.multiModuleProjectDirectory=$M2_HOME
{'fraction_non_alphanumeric': 0.14819004524886878, 'fraction_numerical': 0.049773755656108594, 'mean_word_length': 3.979082864038616, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 47, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1848296', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2171, 'n_words': 646}