site 生命周期的目的是建立和发布项目站点,Maven 能够基于 pom.xml 文件包含的信息,自动生成一个友好的站点,方便团队交流和发布项目信息。该生命周期主要包含以下 4 个阶段:
生命周期阶段
描述
绑定的插件:目标
执行的任务
pre-site
执行项目站点生成前的必要准备工作
site
生成项目的站点文档
maven-site-plugin:site
生成项目的站点文档
post-site
执行完成站点生成所需的最终处理过程,并为站点部署做准备
site-deploy
将生成的站点文档部署到指定的网页服务器
maven-site-plugin:deploy
将生成的站点文档部署到指定的网页服务器
演示
执行mvn site命令,查看生成的站点文档。
执行 mvn site 报错:
Shell复制代码
(base) PS C:\Coding_Gallery\Intellij_IDEA_Workspace\maven_lifecycle_plugin_demo\maven_00> mvn site
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-site-plugin:3.3:site (default-site) @ maven_00 ---
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.8.0
[WARNING] Error injecting: org.apache.maven.report.projectinfo.CiManagementReport
java.lang.NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentContent
at java.lang.Class.getDeclaredConstructors0 (Native Method)
at java.lang.Class.privateGetDeclaredConstructors (Class.java:2671)
at java.lang.Class.getDeclaredConstructors (Class.java:2020)
at com.google.inject.spi.InjectionPoint.forConstructorOf (InjectionPoint.java:245)
......
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.ClassNotFoundException: org.apache.maven.doxia.siterenderer.DocumentContent
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
......
[ERROR] urls[60] = file:/C:/Softwares/Developer_Kits/apache-maven-3.8.8/repository/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar
[ERROR] : org.apache.maven.doxia.siterenderer.DocumentContent
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
Maven 是由 Java 语言开发的,每个插件对应一个 jar 包,而插件目标就是 jar 包中的类。例如,我们常用的测试插件 maven-surefire-plugin 的 test 目标主要由一个叫 TestMojo 的类实现的。既然底层是类,那么就会有属性和方法,我们开发人员在使用插件目标的时候就可以设置属性,而这些属性被称为目标参数。
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-clean-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:help (default-cli) @ maven_00 ---
[INFO] org.apache.maven.plugins:maven-clean-plugin:2.5
Maven Clean Plugin
The Maven Clean Plugin is a plugin that removes files generated at build-time
in a project's directory.
This plugin has 2 goals:
clean:clean
Goal which cleans the build.
This attempts to clean a project's working directory of the files that were
generated at build-time. By default, it discovers and deletes the directories
configured in project.build.directory, project.build.outputDirectory,
project.build.testOutputDirectory, and project.reporting.outputDirectory.
Files outside the default may also be included in the deletion by configuring
the filesets tag.
clean:help
Display help information on maven-clean-plugin.
Call
mvn clean:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.197 s
[INFO] Finished at: 2024-12-04T16:37:09+08:00
[INFO] ------------------------------------------------------------------------
可以看到 maven-clean-plugin 有两个目标:clean 和 help。
2、查看 maven-compiler-plugin 插件的所有目标
Shell复制代码
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-compiler-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-compiler-plugin:3.1:help (default-cli) @ maven_00 ---
[INFO] Maven Compiler Plugin 3.1
The Compiler Plugin is used to compile the sources of your project.
This plugin has 3 goals:
compiler:compile
Compiles application sources
compiler:help
Display help information on maven-compiler-plugin.
Call mvn compiler:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
compiler:testCompile
Compiles application test sources.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.499 s
[INFO] Finished at: 2024-12-04T16:45:37+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-surefire-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:help (default-cli) @ maven_00 ---
[INFO] Maven Surefire Plugin 2.12.4
Surefire is a test framework project.
This plugin has 2 goals:
surefire:help
Display help information on maven-surefire-plugin.
Call mvn surefire:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
surefire:test
Run tests using Surefire.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.376 s
[INFO] Finished at: 2024-12-04T16:34:12+08:00
[INFO] ------------------------------------------------------------------------
可以看到 maven-surefire-plugin 有两个目标:help 和 test。
4、查看 maven-jar-plugin 插件的所有目标
Shell复制代码
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-jar-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-jar-plugin:2.4:help (default-cli) @ maven_00 ---
[INFO] org.apache.maven.plugins:maven-jar-plugin:2.4
Maven JAR Plugin
Builds a Java Archive (JAR) file from the compiled project classes and
resources.
This plugin has 5 goals:
jar:help
Display help information on maven-jar-plugin.
Call
mvn jar:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
jar:jar
Build a JAR from the current project.
jar:sign
Deprecated. As of version 2.3, this goal is no longer supported in favor of
the dedicated maven-jarsigner-plugin.
jar:sign-verify
Deprecated. As of version 2.3, this goal is no longer supported in favor of
the dedicated maven-jarsigner-plugin.
jar:test-jar
Build a JAR of the test classes for the current project.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.349 s
[INFO] Finished at: 2024-12-04T16:50:49+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\Coding_Gallery\Intellij_IDEA_Workspace\maven_lifecycle_plugin_demo\maven_00> mvn org.apache.maven.plugins:maven-install-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:help (default-cli) @ maven_00 ---
[INFO] Maven Install Plugin 2.4
Copies the project artifacts to the user's local repository.
This plugin has 3 goals:
install:help
Display help information on maven-install-plugin.
Call mvn install:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
install:install
Installs the project's main artifact, and any other artifacts attached by
other plugins in the lifecycle, to the local repository.
install:install-file
Installs a file in the local repository.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.304 s
[INFO] Finished at: 2024-12-04T17:09:00+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-deploy-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.7:help (default-cli) @ maven_00 ---
[INFO] org.apache.maven.plugins:maven-deploy-plugin:2.7
Maven Deploy Plugin
Uploads the project artifacts to the internal remote repository.
This plugin has 3 goals:
deploy:deploy
Deploys an artifact to remote repository.
deploy:deploy-file
Installs the artifact in the remote repository.
deploy:help
Display help information on maven-deploy-plugin.
Call
mvn deploy:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.279 s
[INFO] Finished at: 2024-12-04T17:12:07+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-resources-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:help (default-cli) @ maven_00 ---
[INFO] Maven Resources Plugin 2.6
The Resources Plugin handles the copying of project resources to the output
directory. There are two different kinds of resources: main resources and test
resources. The difference is that the main resources are the resources
associated to the main source code while the test resources are associated to
the test source code. Thus, this allows the separation of resources for the
main source code and its unit tests.
This plugin has 4 goals:
resources:copy-resources
Copy resources of the configured plugin attribute resources
resources:help
Display help information on maven-resources-plugin.
Call mvn resources:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
resources:resources
Copy resources for the main source code to the main output directory. Always
uses the project.build.resources element to specify the resources to copy.
resources:testResources
Copy resources for the test source code to the test output directory. Always
uses the project.build.testResources element to specify the resources to copy.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.307 s
[INFO] Finished at: 2024-12-04T17:16:58+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-site-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-site-plugin:3.3:help (default-cli) @ maven_00 ---
[INFO] Maven Site Plugin 3 3.3
The Maven Site Plugin is a plugin that generates a site for the current
project.
This plugin has 9 goals:
site:attach-descriptor
Adds the site descriptor (site.xml) to the list of files to be
installed/deployed.
For Maven-2.x this is enabled by default only when the project has pom
packaging since it will be used by modules inheriting, but this can be enabled
for other projects packaging if needed.
This default execution has been removed from the built-in lifecycle of Maven
3.x for pom-projects. Users that actually use those projects to provide a
common site descriptor for sub modules will need to explicitly define this
goal execution to restore the intended behavior.
site:deploy
Deploys the generated site using wagon supported protocols to the site URL
specified in the <distributionManagement> section of the POM.
For scp protocol, the website files are packaged by wagon into zip archive,
then the archive is transfered to the remote host, next it is un-archived
which is much faster than making a file by file copy.
site:effective-site
Displays the effective site descriptor as an XML for this build, after
inheritance and interpolation of site.xml.
site:help
Display help information on maven-site-plugin.
Call mvn site:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
site:jar
Bundles the site output into a JAR so that it can be deployed to a repository.
site:run
Starts the site up, rendering documents as requested for faster editing. It
uses Jetty as the web server.
site:site
Generates the site for a single project.
Note that links between module sites in a multi module build will not work,
since local build directory structure doesn't match deployed site.
site:stage
Deploys the generated site to a local staging or mock directory based on the
site URL specified in the <distributionManagement> section of the POM.
It can be used to test that links between module sites in a multi-module build
work.
site:stage-deploy
Deploys the generated site to a staging or mock URL to the site URL specified
in the <distributionManagement> section of the POM, using wagon supported
protocols
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.986 s
[INFO] Finished at: 2024-12-04T17:23:37+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn org.apache.maven.plugins:maven-help-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.5.1:help (default-cli) @ maven_00 ---
[INFO] Apache Maven Help Plugin 3.5.1
The Maven Help plugin provides goals aimed at helping to make sense out of
the build environment. It includes the ability to view the effective
POM and settings files, after inheritance and active profiles
have been applied, as well as a describe a particular plugin goal to give
usage information.
This plugin has 8 goals:
help:active-profiles
Displays a list of the profiles which are currently active for this build.
help:all-profiles
Displays a list of available profiles under the current project.
Note: it will list all profiles for a project. If a profile comes up with a
status inactive then there might be a need to set profile activation
switches/property.
help:describe
Displays a list of the attributes for a Maven Plugin and/or goals (aka Mojo -
Maven plain Old Java Object).
See also: What is a Mojo?
<http://maven.apache.org/general.html#What_is_a_Mojo>
help:effective-pom
Displays the effective POM as an XML for this build, with the active profiles
factored in, or a specified artifact. If verbose, a comment is added to each
XML element describing the origin of the line.
help:effective-settings
Displays the calculated settings as XML for this project, given any profile
enhancement and the inheritance of the global settings into the user-level
settings.
help:evaluate
Evaluates Maven expressions given by the user in an interactive mode.
help:help
Display help information on maven-help-plugin.
Call mvn help:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
help:system
Displays a list of the platform details like system properties and environment
variables.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.365 s
[INFO] Finished at: 2024-12-04T20:21:33+08:00
[INFO] ------------------------------------------------------------------------
如下所示,该插件有 21 个目标,其中 tree 常用,用于查看当前项目的依赖树,帮助排查依赖冲突。
Shell复制代码
(base) PS C:\...\maven_09> mvn org.apache.maven.plugins:maven-dependency-plugin:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_09 >------------------------
[INFO] Building maven_09 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:help (default-cli) @ maven_09 ---
[INFO] Maven Dependency Plugin 2.8
Provides utility goals to work with dependencies like copying, unpacking,
analyzing, resolving and many more.
This plugin has 21 goals:
dependency:analyze
Analyzes the dependencies of this project and determines which are: used and
declared; used and undeclared; unused and declared. This goal is intended to
be used standalone, thus it always executes the test-compile phase - use the
dependency:analyze-only goal instead when participating in the build
lifecycle.
By default, maven-dependency-analyzer is used to perform the analysis, with
limitations due to the fact that it works at bytecode level, but any analyzer
can be plugged in through analyzer parameter.
dependency:analyze-dep-mgt
This mojo looks at the dependencies after final resolution and looks for
mismatches in your dependencyManagement section. In versions of maven prior to
2.0.6, it was possible to inherit versions that didn't match your
dependencyManagement. See MNG-1577 for more info. This mojo is also useful for
just detecting projects that override the dependencyManagement directly. Set
ignoreDirect to false to detect these otherwise normal conditions.
dependency:analyze-duplicate
Analyzes the <dependencies/> and <dependencyManagement/> tags in the pom.xml
and determines the duplicate declared dependencies.
dependency:analyze-only
Analyzes the dependencies of this project and determines which are: used and
declared; used and undeclared; unused and declared. This goal is intended to
be used in the build lifecycle, thus it assumes that the test-compile phase
has been executed - use the dependency:analyze goal instead when running
standalone.
By default, maven-dependency-analyzer is used to perform the analysis, with
limitations due to the fact that it works at bytecode level, but any analyzer
can be plugged in through analyzer parameter.
dependency:analyze-report
Analyzes the dependencies of this project and produces a report that
summarizes which are: used and declared; used and undeclared; unused and
declared.
dependency:build-classpath
This goal will output a classpath string of dependencies from the local
repository to a file or log.
dependency:copy
Goal that copies a list of artifacts from the repository to defined locations.
dependency:copy-dependencies
Goal that copies the project dependencies from the repository to a defined
location.
dependency:get
Resolves a single artifact, eventually transitively, from the specified remote
repositories. Caveat: will always check the central repository defined in the
super pom. You could use a mirror entry in your settings.xml
dependency:go-offline
Goal that resolves all project dependencies, including plugins and reports and
their dependencies.
dependency:help
Display help information on maven-dependency-plugin.
Call mvn dependency:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
dependency:list
Displays the list of dependencies for this project.
dependency:list-repositories
Goal that resolves all project dependencies and then lists the repositories
used by the build and by the transitive dependencies
dependency:properties
Goal that sets a property pointing to the artifact file for each project
dependency. For each dependency (direct and transitive) a project property
will be set which follows the groupId:artifactId:type:[classifier] form and
contains the path to the resolved artifact.
dependency:purge-local-repository
Remove the project dependencies from the local repository, and optionally
re-resolve them.
dependency:resolve
Goal that resolves the project dependencies from the repository.
dependency:resolve-plugins
Goal that resolves all project plugins and reports and their dependencies.
dependency:sources
Goal that resolves the project source dependencies from the repository.
dependency:tree
Displays the dependency tree for this project.
dependency:unpack
Goal that retrieves a list of artifacts from the repository and unpacks them
in a defined location.
dependency:unpack-dependencies
Goal that unpacks the project dependencies from the repository to a defined
location.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.933 s
[INFO] Finished at: 2024-12-12T20:48:36+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn help:describe -Dplugin="org.apache.maven.plugins:maven-resources-plugin"
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.5.1:describe (default-cli) @ maven_00 ---
[INFO] org.apache.maven.plugins:maven-resources-plugin:2.6
Name: Maven Resources Plugin
Description: The Resources Plugin handles the copying of project resources to
the output directory. There are two different kinds of resources: main
resources and test resources. The difference is that the main resources are
the resources associated to the main source code while the test resources are
associated to the test source code. Thus, this allows the separation of
resources for the main source code and its unit tests.
Group Id: org.apache.maven.plugins
Artifact Id: maven-resources-plugin
Version: 2.6
Goal Prefix: resources
This plugin has 4 goals:
resources:copy-resources
Description: Copy resources of the configured plugin attribute resources
resources:help
Description: Display help information on maven-resources-plugin.
Call mvn resources:help -Ddetail=true -Dgoal=<goal-name> to display
parameter details.
resources:resources
Description: Copy resources for the main source code to the main output
directory. Always uses the project.build.resources element to specify the
resources to copy.
resources:testResources
Description: Copy resources for the test source code to the test output
directory. Always uses the project.build.testResources element to specify
the resources to copy.
For more information, run 'mvn help:describe [...] -Ddetail'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.833 s
[INFO] Finished at: 2024-12-04T19:59:37+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn resources:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:help (default-cli) @ maven_00 ---
[INFO] Maven Resources Plugin 2.6
The Resources Plugin handles the copying of project resources to the output
directory. There are two different kinds of resources: main resources and test
resources. The difference is that the main resources are the resources
associated to the main source code while the test resources are associated to
the test source code. Thus, this allows the separation of resources for the
main source code and its unit tests.
This plugin has 4 goals:
resources:copy-resources
Copy resources of the configured plugin attribute resources
resources:help
Display help information on maven-resources-plugin.
Call mvn resources:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
resources:resources
Copy resources for the main source code to the main output directory. Always
uses the project.build.resources element to specify the resources to copy.
resources:testResources
Copy resources for the test source code to the test output directory. Always
uses the project.build.testResources element to specify the resources to copy.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.346 s
[INFO] Finished at: 2024-12-04T20:01:59+08:00
[INFO] ------------------------------------------------------------------------
方式三演示
查看 maven-surefire-plugin 的 test 目标:
Shell复制代码
(base) PS C:\...\maven_00> mvn surefire:help -Dgoal=help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:help (default-cli) @ maven_00 ---
[INFO] Maven Surefire Plugin 2.12.4
Surefire is a test framework project.
surefire:help
Display help information on maven-surefire-plugin.
Call mvn surefire:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.344 s
[INFO] Finished at: 2024-12-04T20:51:33+08:00
[INFO] ------------------------------------------------------------------------
(base) PS C:\...\maven_00> mvn surefire:help -Dgoal=test -Ddetail
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< cn.myphoenix:maven_00 >------------------------
[INFO] Building maven_00 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:help (default-cli) @ maven_00 ---
[INFO] Maven Surefire Plugin 2.12.4
Surefire is a test framework project.
surefire:test
Run tests using Surefire.
Available parameters:
additionalClasspathElements
Additional elements to be appended to the classpath.
argLine (Default: null)
Arbitrary JVM options to set on the command line.
basedir
The base directory of the project being tested. This can be obtained in
your integration test via System.getProperty('basedir').
childDelegation (Default: false)
When false it makes tests run using the standard classloader delegation
instead of the default Maven isolated classloader. Only used when forking
(forkMode is not 'none').
Setting it to false helps with some problems caused by conflicts between
xml parsers in the classpath and the Java 5 provider parser.
classesDirectory
The directory containing generated classes of the project being tested.
This will be included after the test classes in the test classpath.
classpathDependencyExcludes
List of dependencies to exclude from the test classpath. Each dependency
string must follow the format groupId:artifactId. For example:
org.acme:project-a
classpathDependencyScopeExclude
A dependency scope to exclude from the test classpath. The scope should be
one of the scopes defined by org.apache.maven.artifact.Artifact. This
includes the following:
- compile - system, provided, compile
- runtime - compile, runtime
- compile+runtime - system, provided, compile, runtime
- runtime+system - system, compile, runtime
- test - system, provided, compile, runtime, test
debugForkedProcess (Default: null)
Attach a debugger to the forked JVM. If set to 'true', the process will
suspend and wait for a debugger to attach on port 5005. If set to some
other string, that string will be appended to the argLine, allowing you to
configure arbitrary debuggability options (without overwriting the other
options specified through the argLine parameter).
disableXmlReport (Default: false)
Flag to disable the generation of report files in xml format.
enableAssertions (Default: true)
By default, Surefire enables JVM assertions for the execution of your test
cases. To disable the assertions, set this flag to 'false'.
environmentVariables
Additional environment variables to set on the command line.
excludedGroups (Default: null)
(TestNG/JUnit47 provider with JUnit4.8+ only) Excluded groups. Any
methods/classes/etc with one of the groups specified in this list will
specifically not be run.
For JUnit, this parameter forces the use of the 4.7 provider
This parameter is ignored if the suiteXmlFiles parameter is specified.
excludes
A list of <exclude> elements specifying the tests (by pattern) that should
be excluded in testing. When not specified and when the test parameter is
not specified, the default excludes will be
<excludes>
<exclude>**/*$*</exclude>
</excludes>
(which excludes all inner classes).
This parameter is ignored if the TestNG suiteXmlFiles parameter is
specified. Each exclude item may also contain a comma-separated sublist of
items, which will be treated as multiple <exclude> entries.
failIfNoSpecifiedTests (Default: null)
Set this to 'true' to cause a failure if the none of the tests specified
in -Dtest=... are run. Defaults to 'true'.
failIfNoTests (Default: null)
Set this to 'true' to cause a failure if there are no tests to run.
Defaults to 'false'.
forkedProcessTimeoutInSeconds (Default: null)
Kill the forked test process after a certain number of seconds. If set to
0, wait forever for the process, never timing out.
forkMode (Default: once)
Option to specify the forking mode. Can be 'never', 'once', 'always' or
'perthread'. 'none' and 'pertest' are also accepted for backwards
compatibility. 'always' forks for each test-class. 'perthread' will create
'threadCount' parallel forks.
groups (Default: null)
(TestNG/JUnit47 provider with JUnit4.8+ only) Groups for this test. Only
classes/methods/etc decorated with one of the groups specified here will
be included in test run, if specified.
For JUnit, this parameter forces the use of the 4.7 provider
This parameter is ignored if the suiteXmlFiles parameter is specified.
includes
A list of <include> elements specifying the tests (by pattern) that should
be included in testing. When not specified and when the test parameter is
not specified, the default includes will be
<includes>
<include>**/IT*.java</include>
<include>**/*IT.java</include>
<include>**/*ITCase.java</include>
</includes>
Each include item may also contain a comma-separated sublist of items,
which will be treated as multiple <include> entries.
This parameter is ignored if the TestNG suiteXmlFiles parameter is
specified.
junitArtifactName (Default: junit:junit)
Allows you to specify the name of the JUnit artifact. If not set,
junit:junit will be used.
jvm (Default: null)
Option to specify the jvm (or path to the java executable) to use with the
forking options. For the default, the jvm will be a new instance of the
same VM as the one used to run Maven. JVM settings are not inherited from
MAVEN_OPTS.
objectFactory (Default: null)
(TestNG only) Define the factory class used to create all test instances.
parallel (Default: null)
(TestNG only) When you use the parallel attribute, TestNG will try to run
all your test methods in separate threads, except for methods that depend
on each other, which will be run in the same thread in order to respect
their order of execution. (JUnit 4.7 provider) Supports values
'classes'/'methods'/'both' to run in separate threads, as controlled by
threadCount.
perCoreThreadCount (Default: true)
(JUnit 4.7 provider) Indicates that threadCount is per cpu core.
printSummary (Default: true)
Option to print summary of test suites or just print the test cases that
have errors.
properties
List of properties for configuring all TestNG related configurations. This
is the new preferred method of configuring TestNG.
redirectTestOutputToFile (Default: false)
Set this to 'true' to redirect the unit test standard output to a file
(found in reportsDirectory/testName-output.txt).
remoteRepositories
The remote plugin repositories declared in the POM.
reportFormat (Default: brief)
Selects the formatting for the test report to be generated. Can be set as
'brief' or 'plain'.
reportNameSuffix (Default: )
Add custom text into report filename:
TEST-testClassName-reportNameSuffix.xml,
testClassName-reportNameSuffix.txt and
testClassName-reportNameSuffix-output.txt. File
TEST-testClassName-reportNameSuffix.xml has changed attributes
'testsuite'--'name' and 'testcase'--'classname' - reportNameSuffix is
added to the attribute value.
reportsDirectory
Base directory where all reports are written to.
runOrder
Defines the order the tests will be run in. Supported values are
'alphabetical', 'reversealphabetical', 'random', 'hourly' (alphabetical on
even hours, reverse alphabetical on odd hours), 'failedfirst', 'balanced'
and 'filesystem'. Odd/Even for hourly is determined at the time the of
scanning the classpath, meaning it could change during a multi-module
build. Failed first will run tests that failed on previous run first, as
well as new tests for this run. Balanced is only relevant with
parallel=classes, and will try to optimize the run-order of the tests to
make all tests complete at the same time, reducing the overall execution
time. Note that the statistics are stored in a file named
.surefire-XXXXXXXXX beside pom.xml, and should not be checked into version
control. The 'XXXXX' is the SHA1 checksum of the entire surefire
configuration, so different configurations will have different statistics
files, meaning if you change any config settings you will re-run once
before new statistics data can be established.
skip (Default: false)
Set this to 'true' to bypass unit tests entirely. Its use is NOT
RECOMMENDED, especially if you enable it using the 'maven.test.skip'
property, because maven.test.skip disables both running the tests and
compiling the tests. Consider using the skipTests parameter instead.
skipExec (Default: null)
Deprecated. Use skipTests instead.
This old parameter is just like skipTests, but bound to the old property
'maven.test.skip.exec'.
skipTests (Default: false)
Set this to 'true' to skip running tests, but still compile them. Its use
is NOT RECOMMENDED, but quite convenient on occasion.
suiteXmlFiles
(TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file
locations. Note that suiteXmlFiles is incompatible with several other
parameters of this plugin, like includes/excludes.
This parameter is ignored if the test parameter is specified (allowing you
to run a single test instead of an entire suite).
systemProperties
Deprecated. Use systemPropertyVariables instead.
List of System properties to pass to the JUnit tests.
systemPropertiesFile
List of System properties, loaded from a file, to pass to the JUnit tests.
systemPropertyVariables
List of System properties to pass to the JUnit tests.
test (Default: null)
Specify this parameter to run individual tests by file name, overriding
the includes/excludes parameters. Each pattern you specify here will be
used to create an include pattern formatted like **/${test}.java, so you
can just type '-Dtest=MyTest' to run a single test called
'foo/MyTest.java'.
This parameter overrides the includes/excludes parameters, and the TestNG
suiteXmlFiles parameter. Since 2.7.3, you can execute a limited number of
methods in the test by adding #myMethod or #my*ethod. For example,
'-Dtest=MyTest#myMethod'. This is supported for junit 4.x and testNg.
testClassesDirectory
The directory containing generated test classes of the project being
tested. This will be included at the beginning of the test classpath. *
testFailureIgnore (Default: false)
Set this to 'true' to ignore a failure during testing. Its use is NOT
RECOMMENDED, but quite convenient on occasion.
testNGArtifactName (Default: org.testng:testng)
Allows you to specify the name of the TestNG artifact. If not set,
org.testng:testng will be used.
testSourceDirectory
The test source directory containing test class sources.
Required: Yes
threadCount (Default: null)
(forkMode=perthread or TestNG/JUnit 4.7 provider) The attribute
thread-count allows you to specify how many threads should be allocated
for this execution. Only makes sense to use in conjunction with the
parallel parameter. (forkMode=perthread does not support/require the
parallel parameter)
trimStackTrace (Default: true)
Whether to trim the stack trace in the reports to just the lines within
the test, or show the full trace.
useFile (Default: true)
Option to generate a file test report or just output the test report to
the console.
useManifestOnlyJar (Default: true)
By default, Surefire forks your tests using a manifest-only JAR; set this
parameter to 'false' to force it to launch your tests with a plain old
Java classpath. (See
http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
for a more detailed explanation of manifest-only JARs and their benefits.)
Beware, setting this to 'false' may cause your tests to fail on Windows if
your classpath is too long.
useSystemClassLoader (Default: true)
Option to pass dependencies to the system's classloader instead of using
an isolated class loader when forking. Prevents problems with JDKs which
implement the service provider lookup mechanism by using the system's
classloader.
useUnlimitedThreads (Default: false)
(JUnit 4.7 provider) Indicates that the thread pool will be unlimited. The
parallel parameter and the actual number of classes/methods will decide.
Setting this to 'true' effectively disables perCoreThreadCount and
threadCount. Defaults to 'false'.
workingDirectory (Default: null)
Command line working directory.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.360 s
[INFO] Finished at: 2024-12-04T20:55:58+08:00
[INFO] ------------------------------------------------------------------------
如果不指定 -Dgoal,会列出该插件的所有目标的所有参数,例如
Shell复制代码
(base) PS C:\...\timer-maven-plugin> mvn org.apache.maven.plugins:maven-surefire-plugin:help -Ddetail
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< cn.myphoenix:timer-maven-plugin >-------------------
[INFO] Building timer-maven-plugin Maven Plugin 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] ----------------------------[ maven-plugin ]----------------------------
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:help (default-cli) @ timer-maven-plugin ---
[INFO] Maven Surefire Plugin 2.12.4
Surefire is a test framework project.
This plugin has 2 goals:
surefire:help
Display help information on maven-surefire-plugin.
Call mvn surefire:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
Available parameters:
detail (Default: false)
If true, display all settable properties for each goal.
goal (Default: null)
The name of the goal for which to show help. If unspecified, all goals
will be displayed.
indentSize (Default: 2)
The number of spaces per indentation level, should be positive.
lineLength (Default: 80)
The maximum length of a display line, should be positive.
surefire:test
Run tests using Surefire.
Available parameters:
additionalClasspathElements
Additional elements to be appended to the classpath.
argLine (Default: null)
Arbitrary JVM options to set on the command line.
basedir
The base directory of the project being tested. This can be obtained in
your integration test via System.getProperty('basedir').
childDelegation (Default: false)
When false it makes tests run using the standard classloader delegation
instead of the default Maven isolated classloader. Only used when forking
(forkMode is not 'none').
Setting it to false helps with some problems caused by conflicts between
xml parsers in the classpath and the Java 5 provider parser.
classesDirectory
The directory containing generated classes of the project being tested.
This will be included after the test classes in the test classpath.
classpathDependencyExcludes
List of dependencies to exclude from the test classpath. Each dependency
string must follow the format groupId:artifactId. For example:
org.acme:project-a
classpathDependencyScopeExclude
A dependency scope to exclude from the test classpath. The scope should be
one of the scopes defined by org.apache.maven.artifact.Artifact. This
includes the following:
- compile - system, provided, compile
- runtime - compile, runtime
- compile+runtime - system, provided, compile, runtime
- runtime+system - system, compile, runtime
- test - system, provided, compile, runtime, test
debugForkedProcess (Default: null)
Attach a debugger to the forked JVM. If set to 'true', the process will
suspend and wait for a debugger to attach on port 5005. If set to some
other string, that string will be appended to the argLine, allowing you to
configure arbitrary debuggability options (without overwriting the other
options specified through the argLine parameter).
disableXmlReport (Default: false)
Flag to disable the generation of report files in xml format.
enableAssertions (Default: true)
By default, Surefire enables JVM assertions for the execution of your test
cases. To disable the assertions, set this flag to 'false'.
environmentVariables
Additional environment variables to set on the command line.
excludedGroups (Default: null)
(TestNG/JUnit47 provider with JUnit4.8+ only) Excluded groups. Any
methods/classes/etc with one of the groups specified in this list will
specifically not be run.
For JUnit, this parameter forces the use of the 4.7 provider
This parameter is ignored if the suiteXmlFiles parameter is specified.
excludes
A list of <exclude> elements specifying the tests (by pattern) that should
be excluded in testing. When not specified and when the test parameter is
not specified, the default excludes will be
<excludes>
<exclude>**/*$*</exclude>
</excludes>
(which excludes all inner classes).
This parameter is ignored if the TestNG suiteXmlFiles parameter is
specified. Each exclude item may also contain a comma-separated sublist of
items, which will be treated as multiple <exclude> entries.
failIfNoSpecifiedTests (Default: null)
Set this to 'true' to cause a failure if the none of the tests specified
in -Dtest=... are run. Defaults to 'true'.
failIfNoTests (Default: null)
Set this to 'true' to cause a failure if there are no tests to run.
Defaults to 'false'.
forkedProcessTimeoutInSeconds (Default: null)
Kill the forked test process after a certain number of seconds. If set to
0, wait forever for the process, never timing out.
forkMode (Default: once)
Option to specify the forking mode. Can be 'never', 'once', 'always' or
'perthread'. 'none' and 'pertest' are also accepted for backwards
compatibility. 'always' forks for each test-class. 'perthread' will create
'threadCount' parallel forks.
groups (Default: null)
(TestNG/JUnit47 provider with JUnit4.8+ only) Groups for this test. Only
classes/methods/etc decorated with one of the groups specified here will
be included in test run, if specified.
For JUnit, this parameter forces the use of the 4.7 provider
This parameter is ignored if the suiteXmlFiles parameter is specified.
includes
A list of <include> elements specifying the tests (by pattern) that should
be included in testing. When not specified and when the test parameter is
not specified, the default includes will be
<includes>
<include>**/IT*.java</include>
<include>**/*IT.java</include>
<include>**/*ITCase.java</include>
</includes>
Each include item may also contain a comma-separated sublist of items,
which will be treated as multiple <include> entries.
This parameter is ignored if the TestNG suiteXmlFiles parameter is
specified.
junitArtifactName (Default: junit:junit)
Allows you to specify the name of the JUnit artifact. If not set,
junit:junit will be used.
jvm (Default: null)
Option to specify the jvm (or path to the java executable) to use with the
forking options. For the default, the jvm will be a new instance of the
same VM as the one used to run Maven. JVM settings are not inherited from
MAVEN_OPTS.
objectFactory (Default: null)
(TestNG only) Define the factory class used to create all test instances.
parallel (Default: null)
(TestNG only) When you use the parallel attribute, TestNG will try to run
all your test methods in separate threads, except for methods that depend
on each other, which will be run in the same thread in order to respect
their order of execution. (JUnit 4.7 provider) Supports values
'classes'/'methods'/'both' to run in separate threads, as controlled by
threadCount.
perCoreThreadCount (Default: true)
(JUnit 4.7 provider) Indicates that threadCount is per cpu core.
printSummary (Default: true)
Option to print summary of test suites or just print the test cases that
have errors.
properties
List of properties for configuring all TestNG related configurations. This
is the new preferred method of configuring TestNG.
redirectTestOutputToFile (Default: false)
Set this to 'true' to redirect the unit test standard output to a file
(found in reportsDirectory/testName-output.txt).
remoteRepositories
The remote plugin repositories declared in the POM.
reportFormat (Default: brief)
Selects the formatting for the test report to be generated. Can be set as
'brief' or 'plain'.
reportNameSuffix (Default: )
Add custom text into report filename:
TEST-testClassName-reportNameSuffix.xml,
testClassName-reportNameSuffix.txt and
testClassName-reportNameSuffix-output.txt. File
TEST-testClassName-reportNameSuffix.xml has changed attributes
'testsuite'--'name' and 'testcase'--'classname' - reportNameSuffix is
added to the attribute value.
reportsDirectory
Base directory where all reports are written to.
runOrder
Defines the order the tests will be run in. Supported values are
'alphabetical', 'reversealphabetical', 'random', 'hourly' (alphabetical on
even hours, reverse alphabetical on odd hours), 'failedfirst', 'balanced'
and 'filesystem'. Odd/Even for hourly is determined at the time the of
scanning the classpath, meaning it could change during a multi-module
build. Failed first will run tests that failed on previous run first, as
well as new tests for this run. Balanced is only relevant with
parallel=classes, and will try to optimize the run-order of the tests to
make all tests complete at the same time, reducing the overall execution
time. Note that the statistics are stored in a file named
.surefire-XXXXXXXXX beside pom.xml, and should not be checked into version
control. The 'XXXXX' is the SHA1 checksum of the entire surefire
configuration, so different configurations will have different statistics
files, meaning if you change any config settings you will re-run once
before new statistics data can be established.
skip (Default: false)
Set this to 'true' to bypass unit tests entirely. Its use is NOT
RECOMMENDED, especially if you enable it using the 'maven.test.skip'
property, because maven.test.skip disables both running the tests and
compiling the tests. Consider using the skipTests parameter instead.
skipExec (Default: null)
Deprecated. Use skipTests instead.
This old parameter is just like skipTests, but bound to the old property
'maven.test.skip.exec'.
skipTests (Default: false)
Set this to 'true' to skip running tests, but still compile them. Its use
is NOT RECOMMENDED, but quite convenient on occasion.
suiteXmlFiles
(TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file
locations. Note that suiteXmlFiles is incompatible with several other
parameters of this plugin, like includes/excludes.
This parameter is ignored if the test parameter is specified (allowing you
to run a single test instead of an entire suite).
systemProperties
Deprecated. Use systemPropertyVariables instead.
List of System properties to pass to the JUnit tests.
systemPropertiesFile
List of System properties, loaded from a file, to pass to the JUnit tests.
systemPropertyVariables
List of System properties to pass to the JUnit tests.
test (Default: null)
Specify this parameter to run individual tests by file name, overriding
the includes/excludes parameters. Each pattern you specify here will be
used to create an include pattern formatted like **/${test}.java, so you
can just type '-Dtest=MyTest' to run a single test called
'foo/MyTest.java'.
This parameter overrides the includes/excludes parameters, and the TestNG
suiteXmlFiles parameter. Since 2.7.3, you can execute a limited number of
methods in the test by adding #myMethod or #my*ethod. For example,
'-Dtest=MyTest#myMethod'. This is supported for junit 4.x and testNg.
testClassesDirectory
The directory containing generated test classes of the project being
tested. This will be included at the beginning of the test classpath. *
testFailureIgnore (Default: false)
Set this to 'true' to ignore a failure during testing. Its use is NOT
RECOMMENDED, but quite convenient on occasion.
testNGArtifactName (Default: org.testng:testng)
Allows you to specify the name of the TestNG artifact. If not set,
org.testng:testng will be used.
testSourceDirectory
The test source directory containing test class sources.
Required: Yes
threadCount (Default: null)
(forkMode=perthread or TestNG/JUnit 4.7 provider) The attribute
thread-count allows you to specify how many threads should be allocated
for this execution. Only makes sense to use in conjunction with the
parallel parameter. (forkMode=perthread does not support/require the
parallel parameter)
trimStackTrace (Default: true)
Whether to trim the stack trace in the reports to just the lines within
the test, or show the full trace.
useFile (Default: true)
Option to generate a file test report or just output the test report to
the console.
useManifestOnlyJar (Default: true)
By default, Surefire forks your tests using a manifest-only JAR; set this
parameter to 'false' to force it to launch your tests with a plain old
Java classpath. (See
http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
for a more detailed explanation of manifest-only JARs and their benefits.)
Beware, setting this to 'false' may cause your tests to fail on Windows if
your classpath is too long.
useSystemClassLoader (Default: true)
Option to pass dependencies to the system's classloader instead of using
an isolated class loader when forking. Prevents problems with JDKs which
implement the service provider lookup mechanism by using the system's
classloader.
useUnlimitedThreads (Default: false)
(JUnit 4.7 provider) Indicates that the thread pool will be unlimited. The
parallel parameter and the actual number of classes/methods will decide.
Setting this to 'true' effectively disables perCoreThreadCount and
threadCount. Defaults to 'false'.
workingDirectory (Default: null)
Command line working directory.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.359 s
[INFO] Finished at: 2024-12-12T16:00:55+08:00
[INFO] ------------------------------------------------------------------------
/**
* Set this to "true" to bypass unit tests entirely. Its use is NOT RECOMMENDED, especially if you enable it using
* the "maven.test.skip" property, because maven.test.skip disables both running the tests and compiling the tests.
* Consider using the <code>skipTests</code> parameter instead.
*/
@Parameter( property = "maven.test.skip", defaultValue = "false" )
protected boolean skip;
(2) skipTests 属性:
Java复制代码
/**
* Set this to "true" to skip running tests, but still compile them. Its use is NOT RECOMMENDED, but quite
* convenient on occasion.
*
* @since 2.4
*/
@Parameter( property = "skipTests", defaultValue = "false" )
protected boolean skipTests;
(3) execute 方法:
Java复制代码
public void execute()
throws MojoExecutionException, MojoFailureException
{
// Stuff that should have been final
setupStuff();
if ( verifyParameters() && !hasExecutedBefore() )
{
DefaultScanResult scan = scanDirectories();
if ( scan.isEmpty() )
{
if ( getEffectiveFailIfNoTests() )
{
throw new MojoFailureException(
"No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
}
handleSummary( Summary.noTestsRun() );
return;
}
logReportsDirectory();
executeAfterPreconditionsChecked( scan );
}
}