SpongePowered / SpongeGradle

Handy gradle utilities for the various gradle projects of SpongePowered
MIT License
21 stars 16 forks source link

Ore plugin deployment #56

Closed zml2008 closed 1 year ago

zml2008 commented 1 year ago

Add a plugin to publish artifacts to Ore.

This plugin has no direct dependency on the plugin development plugin, so it could be used with, say, ForgeGradle for people who want to publish forge mods, or to publish API 7 plugins that don't use the modern SpongeGradle.

A typical plugin author buildscript will have something like:

oreDeployment.defaultPublication {
      // channel.set("Release") // optional, if a non-default channel is wanted
      if (project.hasProperty("changelog")) {
        versionBody.set(file(project.property("changelog")!!).readText(Charsets.UTF_8))
    }
}

The full extension looks something like:

oreDeployment {
  oreEndpoint("https://ore.spongepowered.org/") // default
  apiKey().set(providers.environmentVariable("ORE_TOKEN")) // default value

  publications {
    named("default") {
      projectId.set("id")
      createForumPost.set(true) // default
      versionBody.set("") // default empty
      channel.set("Release") // default
      publishArtifacts.from(tasks.jar.map { it.outputs }) // default when SpongeGradle is present
    }
  }
}

Future work could make it easier to publish to multiple ore hosts, but this allows one project to have multiple artifacts published at least.