Class MinecraftResolverImpl

    • 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

      • downloader

        public org.spongepowered.gradle.vanilla.resolver.Downloader downloader()
        Description copied from interface: MinecraftResolver.Context
        A downloader for resources, configured to resolve to the shared cache by default.
        Specified by:
        downloader in interface MinecraftResolver.Context
        Returns:
        the downloader instance
      • syncExecutor

        public java.util.concurrent.Executor syncExecutor()
        Description copied from interface: MinecraftResolver.Context
        An executor for performing main-thread synchronous operations, like some dependency resolution.
        Specified by:
        syncExecutor in interface MinecraftResolver.Context
        Returns:
        the synchronous executor
      • classLoaderWithTool

        public java.util.function.Supplier<java.net.URLClassLoader> classLoaderWithTool​(ResolvableTool tool)
        Description copied from interface: MinecraftResolver.Context
        Return 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:
        classLoaderWithTool in interface MinecraftResolver.Context
        Parameters:
        tool - the tool to resolve
        Returns:
        a class loader with the tool on the classpath
      • 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: MinecraftResolver
        Given 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:
        produceAssociatedArtifact in interface MinecraftResolver
        Parameters:
        side - the platform to base off of
        version - the version to base off of
        modifiers - any modifiers to complete the description of the provided argument
        id - An identifier for this artifact
        flags - flags to configure this resolution
        action - 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.ExecutionException
        Description copied from interface: MinecraftResolver
        Block on the completion of a provided future, processing "sync" tasks while that occurs.
        Specified by:
        processSyncTasksUntilComplete in interface MinecraftResolver
        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 interrupted
        java.util.concurrent.ExecutionException - if the task execution fails