This essentially runs a maven-dependency-plugin:copy goal to copy a JAR file from (usually) a remote repository to a local directory. The directory is under the users control but defaults to the .m2 repository.

copy_artifact(
  groupId = NULL,
  artifactId = NULL,
  version = NULL,
  ...,
  coordinates = NULL,
  artifact = NULL,
  outputDirectory = .working_dir(artifact),
  repoUrl = .default_repos(),
  nocache = FALSE,
  verbose = c("normal", "quiet", "debug")
)

Arguments

groupId

optional, the maven groupId,

artifactId

optional, the maven artifactId,

version

optional, the maven version,

...

other maven coordinates such as classifier or packaging

coordinates

optional, coordinates as a coordinates object,

artifact

optional, coordinates as an artifact string groupId:artifactId:version[:packaging[:classifier]] string

outputDirectory

optional path, defaults to the rmaven cache directory

repoUrl

the URLs of the repositories to check (defaults to maven central, Sonatype snaphots and jitpack)

nocache

normally artifacts are only fetched if required, nocache forces fetching

verbose

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

Value

the output of the system2 call. 0 on success.

Examples

# \donttest{
# This code can take quite a while to run as has to
# download a lot of plugins, especially on first run
tmp = copy_artifact("org.junit.jupiter","junit-jupiter-api","5.9.0")
#> [INFO] Scanning for projects...
#> [INFO]                                                                         
#> [INFO] ------------------------------------------------------------------------
#> [INFO] Building Maven Stub Project (No POM) 1
#> [INFO] ------------------------------------------------------------------------
#> [INFO] 
#> [INFO] --- maven-dependency-plugin:3.3.0:get (default-cli) @ standalone-pom ---
#> [INFO] Resolving org.junit.jupiter:junit-jupiter-api:jar:5.9.0 with transitive dependencies
#> [INFO] ------------------------------------------------------------------------
#> [INFO] BUILD SUCCESS
#> [INFO] ------------------------------------------------------------------------
#> [INFO] Total time: 3.816 s
#> [INFO] Finished at: 2024-04-24T19:35:48+00:00
#> [INFO] Final Memory: 15M/57M
#> [INFO] ------------------------------------------------------------------------
print(tmp)
#> /home/runner/.cache/rmaven/org.junit.jupiter_junit-jupiter-api_5.9.0/junit-jupiter-api-5.9.0.jar
# }