Interface MinecraftExtension

All Known Subinterfaces:
MinecraftExtension.ForProject

public sealed interface MinecraftExtension permits MinecraftExtension.ForProject (not exhaustive)

The main extension for ForgeGradle, where the Minecraft dependency resolution takes place.

Restrictions

  • When declaring Minecraft dependencies, only module dependencies are supported.
    • The resulting Minecraft dependency is created by the Minecraft Mavenizer. It is not merely a dependency transformation, which means that it cannot use file and project dependencies to generate the Minecraft artifacts.
    • Attempting to provide a non-module dependency to MinecraftExtension.ForProject.dep(Object), will cause the build to fail.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    This interface contains the attributes used by the Minecraft extension for resolving the Minecraft and deobfuscated dependencies.
    static interface 
    Project-specific additions for the Minecraft extension.
    static final record 
    The mappings used for the Minecraft dependency.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The attributes object for easy reference.
    static final String
    The name for this extension in Gradle.
  • Method Summary

    Modifier and Type
    Method
    Description
    The current mappings that were defined in the buildscript.
    A closure for the generated Minecraft maven to be passed into RepositoryHandler.maven(Closure).
    void
    mappings(String channel, String version)
    Sets the mappings to use for the Minecraft Maven.
    default void
    mappings(Map namedArgs)
    Sets the mappings to use for the Minecraft Maven.
    default org.gradle.api.artifacts.repositories.MavenArtifactRepository
    maven(org.gradle.api.artifacts.dsl.RepositoryHandler repositories)
    Adds the generated Minecraft maven to the given repository handler.
  • Field Details

    • NAME

      static final String NAME
      The name for this extension in Gradle.
      See Also:
    • attributes

      static final MinecraftExtension.Attributes attributes
      The attributes object for easy reference.
      
       dependencies {
           implementation 'com.example:example:1.0' {
               attributes.attribute(minecraft.attributes.os, objects.named(OperatingSystemFamily, OperatingSystemFamily.WINDOWS))
           }
       }
       
      See Also:
  • Method Details

    • getMaven

      Closure getMaven()
      A closure for the generated Minecraft maven to be passed into RepositoryHandler.maven(Closure).

      Declaring this in your buildscript is required for the Minecraft dependencies to resolve properly.

      
       repositories {
           maven minecraft.maven
       }
       
      Returns:
      The closure
    • maven

      default org.gradle.api.artifacts.repositories.MavenArtifactRepository maven(org.gradle.api.artifacts.dsl.RepositoryHandler repositories)
      Adds the generated Minecraft maven to the given repository handler.
      
       minecraft.maven(repositories)
       
      Parameters:
      repositories - The repository handler to add the maven to
      Returns:
      The Minecraft maven
      See Also:
    • getMappings

      The current mappings that were defined in the buildscript.
      Returns:
      The current mappings
      Throws:
      NullPointerException - If no mappings were declared
      See Also:
    • mappings

      void mappings(String channel, String version)
      Sets the mappings to use for the Minecraft Maven.

      This method includes a generated named variant that can make declaration in your buildscript easier.

      
       minecraft {
           mappings channel: 'official', version: '1.21.5'
       }
       
      Parameters:
      channel - The mappings channel
      version - The mappings version
      Throws:
      IllegalArgumentException - If any parameter is null
      See Also:
      API Note:
      Mappings should only be declared once. A warning will be reported on re-declaration.
    • mappings

      @Contract default void mappings(Map namedArgs)

      Sets the mappings to use for the Minecraft Maven.

      This method is generated by Groovy in the implementing class, but has been included here for convenience and IDE support.

      Parameters:
      namedArgs - The named arguments
      Throws:
      IllegalArgumentException - If any parameter is null
      See Also:
      API Note:
      Mappings should only be declared once. A warning will be reported on re-declaration.