From ac7ec227b02305c86f4b763a98011027a158ff08 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Tue, 7 Feb 2023 06:31:23 -0500 Subject: [PATCH] Gradle Plugin Portal --- .github/workflows/portal.yml | 23 +++++++++++++++ .github/workflows/publish.yml | 4 ++- build.gradle.kts | 28 +++++++++++++++++++ .../concrete/ConcretePluginPlugin.kt | 16 +++++++---- 4 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/portal.yml diff --git a/.github/workflows/portal.yml b/.github/workflows/portal.yml new file mode 100644 index 0000000..f1a6be8 --- /dev/null +++ b/.github/workflows/portal.yml @@ -0,0 +1,23 @@ +name: Gradle Plugin Portal +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Publish with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: publishPlugins + env: + GRADLE_PLUGIN_PUBLISHING_KEY: "${{ secrets.GRADLE_PLUGIN_PUBLISHING_KEY }}" + GRADLE_PLUGIN_PUBLISHING_SECRET: "${{ secrets.GRADLE_PLUGIN_PUBLISHING_SECRET }}" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 52a17c7..9820faf 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,7 +4,7 @@ on: branches: - main jobs: - build: + publish: runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -21,3 +21,5 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GITLAB_TOKEN: "${{ secrets.GITLAB_TOKEN }}" + GRADLE_PLUGIN_PUBLISHING_KEY: "${{ secrets.GRADLE_PLUGIN_PUBLISHING_KEY }}" + GRADLE_PLUGIN_PUBLISHING_SECRET: "${{ secrets.GRADLE_PLUGIN_PUBLISHING_SECRET }}" diff --git a/build.gradle.kts b/build.gradle.kts index a6341a1..4384e52 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ +@file:Suppress("UnstableApiUsage") plugins { `kotlin-dsl` kotlin("plugin.serialization") version "1.7.10" @@ -25,29 +26,56 @@ dependencies { } gradlePlugin { + website.set("https://github.com/GayPizzaSpecifications/concrete") + vcsUrl.set("https://github.com/GayPizzaSpecifications/concrete") + plugins { create("concrete-root") { id = "gay.pizza.foundation.concrete-root" implementationClass = "gay.pizza.foundation.concrete.ConcreteRootPlugin" + + displayName = "Concrete Root" + description = "Concrete project root." } create("concrete-base") { id = "gay.pizza.foundation.concrete-base" implementationClass = "gay.pizza.foundation.concrete.ConcreteBasePlugin" + + displayName = "Concrete Base" + description = "Concrete project base." } create("concrete-library") { id = "gay.pizza.foundation.concrete-library" implementationClass = "gay.pizza.foundation.concrete.ConcreteLibraryPlugin" + + displayName = "Concrete Library" + description = "Concrete project library." } create("concrete-plugin") { id = "gay.pizza.foundation.concrete-plugin" implementationClass = "gay.pizza.foundation.concrete.ConcretePluginPlugin" + + displayName = "Concrete Library" + description = "Concrete project plugin." + } + + forEach { declaration -> + declaration.tags.set(listOf("foundation-concrete", "minecraft-bukkit")) } } } +val gradlePublishingKey: String? = System.getenv("GRADLE_PLUGIN_PUBLISHING_KEY") +val gradlePublishingSecret: String? = System.getenv("GRADLE_PLUGIN_PUBLISHING_SECRET") + +if (gradlePublishingKey != null && gradlePublishingSecret != null) { + project.setProperty("gradle.publish.key", gradlePublishingKey.toString()) + project.setProperty("gradle.publish.secret", gradlePublishingSecret.toString()) +} + java { val version = JavaVersion.toVersion("17") sourceCompatibility = version diff --git a/src/main/kotlin/gay/pizza/foundation/concrete/ConcretePluginPlugin.kt b/src/main/kotlin/gay/pizza/foundation/concrete/ConcretePluginPlugin.kt index 08f9cea..277b7ff 100644 --- a/src/main/kotlin/gay/pizza/foundation/concrete/ConcretePluginPlugin.kt +++ b/src/main/kotlin/gay/pizza/foundation/concrete/ConcretePluginPlugin.kt @@ -11,12 +11,16 @@ class ConcretePluginPlugin : ConcreteBaseBukkitPlugin() { project.plugins.apply("com.github.johnrengelman.shadow") - project.tasks.find("processResources")!!.apply { - val props = mapOf("version" to project.version.toString()) - inputs.properties(props) - filteringCharset = "UTF-8" - filesMatching("plugin.yml") { - expand(props) + // During IDEA project import, if this code is active, it will print warnings. + // This will make the VERSION field unexpanded if you run using the IntelliJ build system. + if (!project.properties.containsKey("idea.gradle.do.not.build.tasks")) { + project.tasks.find("processResources")!!.apply { + val props = mapOf("version" to project.version.toString()) + inputs.properties(props) + filteringCharset = "UTF-8" + filesMatching("plugin.yml") { + expand(props) + } } }