Skip to content

Commit

Permalink
Enable Gradle Caching for plugin dev (#88)
Browse files Browse the repository at this point in the history
* Enable Gradle Caching for plugin dev
* add back -api dependency
* add gradle jar validation to ci
  • Loading branch information
Nava2 committed Aug 17, 2023
1 parent ecdc9a1 commit 08b39ce
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
23 changes: 12 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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.
}
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.gradle.configuration-cache=true
org.gradle.caching=true

0 comments on commit 08b39ce

Please sign in to comment.