@Mojo(name="create-from-project", requiresProject=true, aggregator=true) @Execute(phase=GENERATE_SOURCES) public class CreateArchetypeFromProjectMojo extends AbstractMojo
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.
org.apache.saltedpeanuts
, then
any example of the string org.apache.saltedpeanuts
is 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.
propertyFile
parameter to specify a property file.
See the documentation for propertyFile
for the details.
archetype.properties
, goal.txt
and verify.groovy
files.
The archetype.properties
file is the file used to generate a new project from the newly created archetype
and the goal.txt
a single-line file to specify the maven goal to invoke after generation of the test-project.
Finally the verify.groovy
is 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.
Constructor and Description |
---|
CreateArchetypeFromProjectMojo() |
Modifier and Type | Method and Description |
---|---|
void |
execute() |
getLog, getPluginContext, setLog, setPluginContext
public void execute() throws MojoExecutionException, MojoFailureException
Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.