Class MinecraftResolverImpl
- java.lang.Object
-
- org.spongepowered.gradle.vanilla.repository.MinecraftResolverImpl
-
- All Implemented Interfaces:
MinecraftResolver,MinecraftResolver.Context
public class MinecraftResolverImpl extends java.lang.Object implements MinecraftResolver, MinecraftResolver.Context
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.gradle.vanilla.repository.MinecraftResolver
MinecraftResolver.Context, MinecraftResolver.MinecraftEnvironment
-
-
Field Summary
-
Fields inherited from interface org.spongepowered.gradle.vanilla.repository.MinecraftResolver
METADATA_VERSION, STORAGE_VERSION
-
-
Constructor Summary
Constructors Constructor Description MinecraftResolverImpl(VersionManifestRepository manifests, org.spongepowered.gradle.vanilla.resolver.Downloader downloader, java.nio.file.Path privateCache, java.util.concurrent.ExecutorService executor, java.util.function.Function<ResolvableTool,java.net.URL[]> toolResolver, boolean forceRefresh)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.function.Supplier<java.net.URLClassLoader>classLoaderWithTool(ResolvableTool tool)Return a child classloader with a tool and its dependencies on the classpath, as well as the VanillaGradle jar.org.spongepowered.gradle.vanilla.resolver.Downloaderdownloader()A downloader for resources, configured to resolve to the shared cache by default.java.util.concurrent.Executorexecutor()An executor for performing asynchronous operations.<T> TprocessSyncTasksUntilComplete(java.util.concurrent.CompletableFuture<T> future)Block on the completion of a provided future, processing "sync" tasks while that occurs.java.util.concurrent.CompletableFuture<org.spongepowered.gradle.vanilla.resolver.ResolutionResult<java.nio.file.Path>>produceAssociatedArtifact(MinecraftPlatform side, java.lang.String version, java.util.Set<ArtifactModifier> modifiers, java.lang.String id, java.util.Set<AssociatedResolutionFlags> flags, java.util.function.BiFunction<MinecraftResolver.MinecraftEnvironment,java.nio.file.Path,java.util.concurrent.CompletableFuture<?>> action)Given a standard Minecraft artifact, produce a variant of that artifact.java.util.concurrent.CompletableFuture<org.spongepowered.gradle.vanilla.resolver.ResolutionResult<MinecraftResolver.MinecraftEnvironment>>provide(MinecraftPlatform side, java.lang.String version)java.util.concurrent.CompletableFuture<org.spongepowered.gradle.vanilla.resolver.ResolutionResult<MinecraftResolver.MinecraftEnvironment>>provide(MinecraftPlatform side, java.lang.String version, java.util.Set<ArtifactModifier> modifiers)java.util.concurrent.ExecutorsyncExecutor()An executor for performing main-thread synchronous operations, like some dependency resolution.VersionManifestRepositoryversions()Get the version manifest repository managed by this resolver.
-
-
-
Constructor Detail
-
MinecraftResolverImpl
public MinecraftResolverImpl(VersionManifestRepository manifests, org.spongepowered.gradle.vanilla.resolver.Downloader downloader, java.nio.file.Path privateCache, java.util.concurrent.ExecutorService executor, java.util.function.Function<ResolvableTool,java.net.URL[]> toolResolver, boolean forceRefresh)
-
-
Method Detail
-
versions
public VersionManifestRepository versions()
Description copied from interface:MinecraftResolverGet the version manifest repository managed by this resolver.- Specified by:
versionsin interfaceMinecraftResolver- Specified by:
versionsin interfaceMinecraftResolver.Context- Returns:
- the resolver
-
downloader
public org.spongepowered.gradle.vanilla.resolver.Downloader downloader()
Description copied from interface:MinecraftResolver.ContextA downloader for resources, configured to resolve to the shared cache by default.- Specified by:
downloaderin interfaceMinecraftResolver.Context- Returns:
- the downloader instance
-
executor
public java.util.concurrent.Executor executor()
Description copied from interface:MinecraftResolver.ContextAn executor for performing asynchronous operations.- Specified by:
executorin interfaceMinecraftResolver.Context- Returns:
- the environment's executor
-
syncExecutor
public java.util.concurrent.Executor syncExecutor()
Description copied from interface:MinecraftResolver.ContextAn executor for performing main-thread synchronous operations, like some dependency resolution.- Specified by:
syncExecutorin interfaceMinecraftResolver.Context- Returns:
- the synchronous executor
-
classLoaderWithTool
public java.util.function.Supplier<java.net.URLClassLoader> classLoaderWithTool(ResolvableTool tool)
Description copied from interface:MinecraftResolver.ContextReturn a child classloader with a tool and its dependencies on the classpath, as well as the VanillaGradle jar.This is a very fragile arrangement but it allows some dependencies to be overridden at runtime. Classes from Gradle, VanillaGradle's dependencies, and the JDK can be safely shared, but VanillaGradle classes CAN NOT.
This must be run on the
MinecraftResolver.Context.syncExecutor().- Specified by:
classLoaderWithToolin interfaceMinecraftResolver.Context- Parameters:
tool- the tool to resolve- Returns:
- a class loader with the tool on the classpath
-
provide
public java.util.concurrent.CompletableFuture<org.spongepowered.gradle.vanilla.resolver.ResolutionResult<MinecraftResolver.MinecraftEnvironment>> provide(MinecraftPlatform side, java.lang.String version)
- Specified by:
providein interfaceMinecraftResolver
-
provide
public java.util.concurrent.CompletableFuture<org.spongepowered.gradle.vanilla.resolver.ResolutionResult<MinecraftResolver.MinecraftEnvironment>> provide(MinecraftPlatform side, java.lang.String version, java.util.Set<ArtifactModifier> modifiers)
- Specified by:
providein interfaceMinecraftResolver
-
produceAssociatedArtifact
public java.util.concurrent.CompletableFuture<org.spongepowered.gradle.vanilla.resolver.ResolutionResult<java.nio.file.Path>> produceAssociatedArtifact(MinecraftPlatform side, java.lang.String version, java.util.Set<ArtifactModifier> modifiers, java.lang.String id, java.util.Set<AssociatedResolutionFlags> flags, java.util.function.BiFunction<MinecraftResolver.MinecraftEnvironment,java.nio.file.Path,java.util.concurrent.CompletableFuture<?>> action)
Description copied from interface:MinecraftResolverGiven a standard Minecraft artifact, produce a variant of that artifact.This variant will synchronize back to the current thread before executing the provider function. This allows for operating in concurrency-sensitive environments, such as a Gradle build.
To de-duplicate resolution actions, a future may be returned if this action has already been performed, or is in process on another thread. In these cases, the provided provider function will not be executed at all.
- Specified by:
produceAssociatedArtifactin interfaceMinecraftResolver- Parameters:
side- the platform to base off ofversion- the version to base off ofmodifiers- any modifiers to complete the description of the provided argumentid- An identifier for this artifactflags- flags to configure this resolutionaction- the action needed to produce a variant, taking the input environment and a target path- Returns:
- a future returning the result of resolving a jar path
-
processSyncTasksUntilComplete
public <T> T processSyncTasksUntilComplete(java.util.concurrent.CompletableFuture<T> future) throws java.lang.InterruptedException, java.util.concurrent.ExecutionExceptionDescription copied from interface:MinecraftResolverBlock on the completion of a provided future, processing "sync" tasks while that occurs.- Specified by:
processSyncTasksUntilCompletein interfaceMinecraftResolver- Type Parameters:
T- the return value type- Parameters:
future- the future to await- Returns:
- the result of the future
- Throws:
java.lang.InterruptedException- if the thread executing the future is interruptedjava.util.concurrent.ExecutionException- if the task execution fails
-
-