Maven 特性
- 最好的项目实践——在几秒钟内创建一个项目或者模块
- 始终一致的访问所有项目——意味着开发人员不在为项目准备而担忧
- 高级依赖管理,包括自动更新、依赖闭包(也可以说是传递依赖)
- 可以同时处理多个项目
- 一个不断增长的仓库,元数据库,并且可以直接使用,以实时提供最新版本的方式。
- 扩展,可以通过java或者其他脚本语言扩展插件
- 只需要少量或不需要额外配置即可访问新功能
- 用于依赖管理和maven外部部署的ant任务
- 基于模块构建:Maven可以构建任意数量的项目,如JAR,WAR或者发行版,并且大多数情况下不需要编写任何脚本
- Coherent site of project information: Using the same metadata as for the build process, Maven is able to generate a web site or PDF including any documentation you care to add, and adds to that standard reports about the state of development of the project. Examples of this information can be seen at the bottom of the left-hand navigation of this site under the "Project Information" and "Project Reports" submenus.
- Release management and distribution publication: Without much additional configuration, Maven will integrate with your source control system (such as Subversion or Git) and manage the release of a project based on a certain tag. It can also publish this to a distribution location for use by other projects. Maven is able to publish individual outputs such as a JAR, an archive including other dependencies and documentation, or as a source distribution.
- Dependency management: Maven encourages the use of a central repository of JARs and other dependencies. Maven comes with a mechanism that your project's clients can use to download any JARs required for building your project from a central JAR repository much like Perl's CPAN. This allows users of Maven to reuse JARs across projects and encourages communication between projects to ensure that backward compatibility issues are dealt with.
Maven的使用
安装
运行
maven允许使用这样的语法
1.mvn [options] [<goal(s)>][<phase(s)>]
所有可以操作的命令可以通过下面这个命令访问
1.mvn -h
构建maven项目典型使用例如
mvn package
构建生命周期与它们的阶段顺序是:
- clean——pre-clean,clean,post-clean
- default——validate(校验),initialize(初始化),generate-sources(生成源码),process-sources(处理源码), generate-resources(生成项目源文件),compile(编译),process-classes(处理class), generate-test-sources(生成-测试-源码), process-test-sources(处理-测试-源码), generate-test-resources(), process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test(集成测试前), integration-test, post-integration-test, verify(验证), install, deploy(部署)
- site——pre-site,site,post-site,site-deploy
生成所有包与文档文件可以以下命令构建
mvn clean deploy site-deploy
只是创建包与安装到本地可以通过以下命令
mvn verify