@Mojo(name="integration-test", requiresProject=true) public class IntegrationTestMojo extends AbstractMojo
Execute the archetype integration tests, consisting in generating projects from the current archetype and optionally comparing generated projects with reference copy.
Each IT consists of a sub-directory in src/test/resources/projects
containing:
goal.txt
file, containing a list of goals to run against the generated project (can be empty,
content ignored before maven-archetype-plugin 2.1),archetype.properties
file, containing properties for project generation,reference/
directory containing a reference copy of the expected project created from
the IT.To let the IT create a Maven module below some other Maven project (being generated from another archetype)
one can additionally specify an optional archetype.pom.properties
file in the parent directory,
specifying the archetype's groupId
, artifactId
and version
along with its
archetype.properties
file, containing properties for project generation. Both files are leveraged
to create the parent project for this IT. Parent projects can be nested.
An example structure for such an integration test looks like this
File/Directory | Description |
---|---|
src/test/resources/projects/it1 |
Directory for integration test 1 |
src/test/resources/projects/it1/archetype.pom.properties |
GAV for the archetype from which to generate the parent |
src/test/resources/projects/it1/archetype.properties |
All required properties for the archetype being specified by archetype.pom.properties on this level |
src/test/resources/projects/it1/child |
Directory for maven module within integration test 1 (this folder's name is not relevant) |
src/test/resources/projects/it1/child/goal.txt |
The file containing the list of goals to be executed against the generated project |
src/test/resources/projects/it1/child/archetype.properties |
All required properties for this project's archetype |
Notice that it is expected to be run as part as of a build after the package
phase and not directly as a
goal from CLI.
Modifier and Type | Field and Description |
---|---|
protected ArtifactRepository |
localRepository |
protected List<ArtifactRepository> |
remoteRepositories |
Constructor and Description |
---|
IntegrationTestMojo() |
Modifier and Type | Method and Description |
---|---|
protected void |
buildInterpolatedFile(File originalFile,
File interpolatedFile) |
void |
execute() |
getLog, getPluginContext, setLog, setPluginContext
@Parameter(defaultValue="${project.remoteArtifactRepositories}", readonly=true, required=true) protected List<ArtifactRepository> remoteRepositories
@Parameter(defaultValue="${localRepository}", readonly=true, required=true) protected ArtifactRepository localRepository
public void execute() throws MojoExecutionException, MojoFailureException
protected void buildInterpolatedFile(File originalFile, File interpolatedFile) throws MojoExecutionException
MojoExecutionException
Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.