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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringThe version of Maven which is used to run the buildsprivate booleanA flag whether the test class path of the project under test should be included in the class path of the pre-/post-build scripts.private booleanSome 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.private booleanEnsure thecloneProjectsTodirectory is not polluted with files from earlier invoker runs.private FileDirectory to which projects should be cloned prior to execution.Projects that are cloned undergo some filtering.private booleanWhether to show debug statements in the build output.private booleanA flag to disable the generation of build reports.private StringThe file encoding for the pre-/post-build scripts and the list files for goals and profiles.Additional environment variables to set on the command line.private StringA string used to prefix the file name of the filtered POMs in case the POMs couldn't be filtered in-place (i.e.A list of additional properties which will be used to filter tokens in POMs and goal files.The list of goals to execute on each project.private final InterpolatorUtilsprivate final org.apache.maven.shared.invoker.Invokerprivate StringThe name of an optional project-specific file that contains properties used to specify settings for an individual Maven invocation.private StringA comma separated list of projectname patterns to run.private FileTheJAVA_HOMEenvironment variable to use for forked Maven invocations.private StringThe package name use in junit reportprivate FileThe local repository for caching artifacts.private FileBy default abuild.logis created in the root of the project.private StringmavenExecutable can either be a file relative to${maven.home}/bin/, test project workspace or an absolute file.private FileThe home directory of the Maven installation to use for the forked builds.private StringTheMAVEN_OPTSenvironment variable to use when invoking Maven.private booleanIf enable and if you have a settings file configured for the execution, it will be merged with your user settings.private org.apache.maven.plugin.MojoExecutionprivate booleanSuppress logging to thebuild.logfile.private static final floatprivate StringNumber of threads for running tests in parallel.private List<org.apache.maven.artifact.Artifact> private FileA single POM to build, skipping any scanning parameters and behavior.Exclude patterns for searching the integration test directory.Include patterns for searching the integration test directory for projects.private StringRelative path of a cleanup/verification hook script to run after executing the build.private StringRelative path of a pre-build hook script to run prior to executing the build.List of profile identifiers to explicitly trigger in the build.private org.apache.maven.project.MavenProjectprivate FileDirectory to search for integration tests.Common set of properties to pass in on each project's command line, via -D parameters.private booleanWhether to execute Maven in quiet mode.private FileBase directory where all build reports are written to.private static final intThe zero-based column index where to print the invoker result.private org.apache.maven.shared.scriptinterpreter.ScriptRunnerThe scripter runner that is responsible to execute hook scripts.Additional variables for use in the hook scripts.private StringRelative path of a selector script to run prior in order to decide if the build should be executed.private org.apache.maven.execution.MavenSessionprivate org.apache.maven.settings.Settingsprivate final org.apache.maven.settings.building.SettingsBuilderprivate FilePath to an alternatesettings.xmlto use for Maven invocation with all ITs.Include patterns for searching the projects directory for projects that need to be run before the other projects.private booleanWhether to show errors in the build output.private booleanflag to enable show mvn version used for running its (cli option : -V,--show-version )private booleanFlag used to suppress certain invocations.private booleanFlag used to determine whether the build logs should be output to the normal mojo log.protected booleanFlag used to suppress the summary output notifying of successes and failures.private StringLocation of a properties file that defines CLI properties for the test.private intprivate final org.apache.maven.toolchain.ToolchainManagerPrivateprivate booleanOnly invoke maven projects if their sources have been modified since they were last built.private booleanForce a check for missing releases and updated snapshots on remote repositories.private booleanWrite test result in junit format.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractInvokerMojo(org.apache.maven.shared.invoker.Invoker invoker, org.apache.maven.settings.building.SettingsBuilder settingsBuilder, org.apache.maven.toolchain.ToolchainManagerPrivate toolchainManagerPrivate, InterpolatorUtils interpolatorUtils) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddMissingDotMvnDirectory(File projectsDir, List<BuildJob> buildJobs) We need add missing.mnvndirectories for executing projects(package private) static booleanalreadyCloned(String subpath, List<String> clonedSubpaths) Determines whether the specified sub path has already been cloned, i.e.(package private) voidbuildInterpolatedFile(File originalFile, File interpolatedFile) Interpolates the specified POM/settings file to a temporary file.private voidcloneProjects(Collection<String> projectPaths) Copies the specified projects to the directory given bycloneProjectsTo.private org.apache.maven.settings.Settingsprivate voidcollectProjects(File projectsDir, String projectPath, Collection<String> projectPaths, boolean included) Collects all projects locally reachable from the specified project.private voidcopyDirectoryStructure(File sourceDir, File destDir) Copied a directory structure with default exclusions (.svn, CVS, etc)private voiddeleteInterpolatedPomFile(File interpolatedPomFile) Delete the interpolated pom file if it has been created before.protected voidvoidexecute()Invokes Maven on the configured test projects.private StringformatElapsedTime(float time) Formats the specified elapsed time.private PathGets the build jobs that should be processed.getInterpolationValueSource(boolean escapeXml) Returns the map-based value source used to interpolate POMs and other stuff.private InvokerPropertiesgetInvokerProperties(File projectDirectory, Properties globalInvokerProperties) Gets the (interpolated) invoker properties for an integration test.getNonSetupJobs(List<BuildJob> buildJobs) (package private) intprivate StringgetParentPath(String path) Gets the parent path of the specified relative path.private intgetSelection(InvokerProperties invokerProperties, CharSequence actualJreVersion) Determines whether selector conditions of the specified invoker properties match the current environment.getSetupJobs(List<BuildJob> buildJobs) private PropertiesgetUserProperties(File basedir, String filename) Gets the system properties to use for the specified project.private voidprivate FileinterpolatePomFile(File pomFile, File basedir) Interpolate the pom file.private FileinterpolateSettings(File settingsFile) Interpolate settings.xml file.private booleanisNotEmpty(String s) private longlastModifiedRecursive(File file) Find the latest lastModified recursively within a directory structure.private FilemergeSettings(File interpolatedSettingsFile) Merge the settings fileprivate org.apache.maven.shared.utils.logging.MessageBuilder(package private) abstract voidprocessResults(InvokerSession invokerSession) Processes the results of invoking the build jobs.private StringrelativizePath(File path, String basedir) Relativizes the specified path against the given base directory.private voidrelativizeProjectPaths(List<BuildJob> buildJobs) Relativizes the project paths of the specified build jobs against the directory specified byprojectsDirectory(if possible).private voidresetSourceLevelSet(org.apache.maven.settings.TrackableBase trackable) private CharSequenceprivate booleanrunBuild(File basedir, File pomFile, File settingsFile, File actualJavaHome, InvokerProperties invokerProperties, FileLogger logger) Runs the specified project.private voidrunBuild(File projectsDir, BuildJob buildJob, File settingsFile, File actualJavaHome, CharSequence actualJreVersion, Properties globalInvokerProperties) Runs the specified project.private voidRuns the specified build jobs.private voidrunPostBuildHook(File basedir, Map<String, Object> context, FileLogger logger) private voidrunPreBuildHook(File basedir, Map<String, Object> context, FileLogger logger) private booleanrunSelectorHook(File basedir, Map<String, Object> context, FileLogger logger) scanProjectsDirectory(List<String> includes, List<String> excludes) Scans the projects directory for projects to build.private voidprivate FileLoggersetupBuildLogFile(File basedir) Initializes the build logger for the specified project.private voidsetupLoggerForBuildJob(FileLogger logger, org.apache.maven.shared.invoker.InvocationRequest request) private voidThis will create the necessary folders for the reports.private static StringConverts the specified filesystem path to a URL.private voidverify(org.apache.maven.shared.invoker.InvocationResult result, int invocationIndex, InvokerProperties invokerProperties, FileLogger logger) Verifies the invocation result.private voidwriteBuildReport(BuildJob buildJob) Writes the XML report for the specified build job unless report generation has been disabled.private voidwriteJunitReport(BuildJob buildJob, String safeFileName) private FilewriteMergedSettingsFile(org.apache.maven.settings.Settings mergedSettings) private voidwriteSummaryFile(List<BuildJob> buildJobs) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
ONE_SECOND
private static final float ONE_SECOND- See Also:
-
RESULT_COLUMN
private static final int RESULT_COLUMNThe zero-based column index where to print the invoker result.- See Also:
-
skipInvocation
@Parameter(property="invoker.skip", defaultValue="false") private boolean skipInvocationFlag used to suppress certain invocations. This is useful in tailoring the build using profiles.- Since:
- 1.1
-
suppressSummaries
@Parameter(defaultValue="false") protected boolean suppressSummariesFlag used to suppress the summary output notifying of successes and failures. If set totrue, 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). IfstreamLogsis enabled, the sub-build summary will also provide an indication.- Since:
- 1.0
-
streamLogs
@Parameter(property="invoker.streamLogs", defaultValue="false") private boolean streamLogsFlag 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 localRepositoryPathThe 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 projectsDirectoryDirectory to search for integration tests.- Since:
- 1.0
-
reportsDirectory
@Parameter(property="invoker.reportsDirectory", defaultValue="${project.build.directory}/invoker-reports") private File reportsDirectoryBase 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 disableReportsA flag to disable the generation of build reports.- Since:
- 1.4
-
cloneProjectsTo
Directory to which projects should be cloned prior to execution. If set tonull, 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 ignoretargetandbuild.login 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 intarget/itsby default.) Note: cloning needs to be enabled for properties filtering to work.- Since:
- 1.1
-
cloneAllFiles
@Parameter(defaultValue="false") private boolean cloneAllFilesSome 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 totruewill cause all files to be copied to thecloneProjectsTodirectory.- Since:
- 1.2
-
cloneClean
@Parameter(defaultValue="true") private boolean cloneCleanEnsure thecloneProjectsTodirectory is not polluted with files from earlier invoker runs.- Since:
- 1.6
-
pom
A single POM to build, skipping any scanning parameters and behavior.- Since:
- 1.0
-
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 allpom.xmlfiles one directory belowprojectsDirectory(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 ofprojectsDirectory, regardless if they contain apom.xml. This allows to perform builds that need/should not depend on the existence of a POM.- Since:
- 1.0
-
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 parametersettingsFilewill always be excluded automatically.- Since:
- 1.0
-
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 parameterpomExcludesapply to the setup projects, too. Default value is:setup*/pom.xml.- Since:
- 1.3
-
goals
-
selectorScript
@Parameter(property="invoker.selectorScript", defaultValue="selector") private String selectorScriptRelative 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.bshand.groovy. If this script exists for a particular project but returns any non-null value different fromtrue, 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 preBuildHookScriptRelative 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.bshand.groovy. If this script exists for a particular project but returns any non-null value different fromtrueor 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 postBuildHookScriptRelative 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.bshand.groovy. If this script exists for a particular project but returns any non-null value different fromtrueor throws an exception, the corresponding build is flagged as a failure.- Since:
- 1.0
-
testPropertiesFile
@Parameter(property="invoker.testPropertiesFile", defaultValue="test.properties") private String testPropertiesFileLocation of a properties file that defines CLI properties for the test.- Since:
- 1.0
-
properties
-
showErrors
@Parameter(property="invoker.showErrors", defaultValue="false") private boolean showErrorsWhether to show errors in the build output.- Since:
- 1.0
-
debug
@Parameter(property="invoker.debug", defaultValue="false") private boolean debugWhether to show debug statements in the build output.- Since:
- 1.0
-
quiet
@Parameter(property="invoker.quiet", defaultValue="false") private boolean quietWhether to execute Maven in quiet mode.- Since:
- 3.3.0
-
noLog
@Parameter(property="invoker.noLog", defaultValue="false") private boolean noLogSuppress logging to thebuild.logfile.- Since:
- 1.0
-
logDirectory
By default abuild.logis 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
-
filterProperties
-
invokerTest
A comma separated list of projectname patterns to run. Specify this parameter to run individual tests by file name, overriding thesetupIncludes,pomIncludesandpomExcludesparameters. 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 to run builds in-Dinvoker.test=SimpleTest,Comp*Test,!Compare*${projectsDirectory}/SimpleTestand${projectsDirectory}/ComplexTest, but not${projectsDirectory}/CompareTest- Since:
- 1.1 (exclusion since 1.8)
-
settingsFile
Path to an alternatesettings.xmlto 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 parameterlocalRepositoryPathis dominant.- Since:
- 1.2
-
mavenOpts
TheMAVEN_OPTSenvironment variable to use when invoking Maven. This value can be overridden for individual integration tests by usinginvokerPropertiesFile.
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
The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven installation.- Since:
- 1.3
-
mavenExecutable
mavenExecutable can either be a file relative to${maven.home}/bin/, test project workspace or an absolute file.- Since:
- 1.8
-
javaHome
TheJAVA_HOMEenvironment 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 encodingThe 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 addTestClassPathA 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 tofalse, the class path of script interpreter consists only of the runtime dependencies of the Maven Invoker Plugin. If set thetrue, 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 invokerPropertiesFileThe 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 parameterfilterProperties.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 showVersionflag to enable show mvn version used for running its (cli option : -V,--show-version )- Since:
- 1.4
-
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 mergeUserSettingsIf enable and if you have a settings file configured for the execution, it will be merged with your user settings.- Since:
- 1.6
-
environmentVariables
-
scriptVariables
-
timeoutInSeconds
@Parameter(defaultValue="0", property="invoker.timeoutInSeconds") private int timeoutInSeconds- Since:
- 3.0.2
-
writeJunitReport
@Parameter(defaultValue="false", property="invoker.writeJunitReport") private boolean writeJunitReportWrite test result in junit format.- Since:
- 3.1.2
-
junitPackageName
@Parameter(defaultValue="maven.invoker.it", property="invoker.junitPackageName") private String junitPackageNameThe package name use in junit report- Since:
- 3.1.2
-
updateOnly
@Parameter(defaultValue="false", property="invoker.updateOnly") private boolean updateOnlyOnly invoke maven projects if their sources have been modified since they were last built. Only works in conjunction withcloneProjectsTo.- Since:
- 3.2.2
-
updateSnapshots
@Parameter(defaultValue="false", property="invoker.updateSnapshots") private boolean updateSnapshotsForce 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
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 scriptRunnerThe scripter runner that is responsible to execute hook scripts. -
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 benull. This will be set tonullif the POMs have already been filtered during cloning. -
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
-
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
private final org.apache.maven.shared.invoker.Invoker invoker -
settingsBuilder
private final org.apache.maven.settings.building.SettingsBuilder settingsBuilder -
toolchainManagerPrivate
private final org.apache.maven.toolchain.ToolchainManagerPrivate toolchainManagerPrivate -
interpolatorUtils
-
-
Constructor Details
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionInvokes Maven on the configured test projects.- Throws:
org.apache.maven.plugin.MojoExecutionException- if the goal encountered severe errorsorg.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.mnvndirectories for executing projects- Parameters:
projectsDir- base of projectsbuildJobs- 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
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.MojoExecutionExceptionThis 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
-
getNonSetupJobs
-
handleScriptRunnerWithScriptClassPath
private void handleScriptRunnerWithScriptClassPath() -
writeSummaryFile
-
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 benull.- 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 benull.projectPath- The relative path of the current project, can denote either the POM or its base directory, must not benull.projectPaths- The set of already collected projects to add new projects to, must not benull. 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 parameterpomIncludes. 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
-
cloneProjects
private void cloneProjects(Collection<String> projectPaths) throws org.apache.maven.plugin.MojoExecutionException Copies the specified projects to the directory given bycloneProjectsTo. 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 benullnor containnullelements.- Throws:
org.apache.maven.plugin.MojoExecutionException- If the projects could not be copied/filtered.
-
getParentPath
-
copyDirectoryStructure
Copied a directory structure with default exclusions (.svn, CVS, etc)- Parameters:
sourceDir- The source directory to copy, must not benull.destDir- The target directory to copy to, must not benull.- Throws:
IOException- If the directory structure could not be copied.
-
alreadyCloned
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 benull.clonedSubpaths- The list of already cloned paths, must not benullnor containnullelements.- Returns:
trueif the specified path has already been cloned,falseotherwise.
-
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 benull.buildJobs- The build jobs to run must not benullnor containnullelements.- Throws:
org.apache.maven.plugin.MojoExecutionException- If any build could not be launched.
-
getAncestorFolder
-
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
-
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 benull.buildJob- The build job to run, must not benull.settingsFile- The (already interpolated) user settings file for the build, may benullto use the current user settings.globalInvokerProperties-- Throws:
org.apache.maven.plugin.MojoExecutionException- If the project could not be launched.
-
pad
-
deleteInterpolatedPomFile
Delete the interpolated pom file if it has been created before.- Parameters:
interpolatedPomFile- The interpolated pom file.
-
getSelection
Determines whether selector conditions of the specified invoker properties match the current environment.- Parameters:
invokerProperties- The invoker properties to check, must not benull.- Returns:
0if the job corresponding to the properties should be run, otherwise a bitwise value representing the reason why it should be skipped.
-
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 benull.- Throws:
org.apache.maven.plugin.MojoExecutionException- If the report could not be written.
-
writeJunitReport
-
formatElapsedTime
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 benull.pomFile- The (already interpolated) POM file, may benullfor a POM-less Maven invocation.settingsFile- The (already interpolated) user settings file for the build, may benull. 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:
trueif the project was launched orfalseif 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.MojoExecutionExceptionRunFailureException
-
runPreBuildHook
private void runPreBuildHook(File basedir, Map<String, Object> context, FileLogger logger) throws org.apache.maven.plugin.MojoExecutionException, RunFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionRunFailureException
-
runPostBuildHook
private void runPostBuildHook(File basedir, Map<String, Object> context, FileLogger logger) throws org.apache.maven.plugin.MojoExecutionException, RunFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionRunFailureException
-
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 intobuild.log.- Parameters:
basedir- The base directory of the project, must not benull.- Returns:
- The build logger or
nullif 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 benull.filename- The filename to the properties file to load, may benullto use the default path given bytestPropertiesFile.- 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.
-
calculateIncludes
-
calculateExcludes
- Throws:
IOException
-
getBuildJobs
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 benull.excludes- The exclude patterns for the scanner, may benullto exclude nothing.- Returns:
- The build jobs matching the patterns, never
null. - Throws:
IOException- If the project directory could not be scanned.
-
relativizeProjectPaths
Relativizes the project paths of the specified build jobs against the directory specified byprojectsDirectory(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 benullnor containnullelements.- Throws:
IOException- If any path could not be relativized.
-
relativizePath
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 benull.basedir- The (canonical path of the) base directory to relativize against, must not benull.- Returns:
- The relative path in normal form or
nullif the input path does not denote a sub path of the base directory. - Throws:
IOException- If the path could not be relativized.
-
getInterpolationValueSource
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
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 benull.- Returns:
- The
file:URL for the specified path, nevernull.
-
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 benull.interpolatedFile- The target file to write the interpolated contents of the original file to, must not benull.- 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 benull.- 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.
-