`
flamezealot
  • 浏览: 20042 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

maven archetype

 
阅读更多

1、生成archetype

从已有的工程生成archetype,无论多module的还是单module的,都一样。

在工程目录下(如果是多module的,就在父module目录下)    执行

  mvn archetype:create-from-project

 

但是这样会把工程下所有文件都给打到archetype里去了,所以得加些配置,在目录建一个配置文件,

里面可以加入以下内容:

groupId   The default groupId of the generated project.

artifactId  The default artifactId of the generated project.

version  The default version of the generated project.

excludePatterns  A comma-separated list of paths that will not be included in the resulting archetype.

archetype.filteredExtensions File extensions which are checked for project's text files (vs binary files).

举个例子:

excludePatterns=.project,.classpath,.settings/**,target/**

 以上配置可以把eclipse生成的一些目录给过滤掉,现在执行命令

mvn archetype:create-from-project archetype.properties=xx.properties

 就会在当前目录的target下生成 generated-sources\archetype 这样一个目录,进入这个目录,在目录下执行

mvn install

 archetype就会被打到本地maven仓库里去。之后也可以mvn deploy上传到远程仓库。

 

 

 

2、利用archetype生成工程

在想要生成工程的目录下执行

mvn archetype:generate DarchetypeCatalog=local

 会列出来你本地仓库的所有archetype,可以选择你想要的,然后再根据提示依次输入groupId、artifactId、version、pacakge,就ok。如果不指定archetypeCatalog=local,会列出远程仓库的所有archetype,刷拉拉一大屏。。。

 

 参考:http://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics