Package de.julielab.utilities.aether
Class AetherUtilities
- java.lang.Object
-
- de.julielab.utilities.aether.AetherUtilities
-
public class AetherUtilities extends Object
Taken and adapted from: https://stackoverflow.com/questions/48537735/download-artifact-from-maven-repository-in-java-program
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAetherUtilities.Checksum
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MavenArtifactgetArtifactByAether(MavenArtifact artifact)static MavenArtifactgetArtifactByAether(MavenArtifact a, File localRepository)static MavenArtifactgetArtifactByAether(MavenArtifact a, File localRepository, boolean searchLocally)static Stream<org.eclipse.aether.artifact.Artifact>getDependencies(MavenArtifact requestedArtifact)Retrieves the dependency tree that hasrequestedArtifactas its root.static Stream<org.eclipse.aether.artifact.Artifact>getDependencies(MavenArtifact requestedArtifact, boolean recursiveCall)Retrieves the dependency tree that hasrequestedArtifactas its root.static Stream<org.eclipse.aether.artifact.Artifact>getDependencies(MavenArtifact dependencyTreeRoot, Stream<MavenArtifact> requestedArtifacts)static Stream<org.eclipse.aether.artifact.Artifact>getDependencies(Stream<MavenArtifact> requestedArtifacts)static StringgetNewestVersion(MavenArtifact requestedArtifact)Retrieves all available versions of the given artifact and returns the newest one or null, if no version is available.static List<org.eclipse.aether.resolution.MetadataResult>getRemoteArtifactMetadata(MavenArtifact a)Returns the results of metadata requests regarding the request coordinates represented by the passed MavenArtifact.static Optional<List<AetherUtilities.Checksum>>getRemoteChecksums(MavenArtifact artifact)static Stream<String>getVersions(MavenArtifact requestedArtifact)Returns all available versions of the given artifact.static Stream<String>getVersions(MavenArtifact requestedArtifact, String lowerBound, String upperBound, boolean lowerInclusive, boolean upperInclusive)Retrieves all versions of the given artifact - whose given version is ignored in this method - that are available within the described version range.static voidmain(String[] args)static voidstoreArtifactsWithDependencies(MavenArtifact dependencyTreeRoot, Stream<MavenArtifact> requestedArtifacts, File libDir)static voidstoreArtifactsWithDependencies(Stream<MavenArtifact> requestedArtifacts, File libDir)static voidstoreArtifactWithDependencies(MavenArtifact requestedArtifact, File libDir)
-
-
-
Method Detail
-
getRemoteChecksums
public static Optional<List<AetherUtilities.Checksum>> getRemoteChecksums(MavenArtifact artifact) throws MavenException
- Throws:
MavenException
-
getRemoteArtifactMetadata
public static List<org.eclipse.aether.resolution.MetadataResult> getRemoteArtifactMetadata(MavenArtifact a) throws MavenException
Returns the results of metadata requests regarding the request coordinates represented by the passed MavenArtifact.
Note that the passed artifact really only represents the expected location of the metadata to retrieve. Releases do not have metadata; snapshots have metadata and only the latest one will be returned. To get the meta data about the artifact regardless of its version, leave the version and packaging fields of the given MavenArtifact empty.
- Parameters:
a-- Returns:
- Throws:
MavenException
-
getArtifactByAether
public static MavenArtifact getArtifactByAether(MavenArtifact artifact) throws MavenException
- Throws:
MavenException
-
getArtifactByAether
public static MavenArtifact getArtifactByAether(MavenArtifact a, File localRepository) throws MavenException
- Throws:
MavenException
-
getArtifactByAether
public static MavenArtifact getArtifactByAether(MavenArtifact a, File localRepository, boolean searchLocally) throws MavenException
- Throws:
MavenException
-
storeArtifactWithDependencies
public static void storeArtifactWithDependencies(MavenArtifact requestedArtifact, File libDir) throws MavenException
- Throws:
MavenException
-
storeArtifactsWithDependencies
public static void storeArtifactsWithDependencies(Stream<MavenArtifact> requestedArtifacts, File libDir) throws MavenException
- Throws:
MavenException
-
storeArtifactsWithDependencies
public static void storeArtifactsWithDependencies(MavenArtifact dependencyTreeRoot, Stream<MavenArtifact> requestedArtifacts, File libDir) throws MavenException
- Throws:
MavenException
-
getDependencies
public static Stream<org.eclipse.aether.artifact.Artifact> getDependencies(MavenArtifact requestedArtifact) throws MavenException
Retrieves the dependency tree that hasrequestedArtifactas its root. Thus, therequestedArtifactis resolved itself and included in the returned artifacts.- Parameters:
requestedArtifact- The Maven artifact to retrieve dependencies for.- Returns:
- The resolved dependencies of
requestedArtifact, includingrequestedArtifactitself. - Throws:
MavenException- If an artifact cannot be found or another Maven related error occurs.
-
getVersions
public static Stream<String> getVersions(MavenArtifact requestedArtifact) throws MavenException
Returns all available versions of the given artifact.- Parameters:
requestedArtifact-- Returns:
- Throws:
MavenException
-
main
public static void main(String[] args) throws MavenException
- Throws:
MavenException
-
getVersions
public static Stream<String> getVersions(MavenArtifact requestedArtifact, String lowerBound, String upperBound, boolean lowerInclusive, boolean upperInclusive) throws MavenException
Retrieves all versions of the given artifact - whose given version is ignored in this method - that are available within the described version range.- Parameters:
requestedArtifact-lowerBound-upperBound-lowerInclusive-upperInclusive-- Returns:
- Throws:
MavenException
-
getNewestVersion
public static String getNewestVersion(MavenArtifact requestedArtifact) throws MavenException
Retrieves all available versions of the given artifact and returns the newest one or null, if no version is available.- Parameters:
requestedArtifact-- Returns:
- Throws:
MavenException
-
getDependencies
public static Stream<org.eclipse.aether.artifact.Artifact> getDependencies(Stream<MavenArtifact> requestedArtifacts) throws MavenException
- Throws:
MavenException
-
getDependencies
public static Stream<org.eclipse.aether.artifact.Artifact> getDependencies(MavenArtifact dependencyTreeRoot, Stream<MavenArtifact> requestedArtifacts) throws MavenException
- Throws:
MavenException
-
getDependencies
public static Stream<org.eclipse.aether.artifact.Artifact> getDependencies(MavenArtifact requestedArtifact, boolean recursiveCall) throws MavenException
Retrieves the dependency tree that hasrequestedArtifactas its root. Thus, therequestedArtifactis resolved itself and included in the returned artifacts.- Parameters:
requestedArtifact- The Maven artifact to retrieve dependencies for.- Returns:
- The resolved dependencies of
requestedArtifact, includingrequestedArtifactitself. - Throws:
MavenException- If an artifact cannot be found or another Maven related error occurs.
-
-