Class UploadArtifact

java.lang.Object
net.darkhax.curseforgegradle.UploadArtifact

public class UploadArtifact extends Object
This class defines the script-time representation of an artifact being published to CurseForge. Users will directly configure this object through their script when defining a new file to upload.
  • Field Details

    • changelog

      public Object changelog
      An optional changelog for this file. This is displayed on the CurseForge website, and it's use is highly recommended. For best results this should be defined using a UTF-8 string.

      When a sub file is created using withAdditionalFile(Object) it will inherit the current changelog value. This can still be changed independently after creation.

    • changelogType

      public Object changelogType
      The type of changelog being defined. CurseForge supports various formats such as markdown and HTML however the default format is plaintext.

      When a sub file is created using withAdditionalFile(Object) it will inherit the current changelog type. This can still be changed independently after creation.

    • displayName

      public Object displayName
      The display name for the file on CurseForge. When defined this will hide the name of the file on CurseForge. The use of this property is generally discouraged.
    • gameVersions

      public Set<String> gameVersions
      A set of game versions associated with the artifact. At least one game version is required to upload an artifact. Additional meta tags like Java version or Loader version are also considered game versions by CurseForge and are added here.

      Sub files automatically inherit the game versions of their parent file. This is a hard limit enforced by the CurseForge API and can not be changed after the fact.

    • releaseType

      public Object releaseType
      The type of release for this file. The default release type is an alpha. When using something like CI to automate bleeding edge releases it is recommended to retain the alpha release type.

      When a sub file is created using withAdditionalFile(Object) it will inherit the current release type. This can still be changed independently after creation.

  • Constructor Details

    • UploadArtifact

      protected UploadArtifact(Object artifact, Long projectId, org.gradle.api.model.ObjectFactory objectFactory, org.gradle.api.logging.Logger log, @Nullable UploadArtifact parent)
      These are created using a helper method from TaskPublishCurseForge. Users should never construct this manually.
      Parameters:
      artifact - The artifact to publish. This is not necessarily a file and may not be valid until later in the build process.
      projectId - The ID of the project to publish this artifact to.
      objectFactory - The project-local object factory.
      log - A logger used to help with debugging. This is taken from the Task that define the artifact and is unique to each task.
      parent - An optional parent artifact. When defined the current artifact is treated as a child/additional/sub file.
  • Method Details

    • getArtifact

      @InputFiles public org.gradle.api.file.FileCollection getArtifact()
    • withAdditionalFile

      public UploadArtifact withAdditionalFile(Object file)
      Creates a new additional file that will be uploaded along with this main file. These files are sometimes called child files or sub files. Only parent files can have additional files. Attempting to create an additional file on another additional file is unsupported.

      By default additional files will copy the changelog, changelog type, release type, and project relations from the parent. Properties copied to an additional file can be modified after the fact however some properties like game versions are exclusively defined by the parent file.

      Parameters:
      file - The file to publish.
      Returns:
      An object that represents the artifact being published. This can be used to perform additional configuration such as defining a changelog.
    • addIncompatibility

      public void addIncompatibility(Object... slugs)
      Marks another project as being incompatible with this file. This will warn users not to use that project with yours. It may also prevent that project from being installed with a launcher when this file is already installed.
      Parameters:
      slugs - The slugs of the incompatible projects.
    • addRequirement

      public void addRequirement(Object... slugs)
      Marks another project as being required for this file to work properly. This will advise users to download the required project when they download this file. It may also cause the latest compatible version of that project to be installed automatically when this file is installed through a launcher.
      Parameters:
      slugs - The slug of the required projects.
    • addEmbedded

      public void addEmbedded(Object... slugs)
      Marks another project as being embedded within this file.
      Parameters:
      slugs - The slugs of the embedded projects.
    • addTool

      public void addTool(Object... slugs)
      Marks another project as being a tool for this file. Nobody seems to know what this means.
      Parameters:
      slugs - The slugs of the tool projects.
    • addOptional

      public void addOptional(Object... slugs)
      Marks another project as being optional. This is used to let users know that this file has special support for another project or works really well with that project.
      Parameters:
      slugs - The slugs of the optional projects.
    • addModLoader

      public void addModLoader(Object... modloaders)
      Marks the file as supporting a given modloader. This is primarily used by Minecraft for the Forge, Fabric, and Rift loaders.
      Parameters:
      modloaders - The modloaders that are supported by this file.
    • addEnvironment

      public void addEnvironment(Object... environments)
      Marks the file as supporting a given environment.
      Parameters:
      environments - The supported environments.
    • addJavaVersion

      public void addJavaVersion(Object... javaVersions)
      Marks the file as supporting the given Java versions.
      Parameters:
      javaVersions - The java versions that are supported.
    • addGameVersion

      public void addGameVersion(Object... gameVersions)
      Marks the file as supporting a given game versions.
      Parameters:
      gameVersions - The game versions supported by this file.
    • addRelations

      public void addRelations(Object type, Object... slugs)
      Adds a relationship between this artifact and multiple other projects on CurseForge. This can have different connotations depending on the game and the platform consuming this data. For example in the case of a Minecraft mod defining a required dependency relationship will cause the official CurseForge launcher to automatically download a valid version of that project when this file is requested.
      Parameters:
      type - The type of relationship to define.
      slugs - The slug of the project to define a relationship with.
    • addRelation

      public void addRelation(Object slug, Object type, Object id)
      Adds a relationship between this artifact and another project on CurseForge. This can have different connotations depending on the game and the platform consuming this data. For example in the case of a Minecraft mod defining a required dependency relationship will cause the official CurseForge launcher to automatically download a valid version of that project when this file is requested.
      Parameters:
      slug - The slug of the project to define a relationship with.
      type - The type of relationship to define.
      id - The exact id of the project.
    • addRelation

      public void addRelation(Object slug, Object type)
    • prepareForUpload

      public final void prepareForUpload(GameVersions validGameVersions)
      Prepares the artifact for being uploaded. This will resolve some configured properties into a format consumable by the API. This is intended for internal use.
      Parameters:
      validGameVersions - The valid game version data from the API.
    • logUploadMetadata

      public final void logUploadMetadata(String endpoint)
      Logs the URI this artifact would be uploaded to as well as the metadata for this artifact.
      Parameters:
      endpoint - The endpoint to upload the file to.
    • beginUpload

      public final void beginUpload(String endpoint, String token)
      Triggers the post request to the API that will begin the upload of the artifact. This is intended for internal use.
      Parameters:
      endpoint - The endpoint to upload the file to.
      token - The CurseForge API token used to authenticate the upload.
    • getAdditionalArtifacts

      public final Collection<UploadArtifact> getAdditionalArtifacts()
      Provides an immutable collection of additional artifacts for this file. This is intended for internal use only.
      Returns:
      An immutable collection of additional artifacts.
    • getCurseFileId

      @Nullable public Long getCurseFileId()