<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.jeedev.myproj</groupId>
<artifactId>myproj</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>myproj</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
|
mvn clean deploy -f pom_jar.xml
指定profile示例:
mvn clean deploy -P deploy -Dmaven.test.skip=true
mvn clean package -P all-in-one -Dmaven.test.skip=true (这里由于all-in-one配置了activeByDefault=true 故-P all-in-one可省略)
<profiles> <profile> <id>all-in-one</id> <activation> <activeByDefault>true</activeByDefault> </activation> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </profile> <profile> <id>deploy</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <inherited>false</inherited> <configuration> <excludes> application*, logback*, mybatis-config.xml, db/changelog/db.changelog-master.yml, db/changelog/db.changelog-master.yaml, com/domain/*Application.class, com/domain/product/*/*Application.class </excludes> </configuration> </plugin> </plugins> </build> </profile> </profiles> |
validate:验证工程是否正确,所有需要的资源是否可用。
compile:编译项目的源代码。
test:使用合适的单元测试框架来测试已编译的源代码。这些测试不需要已打包和布署。
Package:把已编译的代码打包成可发布的格式,比如jar。
integration-test:如有需要,将包处理和发布到一个能够进行集成测试的环境。
verify:运行所有检查,验证包是否有效且达到质量标准。
install:把包安装在本地的repository中,可以被其他工程作为依赖来使用。
Deploy:在集成或者发布环境下执行,将最终版本的包拷贝到远程的repository,使得其他的开发者或者工程可以共享。
clean:清除先前构建的artifacts(在maven中,把由项目生成的包都叫作artifact)。
site:为项目生成文档站点。
-Dmaven.test.skip=true 跳过单元测试
|
mvn -f xxx.xml可以指定pom文件进行构建。
mvn -s /path/to/user/my-settings.xml 指定settings文件
mvn dependency:purge-local-repository 删除本地仓库
分析jar包依赖关系
mvn dependency:analyze
mvn dependency:tree
mvn dependency:tree > tree.txt
mvn dependency:tree -Dverbose -Dincludes=org.elasticsearch > tree.txt
<build>
<finalName>mywebproj</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>7.0.0.pre5</version>
</plugin>
</plugins>
</build>
|
<build>
<finalName>mywebproj</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>7.0.0.pre5</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
|
相关参数说明
参数 | 默认值 | 说明 |
---|---|---|
allowSnapshots | false | 是否更新-snapshot快照版 |
artifactId | ${project.artifactId} | 指定artifactId |
generateBackupPoms | true | 是否备份pom文件 |
groupId | ${project.groupId} | 指定groupId |
newVersion | 设置的新版本号 | |
nextSnapshot | false | 更新版本号为下一个快照版本号 |
oldVersion | ${project.version} | 指定需要更新的版本号可以使用缺省‘*' |
processAllModules | false | 是否更新目录下所有模块无论是否声明父子节点 |
processDependencies | true | 是否更新依赖其的版本号 |
processParent | true | 是否更新父节点的版本号 |
processPlugins | true | 是否更新插件中的版本号 |
processProject | true | 是否更新模块自身的版本号 |
removeSnapshot | false | 移除snapshot快照版本,使之为release稳定版 |
updateMatchingVersions | true | 是否更新在子模块中显式指定的匹配版本(如/项目/版本)。 |
参考 versions-maven-plugin 命令介绍
http://aijezdm915.iteye.com/blog/1335025 maven Nexus入门指南(图文)
http://blog.csdn.net/wang379275614/article/details/43940259/ Maven仓库—Nexus环境搭建及简单介绍
http://121088825.iteye.com/blog/2337515 速度很快的 Maven 远程仓库(阿里云 nexus 仓库)