Maven命令简介:更好更快地管理项目

Maven自带了很多的工程骨架,想自定义骨架可以使用交互式命令:
Xml代码  收藏代码

    mvn archetype:generate 



我的是Maven 2.2.1版本,系统自带的骨架一共有41个:
Xml代码  收藏代码

    1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF) 
    2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC) 
    3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2) 
    4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4) 
    5: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire) 
    6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF) 
    7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modularapplication with Hibernate, Spring and Spring MVC) 
    8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modularapplication with Hibernate, Spring and Struts 2) 
    9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4) 
    10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application) 
    11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade) 
    12: internal -> maven-archetype-mojo (A Maven Java plugin development project) 
    13: internal -> maven-archetype-portlet (A simple portlet application) 
    14: internal -> maven-archetype-profiles () 
    15: internal -> maven-archetype-quickstart () 
    16: internal -> maven-archetype-site-simple (A simple site generation project) 
    17: internal -> maven-archetype-site (A more complex site project) 
    18: internal -> maven-archetype-webapp (A simple Java web application) 
    19: internal -> jini-service-archetype (Archetype for Jini service project creation) 
    20: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype) 
    21: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype) 
    22: internal -> softeu-archetype-jsf (JSF+Facelets Archetype) 
    23: internal -> jpa-maven-archetype (JPA application) 
    24: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype) 
    25: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype) 
    26: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype) 
    27: internal -> maven-archetype-har (Hibernate Archive) 
    28: internal -> maven-archetype-sar (JBoss Service Archive) 
    29: internal -> wicket-archetype-quickstart (A simple Apache Wicket project) 
    30: internal -> scala-archetype-simple (A simple scala project) 
    31: internal -> lift-archetype-blank (A blank/empty liftweb project) 
    32: internal -> lift-archetype-basic (The basic (liftweb) project) 
    33: internal -> cocoon-22-archetype-block-plain ([http://cocoon.apache.org/2.2/maven-plugins/]) 
    34: internal -> cocoon-22-archetype-block ([http://cocoon.apache.org/2.2/maven-plugins/]) 
    35: internal -> cocoon-22-archetype-webapp ([http://cocoon.apache.org/2.2/maven-plugins/]) 
    36: internal -> myfaces-archetype-helloworld (A simple archetype using MyFaces) 
    37: internal -> myfaces-archetype-helloworld-facelets (A simple archetype usingMyFaces and facelets) 
    38: internal -> myfaces-archetype-trinidad (A simple archetype using Myfaces and Trinidad) 
    39: internal -> myfaces-archetype-jsfcomponents (A simple archetype for create custom JSF components using MyFaces) 
    40: internal -> gmaven-archetype-basic (Groovy basic archetype) 
    41: internal -> gmaven-archetype-mojo (Groovy mojo archetype) 



当然,我们完全可以通过命令指定骨架,下面列出几常用的用法:



创建普通Java项目:
mvn archetype:create -DgroupId=[your project's group id] -DartifactId=[your project's artifact id]
Xml代码  收藏代码

    mvn archetype:create -DgroupId=com.aboy -DartifactId=webmap 



创建WEB项目:
mvn archetype:create -DgroupId=[your project's group id] -DartifactId=[your project's artifact id] -DarchetypeArtifactId=maven-archetype-webapp
Xml代码  收藏代码

    mvn archetype:create -DgroupId=com.aboy -DartifactId=webmap -DarchetypeArtifactId=maven-archetype-webapp 



Maven其它命令简单说明:

1、archetype( 内建插件,他的create任务将建立项目骨架 ): archetype:create



2、groupId 项目的java包结构:com.aboy



3、artifactId 项目的名称:webmap



4、显示Maven默认设置 
Xml代码  收藏代码

    mvn help:effective-pom 



5、几个常用的archetypeArtifactId(项目骨架的类型):
* maven-archetype-archetype
* maven-archetype-j2ee-simple
* maven-archetype-mojo
* maven-archetype-portlet
* maven-archetype-profiles
* maven-archetype-quickstart
* maven-archetype-simple
* maven-archetype-site
* maven-archetype-site-simple
* maven-archetype-webapp



6、生成清除Eclipse项目结构:
Xml代码  收藏代码

    mvn eclipse:eclipse 
    mvn eclipse:clean 



7、清理(删除target目录下编译内容)
Xml代码  收藏代码

    mvn clean 



8、仅打包Web页面文件
Xml代码  收藏代码

    mvn war:exploded 



9、Maven的主要生命周期:
validate: 验证项目是否正确以及相关信息是否可用
compile: 编译
test: 通过junit进行单元测试
package: 根据事先指定的格式(比如jar),进行打包
integration-test: 部署到运行环境中,准备进行集成测试
verify: 对包进行有效性性和质量检查
install: 安装到本地代码库
deploy: 在集成或发布环境,将包发布到远程代码库

猜你喜欢

转载自able0001.iteye.com/blog/986957
今日推荐