Maven goals are defined either as life-cycle goals (e.g. "clean", "compile") or as plugin goals (e.g. "help:system"). Some Maven goals may be executed without a pom.xml file, others require one. Some maven goals (e.g. compilation) require the use of a JDK.

execute_maven(
  goal,
  opts = c(),
  pom_path = NULL,
  quiet = .quietly(verbose),
  debug = .debug(verbose),
  verbose = c("normal", "debug", "quiet"),
  require_jdk = FALSE,
  settings = .settings_path(),
  ...
)

Arguments

goal

the goal of the mvn command ( can be multiple ) e.g. c("clean","compile")

opts

provided options in the form c("-Doption1=value2","-Doption2=value2")

pom_path

optional. the path to a pom.xml file for goals that need one.

quiet

should output from maven be suppressed? (-q flag)

debug

should output from maven be verbose? (-X flag)

verbose

how much output from maven, one of "normal", "quiet", "debug"

require_jdk

does the goal you are executing require a JDK (e.g. compilation does, fetching artifacts and calculating class path does not)

settings

the path to a settings.xml file controlling Maven. The default is a configuration with a local repository in the rmaven cache directory (and not the Java maven repository).

...

non-empty named parameters are passed to maven as options in the form -Dname=value

Value

nothing, invisibly

Examples

# \donttest{
# This code can take quite a while to run as has to
# download a lot of plugins, especially on first run on a clean system
execute_maven("help:help")
#> [INFO] Scanning for projects...
#> [INFO]                                                                         
#> [INFO] ------------------------------------------------------------------------
#> [INFO] Building Maven Stub Project (No POM) 1
#> [INFO] ------------------------------------------------------------------------
#> [INFO] 
#> [INFO] --- maven-help-plugin:3.3.0:help (default-cli) @ standalone-pom ---
#> [INFO] Apache Maven Help Plugin 3.3.0
#>   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).
#> 
#> 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: 5.335 s
#> [INFO] Finished at: 2026-02-12T14:42:52+00:00
#> [INFO] Final Memory: 16M/68M
#> [INFO] ------------------------------------------------------------------------
# }