Class AbstractInvokerMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.invoker.AbstractInvokerMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
IntegrationTestMojo, InvokerMojo

public abstract class AbstractInvokerMojo extends org.apache.maven.plugin.AbstractMojo
Provides common code for mojos invoking sub builds.
Since:
15-Aug-2009 09:09:29
  • Field Details

    • ONE_SECOND

      private static final float ONE_SECOND
      See Also:
    • RESULT_COLUMN

      private static final int RESULT_COLUMN
      The zero-based column index where to print the invoker result.
      See Also:
    • skipInvocation

      @Parameter(property="invoker.skip", defaultValue="false") private boolean skipInvocation
      Flag used to suppress certain invocations. This is useful in tailoring the build using profiles.
      Since:
      1.1
    • suppressSummaries

      @Parameter(defaultValue="false") protected boolean suppressSummaries
      Flag used to suppress the summary output notifying of successes and failures. If set to true, the only indication of the build's success or failure will be the effect it has on the main build (if it fails, the main build should fail as well). If streamLogs is enabled, the sub-build summary will also provide an indication.
      Since:
      1.0
    • streamLogs

      @Parameter(property="invoker.streamLogs", defaultValue="false") private boolean streamLogs
      Flag used to determine whether the build logs should be output to the normal mojo log.
      Since:
      1.0
    • localRepositoryPath

      @Parameter(property="invoker.localRepositoryPath", defaultValue="${settings.localRepository}") private File localRepositoryPath
      The local repository for caching artifacts. It is strongly recommended to specify a path to an isolated repository like ${project.build.directory}/it-repo. Otherwise, your ordinary local repository will be used, potentially soiling it with broken artifacts.
      Since:
      1.0
    • projectsDirectory

      @Parameter(property="invoker.projectsDirectory", defaultValue="${basedir}/src/it/") private File projectsDirectory
      Directory to search for integration tests.
      Since:
      1.0
    • reportsDirectory

      @Parameter(property="invoker.reportsDirectory", defaultValue="${project.build.directory}/invoker-reports") private File reportsDirectory
      Base directory where all build reports are written to. Every execution of an integration test will produce an XML file which contains the information about success or failure of that particular build job. The format of the resulting XML file is documented in the given build-job reference.
      Since:
      1.4
    • disableReports

      @Parameter(property="invoker.disableReports", defaultValue="false") private boolean disableReports
      A flag to disable the generation of build reports.
      Since:
      1.4
    • cloneProjectsTo

      @Parameter(property="invoker.cloneProjectsTo") private File cloneProjectsTo
      Directory to which projects should be cloned prior to execution. If set to null, each integration test will be run in the directory in which the corresponding IT POM was found. In this case, you most likely want to configure your SCM to ignore target and build.log in the test's base directory. (Exception when project using invoker plugin is of maven-plugin packaging: In such case IT projects will be cloned to and executed in target/its by default.)
      Since:
      1.1
    • cloneAllFiles

      @Parameter(defaultValue="false") private boolean cloneAllFiles
      Some files are normally excluded when copying the IT projects from the directory specified by the parameter projectsDirectory to the directory given by cloneProjectsTo (e.g. .svn, CVS, *~, etc: see reference for full list). Setting this parameter to true will cause all files to be copied to the cloneProjectsTo directory.
      Since:
      1.2
    • cloneClean

      @Parameter(defaultValue="true") private boolean cloneClean
      Ensure the cloneProjectsTo directory is not polluted with files from earlier invoker runs.
      Since:
      1.6
    • pom

      @Parameter(property="invoker.pom") private File pom
      A single POM to build, skipping any scanning parameters and behavior.
      Since:
      1.0
    • pomIncludes

      @Parameter private List<String> pomIncludes
      Include patterns for searching the integration test directory for projects. This parameter is meant to be set from the POM. If this parameter is not set, the plugin will search for all pom.xml files one directory below projectsDirectory (i.e. */pom.xml).

      Starting with version 1.3, mere directories can also be matched by these patterns. For example, the include pattern * will run Maven builds on all immediate sub directories of projectsDirectory, regardless if they contain a pom.xml. This allows to perform builds that need/should not depend on the existence of a POM.
      Since:
      1.0
    • pomExcludes

      @Parameter private List<String> pomExcludes
      Exclude patterns for searching the integration test directory. This parameter is meant to be set from the POM. By default, no POM files are excluded. For the convenience of using an include pattern like *, the custom settings file specified by the parameter settingsFile will always be excluded automatically.
      Since:
      1.0
    • setupIncludes

      @Parameter private List<String> setupIncludes
      Include patterns for searching the projects directory for projects that need to be run before the other projects. This parameter allows to declare projects that perform setup tasks like installing utility artifacts into the local repository. Projects matched by these patterns are implicitly excluded from the scan for ordinary projects. Also, the exclusions defined by the parameter pomExcludes apply to the setup projects, too. Default value is: setup*/pom.xml.
      Since:
      1.3
    • goals

      @Parameter private List<String> goals
      The list of goals to execute on each project. Default value is: package.
      Since:
      1.0
    • selectorScript

      @Parameter(property="invoker.selectorScript", defaultValue="selector") private String selectorScript
      Relative path of a selector script to run prior in order to decide if the build should be executed. This script may be written with either BeanShell or Groovy. If the file extension is omitted (e.g. selector), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true, the corresponding build is flagged as skipped. In this case, none of the pre-build hook script, Maven nor the post-build hook script will be invoked. If this script throws an exception, the corresponding build is flagged as in error, and none of the pre-build hook script, Maven not the post-build hook script will be invoked.
      Since:
      1.5
    • preBuildHookScript

      @Parameter(property="invoker.preBuildHookScript", defaultValue="prebuild") private String preBuildHookScript
      Relative path of a pre-build hook script to run prior to executing the build. This script may be written with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. prebuild), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true or throws an exception, the corresponding build is flagged as a failure. In this case, neither Maven nor the post-build hook script will be invoked.
      Since:
      1.0
    • postBuildHookScript

      @Parameter(property="invoker.postBuildHookScript", defaultValue="postbuild") private String postBuildHookScript
      Relative path of a cleanup/verification hook script to run after executing the build. This script may be written with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. verify), the plugin searches for the file by trying out the well-known extensions .bsh and .groovy. If this script exists for a particular project but returns any non-null value different from true or throws an exception, the corresponding build is flagged as a failure.
      Since:
      1.0
    • testPropertiesFile

      @Parameter(property="invoker.testPropertiesFile", defaultValue="test.properties") private String testPropertiesFile
      Location of a properties file that defines CLI properties for the test.
      Since:
      1.0
    • properties

      @Parameter private Map<String,String> properties
      Common set of properties to pass in on each project's command line, via -D parameters.
      Since:
      1.1
    • showErrors

      @Parameter(property="invoker.showErrors", defaultValue="false") private boolean showErrors
      Whether to show errors in the build output.
      Since:
      1.0
    • debug

      @Parameter(property="invoker.debug", defaultValue="false") private boolean debug
      Whether to show debug statements in the build output.
      Since:
      1.0
    • quiet

      @Parameter(property="invoker.quiet", defaultValue="false") private boolean quiet
      Whether to execute Maven in quiet mode.
      Since:
      3.3.0
    • noLog

      @Parameter(property="invoker.noLog", defaultValue="false") private boolean noLog
      Suppress logging to the build.log file.
      Since:
      1.0
    • logDirectory

      @Parameter private File logDirectory
      By default a build.log is created in the root of the project. By setting this folder files are written to a different folder, respecting the structure of the projectsDirectory.
      Since:
      3.2.0
    • profiles

      @Parameter private List<String> profiles
      List of profile identifiers to explicitly trigger in the build.
      Since:
      1.1
    • filterProperties

      @Parameter private Map<String,String> filterProperties
      A list of additional properties which will be used to filter tokens in POMs and goal files.
      Since:
      1.3
    • invokerTest

      @Parameter(property="invoker.test") private String invokerTest
      A comma separated list of projectname patterns to run. Specify this parameter to run individual tests by file name, overriding the setupIncludes, pomIncludes and pomExcludes parameters. Each pattern you specify here will be used to create an include/exclude pattern formatted like ${projectsDirectory}/pattern. To exclude a test, prefix the pattern with a '!'. So you can just type -Dinvoker.test=SimpleTest,Comp*Test,!Compare* to run builds in ${projectsDirectory}/SimpleTest and ${projectsDirectory}/ComplexTest, but not ${projectsDirectory}/CompareTest
      Since:
      1.1 (exclusion since 1.8)
    • settingsFile

      @Parameter(property="invoker.settingsFile") private File settingsFile
      Path to an alternate settings.xml to use for Maven invocation with all ITs. Note that the <localRepository> element of this settings file is always ignored, i.e. the path given by the parameter localRepositoryPath is dominant.
      Since:
      1.2
    • mavenOpts

      @Parameter(property="invoker.mavenOpts") private String mavenOpts
      The MAVEN_OPTS environment variable to use when invoking Maven. This value can be overridden for individual integration tests by using invokerPropertiesFile.
      Since the version 3.7.0 using an alternate syntax for mavenOpts, @{...} allows late replacement of properties when the plugin is executed, so properties that have been modified by other plugins will be picked up correctly.
      Since:
      1.2
    • mavenHome

      @Parameter(property="invoker.mavenHome") private File mavenHome
      The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven installation.
      Since:
      1.3
    • mavenExecutable

      @Parameter(property="invoker.mavenExecutable") private String mavenExecutable
      mavenExecutable can either be a file relative to ${maven.home}/bin/, test project workspace or an absolute file.
      Since:
      1.8
    • javaHome

      @Parameter(property="invoker.javaHome") private File javaHome
      The JAVA_HOME environment variable to use for forked Maven invocations. Defaults to the current Java home directory.
      Since:
      1.3
    • encoding

      @Parameter(property="encoding", defaultValue="${project.build.sourceEncoding}") private String encoding
      The file encoding for the pre-/post-build scripts and the list files for goals and profiles.
      Since:
      1.2
    • addTestClassPath

      @Parameter(property="invoker.addTestClassPath", defaultValue="false") private boolean addTestClassPath
      A flag whether the test class path of the project under test should be included in the class path of the pre-/post-build scripts. If set to false, the class path of script interpreter consists only of the runtime dependencies of the Maven Invoker Plugin. If set the true, the project's test class path will be prepended to the interpreter class path. Among others, this feature allows the scripts to access utility classes from the test sources of your project.
      Since:
      1.2
    • invokerPropertiesFile

      @Parameter(property="invoker.invokerPropertiesFile", defaultValue="invoker.properties") private String invokerPropertiesFile
      The name of an optional project-specific file that contains properties used to specify settings for an individual Maven invocation. Any property present in the file will override the corresponding setting from the plugin configuration. The values of the properties are filtered and may use expressions like ${project.version} to reference project properties or values from the parameter filterProperties.

      As of 3.2.0 it is possible to put this folder in any of the ancestor folders, where properties will be inherited. This way you can provide a single properties file for a group of projects

      The snippet below describes the supported properties:
       # A comma or space separated list of goals/phases to execute, may
       # specify an empty list to execute the default goal of the IT project.
       # Environment variables used by maven plugins can be added here
       invoker.goals = clean install -Dplugin.variable=value
      
       # Or you can give things like this if you need.
       invoker.goals = -T2 clean verify
      
       # Optionally, a list of goals to run during further invocations of Maven
       invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:run
      
       # A comma or space separated list of profiles to activate
       # can be indexed
       invoker.profiles = its,jdk15
      
       # The path to an alternative POM or base directory to invoke Maven on, defaults to the
       # project that was originally specified in the plugin configuration
       # Since plugin version 1.4
       # can be indexed
       invoker.project = sub-module
      
       # The maven executable can either be a file relative to ${maven.home}/bin/, test project workspace
       # or an absolute file.
       # Since plugin version 3.3.0
       # can be indexed
       invoker.mavenExecutable = mvnw
      
       # The value for the environment variable MAVEN_OPTS
       # can be indexed
       invoker.mavenOpts = -Dfile.encoding=UTF-16 -Xms32m -Xmx256m
      
       # Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
       # can be indexed
       invoker.failureBehavior = fail-never
      
       # The expected result of the build, possible values are "success" (default) and "failure"
       # can be indexed
       invoker.buildResult = failure
      
       # A boolean value controlling the aggregator mode of Maven, defaults to "false"
      
       # can be indexed
       invoker.nonRecursive = true
      
       # A boolean value controlling the network behavior of Maven, defaults to "false"
       # Since plugin version 1.4
       # can be indexed
       invoker.offline = true
      
       # The path to the properties file from which to load user properties, defaults to the
       # filename given by the plugin parameter testPropertiesFile
       # Since plugin version 1.4
       # can be indexed
       invoker.userPropertiesFile = test.properties
      
       # An optional human friendly name and description for this build job.
       # Both name and description have to be set to be included in the build reports.
       # Since plugin version 1.4
       invoker.name = Test Build 01
       invoker.description = Checks the support for build reports.
      
       # A comma separated list of JRE versions on which this build job should be run.
       # Since plugin version 1.4
       invoker.java.version = 1.4+, !1.4.1, 1.7-
      
       # A comma separated list of OS families on which this build job should be run.
       # Since plugin version 1.4
       invoker.os.family = !windows, unix, mac
      
       # A comma separated list of Maven versions on which this build should be run.
       # Since plugin version 1.5
       invoker.maven.version = 2.0.10+, !2.1.0, !2.2.0
      
       # A mapping for toolchain to ensure it exists
       # Since plugin version 3.2.0
       invoker.toolchain.<type>.<provides> = value
       invoker.toolchain.jdk.version = 11
      
       # For java.version, maven.version, os.family and toolchain it is possible to define multiple selectors.
       # If one of the indexed selectors matches, the test is executed.
       # With the invoker.x.y equivalents you can specify global matchers.
       selector.1.java.version = 1.8+
       selector.1.maven.version = 3.2.5+
       selector.1.os.family = !windows
       selector.2.maven.version = 3.0+
       selector.3.java.version = 9+
      
       # A boolean value controlling the debug logging level of Maven, , defaults to "false"
       # Since plugin version 1.8
       # can be indexed
       invoker.debug = true
      
       # Whether to execute Maven in quiet mode
       # Since plugin version 3.3.0
       # can be indexed
       invoker.quiet = true
      
       The execution timeout in seconds.
       # Since plugin version 3.0.2
       # can be indexed
       invoker.timeoutInSeconds = 5
      
       # Path to an alternate settings.xml to use for Maven invocation with this IT.
       # Since plugin version 3.0.1
       # can be indexed
       invoker.settingsFile = ../
      
       # An integer value to control run order of projects. sorted in the descending order of the ordinal.
       # In other words, the BuildJobs with the highest numbers will be executed first
       # Default value is 0 (zero)
       # Since plugin version 3.2.1
       invoker.ordinal = 3
      
       # The additional value for the environment variable.
       # Since plugin version 3.2.2
       invoker.environmentVariables.<variableName> = variableValue
       invoker.environmentVariables.MY_ENV_NAME = myEnvValue
      
       # A boolean value indicating a check for missing releases and updated snapshots on remote repositories to be done
       # Passed to the invoker. Same as passing -U, --update-snapshots flag on the command line
       # Since plugin version 3.4.0
       invoker.updateSnapshots = true
      
       
      Since:
      1.2
    • showVersion

      @Parameter(property="invoker.showVersion", defaultValue="false") private boolean showVersion
      flag to enable show mvn version used for running its (cli option : -V,--show-version )
      Since:
      1.4
    • parallelThreads

      @Parameter(property="invoker.parallelThreads", defaultValue="1") private String parallelThreads

      Number of threads for running tests in parallel. This will be the number of maven forked process in parallel. When terminated with "C", the number part is multiplied by the number of processors (cores) available to the Java virtual machine. Floating point value are only accepted together with "C".

      Example values: "1.5C", "4"

      Since:
      1.6
    • mergeUserSettings

      @Parameter(property="invoker.mergeUserSettings", defaultValue="false") private boolean mergeUserSettings
      If enable and if you have a settings file configured for the execution, it will be merged with your user settings.
      Since:
      1.6
    • environmentVariables

      @Parameter private Map<String,String> environmentVariables
      Additional environment variables to set on the command line.
      Since:
      1.8
    • scriptVariables

      @Parameter private Map<String,String> scriptVariables
      Additional variables for use in the hook scripts.
      Since:
      1.9
    • timeoutInSeconds

      @Parameter(defaultValue="0", property="invoker.timeoutInSeconds") private int timeoutInSeconds
      Since:
      3.0.2
    • writeJunitReport

      @Parameter(defaultValue="false", property="invoker.writeJunitReport") private boolean writeJunitReport
      Write test result in junit format.
      Since:
      3.1.2
    • junitPackageName

      @Parameter(defaultValue="maven.invoker.it", property="invoker.junitPackageName") private String junitPackageName
      The package name use in junit report
      Since:
      3.1.2
    • updateOnly

      @Parameter(defaultValue="false", property="invoker.updateOnly") private boolean updateOnly
      Only invoke maven projects if their sources have been modified since they were last built. Only works in conjunction with cloneProjectsTo.
      Since:
      3.2.2
    • updateSnapshots

      @Parameter(defaultValue="false", property="invoker.updateSnapshots") private boolean updateSnapshots
      Force a check for missing releases and updated snapshots on remote repositories. This is passed to the invoked maven projects (it is the same as if you were to use the -U, --update-snapshots flag on the command line).
      Since:
      3.4.0
    • collectedProjects

      @Parameter private List<String> collectedProjects
      Projects that are cloned undergo some filtering. In order to grab all projects and make sure they are all filtered, projects are read and parsed. In some cases, this may not be a desired behavior (especially when some pom.xml cannot be parsed by Maven directly). In such cases, the exact list of projects can be set using this field, avoiding the parsing of all pom.xml files found.
      Since:
      3.9.0
    • scriptRunner

      private org.apache.maven.shared.scriptinterpreter.ScriptRunner scriptRunner
      The scripter runner that is responsible to execute hook scripts.
    • filteredPomPrefix

      private String filteredPomPrefix
      A string used to prefix the file name of the filtered POMs in case the POMs couldn't be filtered in-place (i.e. the projects were not cloned to a temporary directory), can be null. This will be set to null if the POMs have already been filtered during cloning.
    • actualMavenVersion

      private String actualMavenVersion
      The version of Maven which is used to run the builds
    • pluginArtifacts

      @Parameter(property="plugin.artifacts", required=true, readonly=true) private List<org.apache.maven.artifact.Artifact> pluginArtifacts
    • testClassPath

      @Parameter(defaultValue="${project.testClasspathElements}", readonly=true) private List<String> testClassPath
    • mojoExecution

      @Parameter(defaultValue="${mojoExecution}", readonly=true, required=true) private org.apache.maven.plugin.MojoExecution mojoExecution
    • project

      @Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project
    • session

      @Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession session
    • settings

      @Parameter(defaultValue="${settings}", readonly=true, required=true) private org.apache.maven.settings.Settings settings
    • invoker

      @Component private org.apache.maven.shared.invoker.Invoker invoker
    • settingsBuilder

      @Component private org.apache.maven.settings.building.SettingsBuilder settingsBuilder
    • toolchainManagerPrivate

      @Component private org.apache.maven.toolchain.ToolchainManagerPrivate toolchainManagerPrivate
    • interpolatorUtils

      @Component private InterpolatorUtils interpolatorUtils
  • Constructor Details

    • AbstractInvokerMojo

      public AbstractInvokerMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Invokes Maven on the configured test projects.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the goal encountered severe errors.
      org.apache.maven.plugin.MojoFailureException - If any of the Maven builds failed.
    • addMissingDotMvnDirectory

      private void addMissingDotMvnDirectory(File projectsDir, List<BuildJob> buildJobs) throws org.apache.maven.plugin.MojoExecutionException
      We need add missing .mnvn directories for executing projects
      Parameters:
      projectsDir - base of projects
      buildJobs - list of discovered jobs
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • setupActualMavenVersion

      private void setupActualMavenVersion() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • lastModifiedRecursive

      private long lastModifiedRecursive(File file)
      Find the latest lastModified recursively within a directory structure.
      Parameters:
      file - the root file to check.
      Returns:
      the latest lastModified time found.
    • setupReportsFolder

      private void setupReportsFolder() throws org.apache.maven.plugin.MojoExecutionException
      This will create the necessary folders for the reports.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - in case of failure during creation of the reports folder.
    • getSetupJobs

      private List<BuildJob> getSetupJobs(List<BuildJob> buildJobs)
    • getNonSetupJobs

      private List<BuildJob> getNonSetupJobs(List<BuildJob> buildJobs)
    • handleScriptRunnerWithScriptClassPath

      private void handleScriptRunnerWithScriptClassPath()
    • writeSummaryFile

      private void writeSummaryFile(List<BuildJob> buildJobs) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • doFailIfNoProjects

      protected void doFailIfNoProjects() throws org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoFailureException
    • processResults

      abstract void processResults(InvokerSession invokerSession) throws org.apache.maven.plugin.MojoFailureException
      Processes the results of invoking the build jobs.
      Parameters:
      invokerSession - The session with the build jobs, must not be null.
      Throws:
      org.apache.maven.plugin.MojoFailureException - If the mojo had failed as a result of invoking the build jobs.
      Since:
      1.4
    • collectProjects

      private void collectProjects(File projectsDir, String projectPath, Collection<String> projectPaths, boolean included) throws org.apache.maven.plugin.MojoExecutionException
      Collects all projects locally reachable from the specified project. The method will as such try to read the POM and recursively follow its parent/module elements.
      Parameters:
      projectsDir - The base directory of all projects, must not be null.
      projectPath - The relative path of the current project, can denote either the POM or its base directory, must not be null.
      projectPaths - The set of already collected projects to add new projects to, must not be null. This set will hold the relative paths to either a POM file or a project base directory.
      included - A flag indicating whether the specified project has been explicitly included via the parameter pomIncludes. Such projects will always be added to the result set even if there is no corresponding POM.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the project tree could not be traversed.
    • isNotEmpty

      private boolean isNotEmpty(String s)
    • cloneProjects

      private void cloneProjects(Collection<String> projectPaths) throws org.apache.maven.plugin.MojoExecutionException
      Copies the specified projects to the directory given by cloneProjectsTo. A project may either be denoted by a path to a POM file or merely by a path to a base directory. During cloning, the POM files will be filtered.
      Parameters:
      projectPaths - The paths to the projects to clone, relative to the projects directory, must not be null nor contain null elements.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the projects could not be copied/filtered.
    • getParentPath

      private String getParentPath(String path)
      Gets the parent path of the specified relative path.
      Parameters:
      path - The relative path whose parent should be retrieved, must not be null.
      Returns:
      The parent path or "." if the specified path has no parent, never null.
    • copyDirectoryStructure

      private void copyDirectoryStructure(File sourceDir, File destDir) throws IOException
      Copied a directory structure with default exclusions (.svn, CVS, etc)
      Parameters:
      sourceDir - The source directory to copy, must not be null.
      destDir - The target directory to copy to, must not be null.
      Throws:
      IOException - If the directory structure could not be copied.
    • alreadyCloned

      static boolean alreadyCloned(String subpath, List<String> clonedSubpaths)
      Determines whether the specified sub path has already been cloned, i.e. whether one of its ancestor directories was already cloned.
      Parameters:
      subpath - The sub path to check, must not be null.
      clonedSubpaths - The list of already cloned paths, must not be null nor contain null elements.
      Returns:
      true if the specified path has already been cloned, false otherwise.
    • runBuilds

      private void runBuilds(File projectsDir, List<BuildJob> buildJobs, int runWithParallelThreads) throws org.apache.maven.plugin.MojoExecutionException
      Runs the specified build jobs.
      Parameters:
      projectsDir - The base directory of all projects, must not be null.
      buildJobs - The build jobs to run must not be null nor contain null elements.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If any build could not be launched.
    • getAncestorFolder

      private Path getAncestorFolder(Path p)
    • interpolateSettings

      private File interpolateSettings(File settingsFile) throws org.apache.maven.plugin.MojoExecutionException
      Interpolate settings.xml file.
      Parameters:
      settingsFile - a settings file
      Returns:
      The interpolated settings.xml file.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - in case of a problem.
    • mergeSettings

      private File mergeSettings(File interpolatedSettingsFile) throws org.apache.maven.plugin.MojoExecutionException
      Merge the settings file
      Parameters:
      interpolatedSettingsFile - The interpolated settings file.
      Returns:
      The merged settings file.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Fail the build in case the merged settings file can't be created.
    • writeMergedSettingsFile

      private File writeMergedSettingsFile(org.apache.maven.settings.Settings mergedSettings) throws IOException
      Throws:
      IOException
    • cloneSettings

      private org.apache.maven.settings.Settings cloneSettings()
    • resetSourceLevelSet

      private void resetSourceLevelSet(org.apache.maven.settings.TrackableBase trackable)
    • resolveExternalJreVersion

      private CharSequence resolveExternalJreVersion()
    • interpolatePomFile

      private File interpolatePomFile(File pomFile, File basedir) throws org.apache.maven.plugin.MojoExecutionException
      Interpolate the pom file.
      Parameters:
      pomFile - The pom file.
      basedir - The base directory.
      Returns:
      interpolated pom file location in case we have interpolated the pom file otherwise the original pom file will be returned.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • runBuild

      private void runBuild(File projectsDir, BuildJob buildJob, File settingsFile, File actualJavaHome, CharSequence actualJreVersion, Properties globalInvokerProperties) throws org.apache.maven.plugin.MojoExecutionException
      Runs the specified project.
      Parameters:
      projectsDir - The base directory of all projects, must not be null.
      buildJob - The build job to run, must not be null.
      settingsFile - The (already interpolated) user settings file for the build, may be null to use the current user settings.
      globalInvokerProperties -
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the project could not be launched.
    • pad

      private org.apache.maven.shared.utils.logging.MessageBuilder pad(BuildJob buildJob)
    • deleteInterpolatedPomFile

      private void deleteInterpolatedPomFile(File interpolatedPomFile)
      Delete the interpolated pom file if it has been created before.
      Parameters:
      interpolatedPomFile - The interpolated pom file.
    • getSelection

      private int getSelection(InvokerProperties invokerProperties, CharSequence actualJreVersion)
      Determines whether selector conditions of the specified invoker properties match the current environment.
      Parameters:
      invokerProperties - The invoker properties to check, must not be null.
      Returns:
      0 if the job corresponding to the properties should be run, otherwise a bitwise value representing the reason why it should be skipped.
    • getToolchainPrivateManager

      private AbstractInvokerMojo.ToolchainPrivateManager getToolchainPrivateManager()
    • writeBuildReport

      private void writeBuildReport(BuildJob buildJob) throws org.apache.maven.plugin.MojoExecutionException
      Writes the XML report for the specified build job unless report generation has been disabled.
      Parameters:
      buildJob - The build job whose report should be written, must not be null.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the report could not be written.
    • writeJunitReport

      private void writeJunitReport(BuildJob buildJob, String safeFileName) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • formatElapsedTime

      private String formatElapsedTime(float time)
      Formats the specified elapsed time.
      Parameters:
      time - The eapsed time of the build.
      Returns:
      The formatted time, never null.
    • runBuild

      private boolean runBuild(File basedir, File pomFile, File settingsFile, File actualJavaHome, InvokerProperties invokerProperties, FileLogger logger) throws org.apache.maven.plugin.MojoExecutionException, RunFailureException
      Runs the specified project.
      Parameters:
      basedir - The base directory of the project, must not be null.
      pomFile - The (already interpolated) POM file, may be null for a POM-less Maven invocation.
      settingsFile - The (already interpolated) user settings file for the build, may be null. Will be merged with the settings file of the invoking Maven process.
      invokerProperties - The properties to use.
      logger - file logger to write execution build.log
      Returns:
      true if the project was launched or false if the selector script indicated that the project should be skipped.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the project could not be launched.
      RunFailureException - If either a hook script or the build itself failed.
    • getParallelThreadsCount

      int getParallelThreadsCount()
    • runSelectorHook

      private boolean runSelectorHook(File basedir, Map<String,Object> context, FileLogger logger) throws org.apache.maven.plugin.MojoExecutionException, RunFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      RunFailureException
    • runPreBuildHook

      private void runPreBuildHook(File basedir, Map<String,Object> context, FileLogger logger) throws org.apache.maven.plugin.MojoExecutionException, RunFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      RunFailureException
    • runPostBuildHook

      private void runPostBuildHook(File basedir, Map<String,Object> context, FileLogger logger) throws org.apache.maven.plugin.MojoExecutionException, RunFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      RunFailureException
    • setupLoggerForBuildJob

      private void setupLoggerForBuildJob(FileLogger logger, org.apache.maven.shared.invoker.InvocationRequest request)
    • setupBuildLogFile

      private FileLogger setupBuildLogFile(File basedir) throws org.apache.maven.plugin.MojoExecutionException
      Initializes the build logger for the specified project. This will write the logging information into build.log.
      Parameters:
      basedir - The base directory of the project, must not be null.
      Returns:
      The build logger or null if logging has been disabled.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the log file could not be created.
    • getUserProperties

      private Properties getUserProperties(File basedir, String filename) throws org.apache.maven.plugin.MojoExecutionException
      Gets the system properties to use for the specified project.
      Parameters:
      basedir - The base directory of the project, must not be null.
      filename - The filename to the properties file to load, may be null to use the default path given by testPropertiesFile.
      Returns:
      The system properties to use, may be empty but never null.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the properties file exists but could not be read.
    • verify

      private void verify(org.apache.maven.shared.invoker.InvocationResult result, int invocationIndex, InvokerProperties invokerProperties, FileLogger logger) throws RunFailureException
      Verifies the invocation result.
      Parameters:
      result - The invocation result to check, must not be null.
      invocationIndex - The index of the invocation for which to check the exit code, must not be negative.
      invokerProperties - The invoker properties used to check the exit code, must not be null.
      logger - The build logger, may be null if logging is disabled.
      Throws:
      RunFailureException
    • calculateIncludes

      private List<String> calculateIncludes()
    • calculateExcludes

      private List<String> calculateExcludes() throws IOException
      Throws:
      IOException
    • getBuildJobs

      List<BuildJob> getBuildJobs() throws IOException, org.apache.maven.plugin.MojoExecutionException
      Gets the build jobs that should be processed. Note that the order of the returned build jobs is significant.
      Returns:
      The build jobs to process, may be empty but never null.
      Throws:
      IOException - If the projects directory could not be scanned.
      org.apache.maven.plugin.MojoExecutionException
    • scanProjectsDirectory

      private List<BuildJob> scanProjectsDirectory(List<String> includes, List<String> excludes) throws IOException
      Scans the projects directory for projects to build. Both (POM) files and mere directories will be matched by the scanner patterns. If the patterns match a directory which contains a file named "pom.xml", the results will include the path to this file rather than the directory path in order to avoid duplicate invocations of the same project.
      Parameters:
      includes - The include patterns for the scanner, may be null.
      excludes - The exclude patterns for the scanner, may be null to exclude nothing.
      Returns:
      The build jobs matching the patterns, never null.
      Throws:
      IOException - If the project directory could not be scanned.
    • relativizeProjectPaths

      private void relativizeProjectPaths(List<BuildJob> buildJobs) throws IOException
      Relativizes the project paths of the specified build jobs against the directory specified by projectsDirectory (if possible). If a project path does not denote a sub path of the projects directory, it is returned as is.
      Parameters:
      buildJobs - The build jobs whose project paths should be relativized, must not be null nor contain null elements.
      Throws:
      IOException - If any path could not be relativized.
    • relativizePath

      private String relativizePath(File path, String basedir) throws IOException
      Relativizes the specified path against the given base directory. Besides relativization, the returned path will also be normalized, e.g. directory references like ".." will be removed.
      Parameters:
      path - The path to relativize, must not be null.
      basedir - The (canonical path of the) base directory to relativize against, must not be null.
      Returns:
      The relative path in normal form or null if the input path does not denote a sub path of the base directory.
      Throws:
      IOException - If the path could not be relativized.
    • getInterpolationValueSource

      private Map<String,Object> getInterpolationValueSource(boolean escapeXml)
      Returns the map-based value source used to interpolate POMs and other stuff.
      Parameters:
      escapeXml - true, to escape any XML special characters in the property values; false, to not escape any property values.
      Returns:
      The map-based value source for interpolation, never null.
    • toUrl

      private static String toUrl(String filename)
      Converts the specified filesystem path to a URL. The resulting URL has no trailing slash regardless whether the path denotes a file or a directory.
      Parameters:
      filename - The filesystem path to convert, must not be null.
      Returns:
      The file: URL for the specified path, never null.
    • buildInterpolatedFile

      void buildInterpolatedFile(File originalFile, File interpolatedFile) throws org.apache.maven.plugin.MojoExecutionException
      Interpolates the specified POM/settings file to a temporary file. The destination file may be same as the input file, i.e. interpolation can be performed in-place.

      Note:This methods expects the file to be a XML file and applies special XML escaping during interpolation.

      Parameters:
      originalFile - The XML file to interpolate, must not be null.
      interpolatedFile - The target file to write the interpolated contents of the original file to, must not be null.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the target file could not be created.
    • getInvokerProperties

      private InvokerProperties getInvokerProperties(File projectDirectory, Properties globalInvokerProperties) throws org.apache.maven.plugin.MojoExecutionException
      Gets the (interpolated) invoker properties for an integration test.
      Parameters:
      projectDirectory - The base directory of the IT project, must not be null.
      Returns:
      The invoker properties, may be empty but never null.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If an I/O error occurred during reading the properties.