Package de.softwareforge.testing.maven
Class MavenArtifactLoader
java.lang.Object
de.softwareforge.testing.maven.MavenArtifactLoader
A quick and dirty artifact loader. Downloads published artifacts from the Maven repository system.
The loader respects the local maven settings (repositories, mirrors etc.) if present. If no configuration is found, a hard-coded reference to Maven Central is used.
-
Constructor Summary
ConstructorDescriptionCreates a new artifact loader for 'jar' artifacts.MavenArtifactLoader
(String extension) Creates a new artifact loader for artifacts. -
Method Summary
Modifier and TypeMethodDescriptionCreate a new version match builder to retrieve an artifact.findLatestVersion
(String groupId, String artifactId, String version) Find a matching artifact version from a partially defined artifact version.getArtifactFile
(String groupId, String artifactId, String version) Download an artifact file from the Maven repository system.
-
Constructor Details
-
MavenArtifactLoader
public MavenArtifactLoader()Creates a new artifact loader for 'jar' artifacts. -
MavenArtifactLoader
Creates a new artifact loader for artifacts.- Parameters:
extension
- The artifact extension. Must not be null.
-
-
Method Details
-
builder
Create a new version match builder to retrieve an artifact.- Parameters:
groupId
- The Apache Maven Group Id. Must not be null.artifactId
- The Apache Maven Artifact Id. Must not be null.- Returns:
- A
MavenVersionMatchBuilder
instance
-
getArtifactFile
Download an artifact file from the Maven repository system.- Parameters:
groupId
- The Apache Maven Group Id. Must not be null.artifactId
- The Apache Maven Artifact Id. Must not be null.version
- The Apache Maven Artifact version. Must not be null.- Returns:
- A file representing a successfully downloaded artifact.
- Throws:
IOException
- If the artifact could not be found or an IO problem happened while locating or downloading the artifact.
-
findLatestVersion
public String findLatestVersion(String groupId, String artifactId, String version) throws IOException Find a matching artifact version from a partially defined artifact version.Any located artifact in the repository system is compared to the version given.
Using this method is equivalent to callingbuilder(groupId, artifactId) .partialMatch(version) .extension(extension) .includeSnapshots(true) .findBestMatch();
but will throw an IOException if no version could be found.- Parameters:
groupId
- The Apache Maven Group Id. Must not be null.artifactId
- The Apache Maven Artifact Id. Must not be null.version
- A partial version string. Must not be null. An empty string matches any version.- Returns:
- The latest version that matches the partial version string. It either starts with the partial version string given (an empty version string matches any version) or is exactly the provided version.
- Throws:
IOException
- If an IO problem happened during artifact download or no versions were found during resolution.
-