public final class MavenArtifactUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.Object |
artifactLock |
Constructor and Description |
---|
MavenArtifactUtil() |
Modifier and Type | Method and Description |
---|---|
static ResourceLoader |
createMavenArtifactLoader(MavenResolver mavenResolver,
java.lang.String name)
A utility method to create a Maven artifact resource loader for the given artifact name.
|
static ResourceLoader |
createMavenArtifactLoader(java.lang.String name)
A utility method to create a Maven artifact resource loader for the given artifact name.
|
(package private) static <T> T |
doIo(java.security.PrivilegedExceptionAction<T> action) |
(package private) static <T> T |
doIo(java.security.PrivilegedExceptionAction<T> action,
java.security.AccessControlContext context) |
(package private) static void |
downloadFile(java.lang.String artifact,
java.lang.String src,
java.io.File dest) |
static java.io.File |
resolveArtifact(ArtifactCoordinates coordinates,
java.lang.String packaging)
Tries to find a maven jar artifact from the system property
"maven.repo.local" This property is a list of
platform separated directory names. |
static java.io.File |
resolveJarArtifact(ArtifactCoordinates coordinates)
Try to resolve a Maven JAR artifact.
|
public static java.io.File resolveJarArtifact(ArtifactCoordinates coordinates) throws java.io.IOException
resolveJarArtifact(qualifier, "jar")
.coordinates
- the non-null
Maven coordinates objectnull
if none existsjava.io.IOException
- if acquiring the artifact path failed for some reasonpublic static java.io.File resolveArtifact(ArtifactCoordinates coordinates, java.lang.String packaging) throws java.io.IOException
"maven.repo.local"
This property is a list of
platform separated directory names. If not specified, then it looks in ${user.home}/.m2/repository
by default.
If it can't find it in local paths, then will try to download from a remote repository from the system property
"remote.maven.repo"
. There is no default remote repository. It will download both the pom and jar and put it
into the first directory listed in "maven.repo.local"
(or the default directory). This directory will be
created if it doesn't exist.
Finally, if you do not want a message to console, then set the system property "maven.download.message"
to
"false"
.
coordinates
- the non-null
Maven coordinates objectpackaging
- a non-null
string with the exact packaging type desired (e.g. pom
, jar
, etc.)null
if none existsjava.io.IOException
- if acquiring the artifact path failed for some reasonstatic void downloadFile(java.lang.String artifact, java.lang.String src, java.io.File dest) throws java.io.IOException
java.io.IOException
public static ResourceLoader createMavenArtifactLoader(java.lang.String name) throws java.io.IOException
name
- the artifact namejava.io.IOException
- if the artifact could not be resolvedpublic static ResourceLoader createMavenArtifactLoader(MavenResolver mavenResolver, java.lang.String name) throws java.io.IOException
mavenResolver
- the Maven resolver to use (must not be null
)name
- the artifact namejava.io.IOException
- if the artifact could not be resolvedstatic <T> T doIo(java.security.PrivilegedExceptionAction<T> action) throws java.io.IOException
java.io.IOException
static <T> T doIo(java.security.PrivilegedExceptionAction<T> action, java.security.AccessControlContext context) throws java.io.IOException
java.io.IOException