Class CreateArchetypeFromProjectMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
Creates an archetype project from the current project.
This goal reads your source and resource files, the values of its parameters,
and properties you specify in a .property file, and uses them to
create a Maven archetype project using the maven-archetype packaging.
If you build the resulting project, it will create the archetype. You can then
use this archetype to create new projects that resemble the original.
The maven-archetype-plugin uses Velocity to expand template files, and this documentation talks about 'Velocity Properties', which are values substituted into Velocity templates. See The Velocity User's Guide for more information.
This goal modifies the text of the files of the current project to 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 new values for these when generating a project from the archetype.
- package
- All the files under one specified Java (or cognate) package are relocated to a project
that the user chooses when generating a project. References to the class name are replaced by a property reference. For
example, if the current project's sources are in the package
org.apache.saltedpeanuts, then any example of the stringorg.apache.saltedpeanutsis replaced with the Velocity property reference${packageName}. When the user generates a project, this is in turn replaced by his or her choice of a package. - custom properties
- You may identify additional strings that should be replaced by parameters.
To add custom properties, you must use the
propertyFileparameter to specify a property file. See the documentation forpropertyFilefor the details. - integration tests
- You may also specify a set of integration tests to be executed right after
you create archetype from the project. Each test consists of a separate folder under src/it/projects folder and
in there you specify
archetype.properties,goal.txtandverify.groovyfiles. Thearchetype.propertiesfile is the file used to generate a new project from the newly created archetype and thegoal.txta single-line file to specify the maven goal to invoke after generation of the test-project. Finally theverify.groovyis a groovy file that you can use to specify your assertions on the generated project.
Note that you may need to edit the results of this goal. This goal has no way to exclude unwanted files, or add copyright notices to the Velocity templates, or add more complex elements to the archetype metadata file.
This goal also generates a simple integration-test that exercises the generated archetype.
- Author:
- rafale
-
Field Summary
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsConstructorDescriptionCreateArchetypeFromProjectMojo(ArchetypeCreationConfigurator configurator, ArchetypeManager manager) -
Method Summary
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Constructor Details
-
CreateArchetypeFromProjectMojo
@Inject public CreateArchetypeFromProjectMojo(ArchetypeCreationConfigurator configurator, ArchetypeManager manager)
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-