Class IntegrationTestMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="integration-test",
          requiresProject=true)
    public class IntegrationTestMojo
    extends org.apache.maven.plugin.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:

    • a 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),
    • an archetype.properties file, containing properties for project generation,
    • an optional 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.

    Author:
    rafale
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.maven.artifact.repository.ArtifactRepository localRepository  
      protected java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories  
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void buildInterpolatedFile​(java.io.File originalFile, java.io.File interpolatedFile)  
      void execute()  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • remoteRepositories

        @Parameter(defaultValue="${project.remoteArtifactRepositories}",
                   readonly=true,
                   required=true)
        protected java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories
      • localRepository

        @Parameter(defaultValue="${localRepository}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
    • Constructor Detail

      • IntegrationTestMojo

        public IntegrationTestMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • buildInterpolatedFile

        protected void buildInterpolatedFile​(java.io.File originalFile,
                                             java.io.File interpolatedFile)
                                      throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException