Ø 一个简单的Maven项目。
Maven Help 插件有四个目标。前三个目标是—— active-profiles, effective-pom 和
effective-settings —— 描述一个特定的项目,它们必须在项目的目录下运行。 最后
一个目标—— describe ——相对比较复杂,展示某个插件或者插件目标的相关信息。
§ help:active-profiles 列出当前构建中活动的Profile(项目的,用户的,全局的)。
§ help:effective-pom 显示当前构建的实际POM,包含活动的Profile。
§ help:effective-settings 打印出项目的实际settings, 包括从全局的settings和用户级别settings继承的
配置。
§ help:describe 描述插件的属性。它不需要在项目目录下运行。但是你必须提供你想要描述插件
的 groupId 和 artifactId。
下面的命令使用 help 插件的 describe 目标来输出Maven Help 插件的信息。
mvn help:describe -Dplugin=help
|
mvn help:describe -Dplugin=help -Dfull
|
mvn help:effective-pom
|
Ø 创建一个简单的MAVEN项目
Create:
mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app
Build,Maven会把我们项目的构件安装到本地仓库:
$ mvn install
C:\Project\GC_source_CVS_R1.1\simple>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ simple ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Project\GC_source_CVS_R1.1\simple\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ simple ---
[INFO] Compiling 1 source file to C:\Project\GC_source_CVS_R1.1\simple\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ simple ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Project\GC_source_CVS_R1.1\simple\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ simple ---
[INFO] Compiling 1 source file to C:\Project\GC_source_CVS_R1.1\simple\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ simple ---
[INFO] Surefire report directory: C:\Project\GC_source_CVS_R1.1\simple\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ simple ---
[INFO] Building jar: C:\Project\GC_source_CVS_R1.1\simple\target\simple-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ simple ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.860s
[INFO] Finished at: Wed May 09 15:58:18 CST 2012
[INFO] Final Memory: 9M/22M
[INFO] ------------------------------------------------------------------------
C:\Project\GC_source_CVS_R1.1\simple>java -cp target/simple-1.0-SNAPSHOT.jar com.App
Hello World!
|
pom.xml 文件
Maven项目的坐标(coordinate)
§ groupId
d 团体,公司,小组,组织,项目,或者其它团体。团体标识的约定是,它以创建这个项目的组织名称的逆向域名(reverse domain name)开头。
§ artifactId
在groupId下的表示一个单独项目的唯一标识符。
§ version
一个项目的特定版本。发布的项目有一个固定的版本标识来指向该项目的某一个特定的版本。而正在开发中的项目可以用一个特殊的标识,这种标识给版本加上一个“SNAPSHOT”的标记。
§ packaging
项目的类型,默认是jar,描述了项目打包后的输出。类型为jar的项目产生一个JAR文件,类型为war的项目产生一个web应用。
|
Maven项目的坐标(coordinate)
§ groupId
d 团体,公司,小组,组织,项目,或者其它团体。团体标识的约定是,它以创建这个项目的组织名称的逆向域名(reverse domain name)开头。
§ artifactId
在groupId下的表示一个单独项目的唯一标识符。
§ version
一个项目的特定版本。发布的项目有一个固定的版本标识来指向该项目的某一个特定的版本。而正在开发中的项目可以用一个特殊的标识,这种标识给版本加上一个“SNAPSHOT”的标记。
§ packaging
项目的类型,默认是jar,描述了项目打包后的输出。类型为jar的项目产生一个JAR文件,类型为war的项目产生一个web应用。
|
Maven项目的坐标(coordinate)
§ groupId
d 团体,公司,小组,组织,项目,或者其它团体。团体标识的约定是,它以创建这个项目的组织名称的逆向域名(reverse domain name)开头。
§ artifactId
在groupId下的表示一个单独项目的唯一标识符。
§ version
一个项目的特定版本。发布的项目有一个固定的版本标识来指向该项目的某一个特定的版本。而正在开发中的项目可以用一个特殊的标识,这种标识给版本加上一个“SNAPSHOT”的标记。
§ packaging
项目的类型,默认是jar,描述了项目打包后的输出。类型为jar的项目产生一个JAR文件,类型为war的项目产生一个web应用。
|
<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">
Maven项目的坐标(coordinate)
§ groupId
d 团体,公司,小组,组织,项目,或者其它团体。团体标识的约定是,它以创建这个项目的组织名称的逆向域名(reverse domain name)开头。
§ artifactId
在groupId下的表示一个单独项目的唯一标识符。
§ version
一个项目的特定版本。发布的项目有一个固定的版本标识来指向该项目的某一个特定的版本。而正在开发中的项目可以用一个特殊的标识,这种标识给版本加上一个“SNAPSHOT”的标记。
§ packaging
项目的类型,默认是jar,描述了项目打包后的输出。类型为jar的项目产生一个JAR文件,类型为war的项目产生一个web应用。
|
<modelVersion>4.0.0</modelVersion>
<groupId>com.ch03</groupId>
<artifactId>simple</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>simple</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>
仓库的根目录
/<groupId>/<artifactId>/<version>/<artifactId>-<version>.<packaging>
|
Ø Maven插件和目标 (Plugins and Goals)
当提到一个插件目标的时候,我们常常用速记符号:pluginId:goalId。
例如,当提到Archetype插件的generate目标的时候,我们写
成archetype:generate。
Ø Maven生命周期 (Lifecycle) Lifecycle Reference
Clean Lifecycle
pre-clean
|
executes processes needed prior to the actual project cleaning
|
|
clean
|
remove all files generated by the previous build
|
clean:clean
|
post-clean
|
executes processes needed to finalize the project cleaning
|
|
Default Lifecycle
validate
|
validate the project is correct and all necessary information is available.
|
|
initialize
|
initialize build state, e.g. set properties or create directories.
|
|
generate-sources
|
generate any source code for inclusion in compilation.
|
ear:generateApplicationXml
|
process-sources
|
process the source code, for example to filter any values.
|
resources:resources
|
generate-resources
|
generate resources for inclusion in the package.
|
|
process-resources
|
copy and process the resources into the destination directory, ready for packaging.
|
|
compile
|
compile the source code of the project.
|
compiler:compile
|
process-classes
|
post-process the generated files from compilation, for example to do bytecode enhancement on Java classes.
|
|
generate-test-sources
|
generate any test source code for inclusion in compilation.
|
|
process-test-sources
|
process the test source code, for example to filter any values.
|
resources:testResources
|
generate-test-resources
|
create resources for testing.
|
|
process-test-resources
|
copy and process the resources into the test destination directory.
|
|
test-compile
|
compile the test source code into the test destination directory
|
compiler:testCompile
|
process-test-classes
|
post-process the generated files from test compilation, for example to do bytecode enhancement on Java classes. For Maven 2.0.5 and above.
|
|
test
|
run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed.
|
surefire:test
|
prepare-package
|
perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package. (Maven 2.1 and above)
|
|
package
|
take the compiled code and package it in its distributable format, such as a JAR.
|
ejb:ejb or ejb3:ejb3 or jar:jar or par:par or rar:rar or war:war
|
pre-integration-test
|
perform actions required before integration tests are executed. This may involve things such as setting up the required environment.
|
|
integration-test
|
process and deploy the package if necessary into an environment where integration tests can be run.
|
|
post-integration-test
|
perform actions required after integration tests have been executed. This may including cleaning up the environment.
|
|
verify
|
run any checks to verify the package is valid and meets quality criteria.
|
|
install
|
install the package into the local repository, for use as a dependency in other projects locally.
|
install:install
|
deploy
|
done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
|
deploy:deploy
|
Site Lifecycle
pre-site
|
executes processes needed prior to the actual project site generation
|
|
site
|
generates the project's site documentation
|
site:site
|
post-site
|
executes processes needed to finalize the site generation, and to prepare for site deployment
|
|
site-deploy
|
deploys the generated site documentation to the specified web server
|
site:deploy
|
分享到:
相关推荐
maven入门到精通 用 Maven 做项目管理 在 Java世界中我们很多的开发人员选择用 Ant来构建项目,一个 build.xml能够完成编译、测试、打包、部署等很多任务,但我们也碰到了很多的问题,如 jar文件管理混乱,各个...
Maven入门到精通. 做好人不要资源分
Maven 入门到进阶 #资源达人分享计划 #技术文档
Maven入门案例,Maven安装,Maven配置,Maven案例,Maven常见命令
maven教案,maven学习资料,maven入门
Maven入门文档,maven使用方法的简介
1.13 Maven入门--概念与实例 1.14 Subversion 1.15 jar war ear区别 1.16 如何在Eclipse中调试JBoss应用 1.17 JBoss 5.0 安装与配置详解 1.18 JBOSS安装配置 1.19 Oracle,MySql,SQL server分页 1.20 Jboss...
maven 入门笔记配套示例代码 maven 入门笔记配套示例代码 maven 入门笔记配套示例代码
NULL 博文链接:https://georgema2000.iteye.com/blog/1062887
maven 入门到精通
技术部Maven入门培训
开发部Maven入门培训.pptx
HAP框架-Maven入门手册.doc
Maven入门--概念与实例.doc
Maven入门教程
开发部Maven入门培训2.pptx
Myeclipse优化 开发环境配置 SSHE MAVEN入门
HAP框架-Maven入门手册.zip