maven 常用命令goal

1.显示一个插件所有的goal
2.创建一个基于模版的项目,eclipse项目
//创建标准目录模板
mvn archetype:create -DgroupId=com.codeline.commons -DartifactId=codelineCommons
//创建web项目
mvn archetype:create -DgroupId=com.mycompany.app    -DartifactId=my-webapp       -DarchetypeArtifactId=maven-archetype-web

3.查看一个插件所用的版本
mvn -Dplugin=groupId:artifactId help:describe
4.忽略编译test
mvn -Dmaven.test.skip=true
5.一个jar文件,它是maven的一个插件,怎么安装到本地库。
   mvn install:install-file
       -Dfile=<path-to-file>
    -DgroupId=<group-id>
    -DartifactId=<artifact-id>
    -Dversion=<version>
    -Dpackaging=<packaging>
    -DgeneratePom=true

6.maven的生命周期
    validate,验证工程是否正确,所有需要的资源是否可用。
    compile,编译项目的源代码。
    test-compile,编译项目测试代码。
    test,使用已编译的测试代码,测试已编译的源代码。
    package,已发布的格式,如jar,将已编译的源代码打包。
    integration-test,在集成测试可以运行的环境中处理和发布包。
    verify,运行任何检查,验证包是否有效且达到质量标准。
    install,把包安装在本地的repository中,可以被其他工程作为依赖来使用
   deploy,在整合或者发布环境下执行,将最终版本的包拷贝到远程的repository,使得其他的开发者或者工程可以共享。 
   generate-sources,产生应用需要的任何额外的源代码,如xdoclet。
7.Dependency Scope
compile,缺省值,适用于所有阶段,会随着项目一起发布。
provided,类似compile,期望JDK、容器或使用者会提供这个依赖。如servlet.jar。
runtime,只在运行时使用,如JDBC驱动,适用运行和测试阶段。
test,只在测试时使用,用于编译和运行测试代码。不会随项目发布。
system,类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它
eg:
<dependency>
    <groupId>hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>3.0.3</version>
    <scope>test</scope>
</dependency>

【转载地址】http://hamber.iteye.com/blog/1605209

猜你喜欢

转载自hck.iteye.com/blog/1931128