Class Publisher

java.lang.Object
io.github.smootheez.Publisher
Direct Known Subclasses:
CurseforgePublisher, ModrinthPublisher

public abstract class Publisher extends Object
Base abstraction for all publishing implementations within the Mc-Mod-Publisher Gradle plugin. Concrete subclasses provide the logic necessary to publish a project to a specific platform such as CurseForge, Modrinth, or other distribution services.

This class centralizes shared components needed by all publishers:

  • Project — the Gradle project instance
  • McModPublisherExtension — user-defined configuration
  • OkHttpClient — HTTP client for performing network requests
  • Gson — serializer for JSON payloads

Implementations must define the publish() method, which encapsulates the complete publishing workflow, including:

  • reading configuration
  • preparing request payloads
  • executing HTTP calls
  • handling responses and logging

This class is designed to be extended and used by Gradle tasks or other orchestration components inside the plugin.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final okhttp3.OkHttpClient
    HTTP client used to send HTTP requests to external publishing platforms.
    protected final McModPublisherExtension
    Global extension containing configuration values supplied by users via Gradle DSL.
    protected static final com.google.gson.Gson
    Shared Gson instance for serializing and deserializing JSON payloads.
    protected final org.gradle.api.Project
    The current Gradle project, used for logging and access to build information.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Executes the publishing workflow for a specific platform.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • project

      protected final org.gradle.api.Project project
      The current Gradle project, used for logging and access to build information.
    • extension

      protected final McModPublisherExtension extension
      Global extension containing configuration values supplied by users via Gradle DSL.
    • client

      protected final okhttp3.OkHttpClient client
      HTTP client used to send HTTP requests to external publishing platforms.
    • GSON

      protected static final com.google.gson.Gson GSON
      Shared Gson instance for serializing and deserializing JSON payloads.
  • Constructor Details

    • Publisher

      public Publisher()
  • Method Details

    • publish

      public abstract void publish()
      Executes the publishing workflow for a specific platform.

      Implementations must provide the complete logic required to:

      • validate configuration
      • prepare metadata and artifacts
      • send requests to the remote API
      • handle failures and log results

      This method is expected to be invoked from a Gradle task or another orchestrator responsible for running publishing actions.