From 08b39ce286ce736277f4aa4bbd21de9488ccd087 Mon Sep 17 00:00:00 2001 From: Kevin Brightwell Date: Thu, 17 Aug 2023 07:16:41 -0400 Subject: [PATCH] Enable Gradle Caching for plugin dev (#88) * Enable Gradle Caching for plugin dev * add back -api dependency * add gradle jar validation to ci --- .github/workflows/ci.yml | 2 ++ build.gradle.kts | 23 ++++++++++++----------- config/detekt-config.yml => detekt.yaml | 0 gradle.properties | 2 ++ 4 files changed, 16 insertions(+), 11 deletions(-) rename config/detekt-config.yml => detekt.yaml (100%) create mode 100644 gradle.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3344f53..f0b3225 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,8 @@ jobs: - uses: actions/checkout@v3 + - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/gradle-build-action@v2 with: gradle-version: ${{ matrix.gradle-version }} diff --git a/build.gradle.kts b/build.gradle.kts index 5dd43e1..50725ce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,21 +14,21 @@ plugins { } val setupPluginUpload by tasks.registering { - if (System.getenv("GITHUB_ACTION") == null) return@registering + if (!providers.environmentVariable("GITHUB_ACTION").isPresent) return@registering - val key = System.getenv(GRADLE_PUBLISH_KEY_ENV) ?: System.getProperty(GRADLE_PUBLISH_KEY) - val secret = System.getenv(GRADLE_PUBLISH_SECRET_ENV) ?: System.getProperty(GRADLE_PUBLISH_SECRET) + val key = providers.environmentVariable(GRADLE_PUBLISH_KEY_ENV) + .orElse(providers.systemProperty(GRADLE_PUBLISH_KEY)) - if (key == null || secret == null) { - error("GRADLE_PUBLISH_KEY and/or GRADLE_PUBLISH_SECRET are not defined environment variables") - } + val secret = providers.environmentVariable(GRADLE_PUBLISH_SECRET_ENV) + .orElse(providers.systemProperty(GRADLE_PUBLISH_SECRET)) - System.setProperty(GRADLE_PUBLISH_KEY, key) - System.setProperty(GRADLE_PUBLISH_SECRET, secret) + if (!key.isPresent || !secret.isPresent) { + error("GRADLE_PUBLISH_KEY and/or GRADLE_PUBLISH_SECRET are not defined environment or system variables") + } // This is the git tag for a release - val githubRefName = System.getenv("GITHUB_REF_NAME")?.trimStart('v') - version = checkNotNull(githubRefName) { "No GITHUB_REF_NAME env value defined" } + val githubRefName = providers.environmentVariable("GITHUB_REF_NAME").map { it.trimStart('v') } + version = checkNotNull(githubRefName.orNull) { "No GITHUB_REF_NAME env value defined" } } tasks.named("publishPlugins") { @@ -72,6 +72,7 @@ dependencies { val kotlinVersion = "1.6.21" implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kotlinVersion") testCompileOnly("org.jetbrains:annotations:24.0.1") @@ -109,7 +110,7 @@ detekt { autoCorrect = true buildUponDefaultConfig = true // preconfigure defaults - config.from("$rootDir/config/detekt-config.yml") + config.from("$rootDir/detekt.yaml") allRules = false // activate all available (even unstable) rules. } diff --git a/config/detekt-config.yml b/detekt.yaml similarity index 100% rename from config/detekt-config.yml rename to detekt.yaml diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..5581b6c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.configuration-cache=true +org.gradle.caching=true