archetype:create-from-project

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

Description:

Creates an archetype project from the current project.

This goal reads your source and resource files, the values ofits parameters, and properties you specify in a.property file, and uses them to create a Mavenarchetype project using the maven-archetype packaging. If you buildthe resulting project, it will create the archetype. You can thenuse this archetype to create new projects that resemble theoriginal.

The maven-archetype-plugin uses Velocity to expand templatefiles, and this documentation talks about 'Velocity Properties',which are values substituted into Velocity templates. See TheVelocity User's Guide for more information.

This goal modifies the text of the files of the current projectto form the Velocity template files that make up the archetype.

GAV
The GAV values for the current project are replaced by properties: groupId, artifactId, and version. The user chooses newvalues for these when generating a project from the archetype.
package
All the files under one specified Java (or cognate) package arerelocated to a project that the user chooses when generating aproject. References to the class name are replaced by a propertyreference. For example, if the current project's sources are in thepackage org.apache.saltedpeanuts, then any example ofthe string org.apache.saltedpeanuts is replaced withthe Velocity property reference ${packageName}. Whenthe user generates a project, this is in turn replaced by his orher choice of a package.
custom properties
You may identify additional strings that should be replaced byparameters. To add custom properties, you must use the propertyFile parameter to specify a property file. Seethe documentation for propertyFile for thedetails.

Note that you may need to edit the results of this goal. Thisgoal has no way to exclude unwanted files, or add copyright noticesto the Velocity templates, or add more complex elements to thearchetype metadata file.

This goal also generates a simple integration-test thatexercises the generated archetype.

Attributes:

  • Requires a Maven project to be executed.
  • Executes as an aggregator plugin.
  • Invokes the execution of the lifecycle phase generate-sources prior to executing itself.


propertyFile:

The property file that holds the plugin configuration. If this isprovided, then the plugin reads properties from here. Theproperties in here can be standard properties listed below orcustom properties for this archetype. The standard properties arebelow. Several of them overlap parameters of this goal; it's betterto just set the parameter.
package
See the packageName parameter.
archetype.languages
See the archetypeLanguages parameter.
groupId
The default groupId of the generated project.
artifactId
The default artifactId of the generated project.
version
The default version of the generated project.
archetype.filteredExtensions
See the filteredExensions parameter.
Custom Properties

Custom properties allow you to replace some constant values inthe project's files with Velocity macro references. When a usergenerates a project from your archetype he or she gets theopportunity to replace the value from the source project.

Custom property names may not contain the '.'character.

For example, if you include a line like the following in yourproperty file:

        cxf-version=2.5.1-SNAPSHOT
the plugin will search your files for the string
2.5.1-SNAPSHOT
and replace them with references to a velocity macro
cxf-version
. It will then list
cxf-version
as a
requiredProperty
in the archetype-metadata.xml, with
2.5.1-SNAPSHOT
as the default value.

  • Type: java.io.File
  • Required: No
  • Expression: ${archetype.properties}

Usage:

[Run in a directory including pom.xml]

> mvn archetype:create-from-project 


The archetype will be generated in */target/generated-sources/archetype


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值