1- MAVEN Projects
- use pom.xml to describe the project dependencies,such as third party jars used
- use pom.xml to describe the build process,such as using build plugin to achieve specific building process
- use pom.xml to manage multiple projects/modules, modules are in pom.xml, modules section
- a lot other stuff……
2- MAVEN Artifact Vector
MAVEN Project produces an element, JAR,WAR or EAR, uniquely identified by a composite of fields known as groupId,artificatId,packing,version and scope. This vector of fields uniquely distinguishes a MAVEN artifact from all others.
the samples as follow:
groupid:artifactid:packaging:version:scope
org.springframework:spring:jar:4.3.2:compile
3- MAVEN Lifecycles
Phases,Plugins and Goals
- Build-in Maven Default Lifecycles:
- Site lifecycle
4- Maven Help
help: describe -Dplugin=
mvn help:effective-pom
mvn help:active-profiles
5- MAVEN Dependency
- declaring dependencies
<dependencies>
<dependency> <groupId>com.yourcompany</groupId> <artifactId>yourlib</artifactId> <version>1.0</version> <type>jar</type> <scope>compile</scope>
</dependency>
</dependencies>
- declaring plugins
<build>
<plugins>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration>
<maxmem>512m</maxmem> </configuration>
</plugin>
</plugins>
</build>
6- Maven Scope
scope in dependency:
7- Learning Dependencies
To Understand the dependencies for whole project,you can use following commands:
mvn dependency:tree
mvn dependency:resolve ## sorted
mvn dependency:resolve-plugins
mvn dependency:analyze
8- Declaring Repository
Repository is somewhere you can get the jars/wars
<repositories>
<repository>
<id>JavaDotNetRepo</id>
<url>https://maven-repository.dev.java.net</url>
</repository>
</repositories>
9- Maven Properties
-
Prefefined Properties
-
self defined properties
<project>
<properties>
<my.somevar>My Value</my.somevar>
</properties>
</project>
10- Maven Debug
commands for debug:
mvn -e # stacktrace
mvn -X #
mvnDebug
11- Maven Profile activation
mvn -P profileName
profile setting:
<profiles>
<profile>
<id>YourProfile</id> [...settings, build, etc...]
<activation>
<os>
<name>Windows XP</name> <family>Windows</family> <arch>x86</arch> <version>5.1.2600</version>
</os> <file>
<missing>somefolder/somefile.txt</missing> </file>
</activation>
</profile>
</profiles>
##12- Maven Release
mvn release: repare
mvn release: perform
13- Maven Reports
reports defined in reporting section, these reports could be coverage report, and any other reports.
近期评论