public class DependencyManager
extends java.lang.Object
| Constructor and Description |
|---|
DependencyManager(@NotNull DependencyPathProvider dependencyPathProvider)
Creates a
DependencyManager. |
DependencyManager(@NotNull java.nio.file.Path cacheDirectory)
Creates a
DependencyManager. |
| Modifier and Type | Method and Description |
|---|---|
void |
addDependency(@NotNull Dependency dependency)
Adds a dependency to this
DependencyManager. |
void |
addRelocation(@NotNull Relocation relocation)
Adds a relocation to this
DependencyManager. |
void |
cleanupCacheDirectory()
Removes files that are not known dependencies of this
DependencyManager from CleanupPathProvider.getCleanupPath() implementation. |
java.util.concurrent.CompletableFuture<java.lang.Void>[] |
download(@Nullable java.util.concurrent.Executor executor,
@NotNull java.util.List<Repository> repositories)
Download all the dependencies in this
DependencyManager. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
downloadAll(@Nullable java.util.concurrent.Executor executor,
@NotNull java.util.List<Repository> repositories)
Download all the dependencies in this
DependencyManager. |
@NotNull java.util.Set<java.nio.file.Path> |
getAllPaths(boolean includeRelocated)
Gets
Paths to all Dependencies in this DependencyManager,
optionally also including the relocated paths if includeRelocated is set to true. |
@NotNull java.util.List<Dependency> |
getDependencies()
Gets the dependencies in this
DependencyManager. |
@NotNull DependencyPathProvider |
getDependencyPathProvider()
Gets the dependency path provider for this DependencyManager.
|
@NotNull java.nio.file.Path |
getPathForDependency(@NotNull Dependency dependency,
boolean relocated)
Gets the
Path where the given Dependency will be stored once downloaded. |
@NotNull java.util.Set<Relocation> |
getRelocations()
Gets the relocations in this
DependencyManager. |
java.util.concurrent.CompletableFuture<java.lang.Void>[] |
load(@Nullable java.util.concurrent.Executor executor,
@NotNull ClasspathAppender classpathAppender)
Loads all the (potentially relocated) dependencies with provided
ClasspathAppender. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
loadAll(@Nullable java.util.concurrent.Executor executor,
@NotNull ClasspathAppender classpathAppender)
Loads all the (potentially relocated) dependencies with provided
ClasspathAppender. |
void |
loadFromResource(@NotNull java.util.List<java.lang.String> fileLines)
Loads dependencies and relocations from the resource generated by the gradle plugin.
|
void |
loadFromResource(@NotNull java.lang.String fileContents)
Loads dependencies and relocations from the resource generated by the gradle plugin.
|
void |
loadFromResource(@NotNull java.net.URL resourceURL)
Loads dependencies and relocations from the resource generated by the gradle plugin.
|
java.util.concurrent.CompletableFuture<java.lang.Void>[] |
relocate(@Nullable java.util.concurrent.Executor executor)
Relocates all the dependencies with the relocations in this
DependencyManager. |
java.util.concurrent.CompletableFuture<java.lang.Void>[] |
relocate(@Nullable java.util.concurrent.Executor executor,
@Nullable java.lang.ClassLoader jarRelocatorLoader)
Relocates all the dependencies with the relocations in this
DependencyManager. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
relocateAll(@Nullable java.util.concurrent.Executor executor)
Relocates all the dependencies with the relocations in this
DependencyManager. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
relocateAll(@Nullable java.util.concurrent.Executor executor,
@Nullable java.lang.ClassLoader jarRelocatorLoader)
Relocates all the dependencies with the relocations in this
DependencyManager. |
public DependencyManager(@NotNull
@NotNull java.nio.file.Path cacheDirectory)
DependencyManager.cacheDirectory - the directory used for downloaded and relocated dependencies.public DependencyManager(@NotNull
@NotNull DependencyPathProvider dependencyPathProvider)
DependencyManager.dependencyPathProvider - the dependencyPathProvider used for downloaded and relocated dependencies.public void addDependency(@NotNull
@NotNull Dependency dependency)
DependencyManager.dependency - the dependencyjava.lang.IllegalStateException - if this method is executed after downloading@NotNull public @NotNull java.util.List<Dependency> getDependencies()
DependencyManager.public void addRelocation(@NotNull
@NotNull Relocation relocation)
DependencyManager.relocation - the relocationjava.lang.IllegalStateException - if this method is executed after relocating@NotNull public @NotNull java.util.Set<Relocation> getRelocations()
DependencyManager.@NotNull public @NotNull DependencyPathProvider getDependencyPathProvider()
DependencyPathProvider or nullDependencyPathProviderpublic void loadFromResource(@NotNull
@NotNull java.net.URL resourceURL)
throws java.io.IOException
resourceURL - the url to the resourcejava.io.IOException - if the resource cannot be readpublic void loadFromResource(@NotNull
@NotNull java.lang.String fileContents)
fileContents - the contents of the file generated by the gradle plugin as a Stringpublic void loadFromResource(@NotNull
@NotNull java.util.List<java.lang.String> fileLines)
fileLines - all the lines from the file generated by the gradle pluginpublic java.util.concurrent.CompletableFuture<java.lang.Void> downloadAll(@Nullable
@Nullable java.util.concurrent.Executor executor,
@NotNull
@NotNull java.util.List<Repository> repositories)
DependencyManager.executor - the executor that will run the downloadsrepositories - an ordered list of repositories that will be tried one-by-onejava.lang.IllegalStateException - if dependencies have already been queued for download oncepublic java.util.concurrent.CompletableFuture<java.lang.Void>[] download(@Nullable
@Nullable java.util.concurrent.Executor executor,
@NotNull
@NotNull java.util.List<Repository> repositories)
DependencyManager.executor - the executor that will run the downloadsrepositories - an ordered list of repositories that will be tried one-by-oneCompletableFuture for each dependencyjava.lang.IllegalStateException - if dependencies have already been queued for download oncepublic java.util.concurrent.CompletableFuture<java.lang.Void> relocateAll(@Nullable
@Nullable java.util.concurrent.Executor executor)
DependencyManager. This step is not required.
Uses the ClassLoader that loaded this class to acquire jar-relocator.executor - the executor that will run the relocationsjava.lang.IllegalStateException - if dependencies have already been queued for relocation oncepublic java.util.concurrent.CompletableFuture<java.lang.Void> relocateAll(@Nullable
@Nullable java.util.concurrent.Executor executor,
@Nullable
@Nullable java.lang.ClassLoader jarRelocatorLoader)
DependencyManager. This step is not required.executor - the executor that will run the relocationsjarRelocatorLoader - the ClassLoader to use to load jar-relocator,
if this is set to null the current class loader will be usedjava.lang.IllegalStateException - if dependencies have already been queued for relocation oncepublic java.util.concurrent.CompletableFuture<java.lang.Void>[] relocate(@Nullable
@Nullable java.util.concurrent.Executor executor)
DependencyManager. This step is not required.
Uses the ClassLoader that loaded this class to acquire jar-relocator.executor - the executor that will run the relocationsCompletableFuture for each dependencyjava.lang.IllegalStateException - if dependencies have already been queued for relocation oncepublic java.util.concurrent.CompletableFuture<java.lang.Void>[] relocate(@Nullable
@Nullable java.util.concurrent.Executor executor,
@Nullable
@Nullable java.lang.ClassLoader jarRelocatorLoader)
DependencyManager. This step is not required.executor - the executor that will run the relocationsjarRelocatorLoader - the ClassLoader to use to load jar-relocatorCompletableFuture for each dependencyjava.lang.IllegalStateException - if dependencies have already been queued for relocation oncepublic java.util.concurrent.CompletableFuture<java.lang.Void> loadAll(@Nullable
@Nullable java.util.concurrent.Executor executor,
@NotNull
@NotNull ClasspathAppender classpathAppender)
ClasspathAppender.executor - the executor that will load the dependenciesclasspathAppender - the classpath appenderClasspathAppender otherwise completes when all dependencies are relocatedjava.lang.IllegalStateException - if dependencies have already been queued for load oncepublic java.util.concurrent.CompletableFuture<java.lang.Void>[] load(@Nullable
@Nullable java.util.concurrent.Executor executor,
@NotNull
@NotNull ClasspathAppender classpathAppender)
ClasspathAppender.executor - the executor that will load the dependenciesclasspathAppender - the classpath appenderCompletableFuture for each dependencyjava.lang.IllegalStateException - if dependencies have already been queued for load once@NotNull
public @NotNull java.nio.file.Path getPathForDependency(@NotNull
@NotNull Dependency dependency,
boolean relocated)
Path where the given Dependency will be stored once downloaded.dependency - the dependency.relocated - if the path should be for the relocated or unrelocated file of the Dependency@NotNull public @NotNull java.util.Set<java.nio.file.Path> getAllPaths(boolean includeRelocated)
Paths to all Dependencies in this DependencyManager,
optionally also including the relocated paths if includeRelocated is set to true.includeRelocated - if relocated paths should also be includedgetPathForDependency(Dependency, boolean)public void cleanupCacheDirectory()
throws java.io.IOException,
java.lang.IllegalStateException
DependencyManager from CleanupPathProvider.getCleanupPath() implementation.
This only accounts for dependencies that are included in this DependencyManager instance!
java.io.IOException - if listing files in the cache directory or deleting files in it failsjava.lang.IllegalStateException - if this DependencyManager's dependencyPathProvider isn't an instance of CleanupPathProvidergetAllPaths(boolean),
CleanupPathProvider