Skip to content

Commit a04a118

Browse files
committed
Prepare Gradle plugin publishing
1 parent 6e20a3d commit a04a118

File tree

6 files changed

+97
-25
lines changed

6 files changed

+97
-25
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1+
name: Publish Gradle Plugin
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
GRADLE_PUBLISH_KEY: ${{ secrets.ORG_GRADLE_PUBLISH_KEY }}
15+
GRADLE_PUBLISH_SECRET: ${{ secrets.ORG_GRADLE_PUBLISH_SECRET }}
16+
17+
steps:
18+
- uses: actions/checkout@v6
19+
20+
- name: Setup Java
21+
uses: actions/setup-java@v5
22+
with:
23+
distribution: temurin
24+
java-version: 21
25+
26+
- name: Prepare release information
27+
run: |
28+
VERSION_NAME=$(grep "^gradle-plugin-version" gradle/gradle.versions.toml | cut -d '"' -f 2)
29+
RELEASE_TAG="gradle-plugin-$VERSION_NAME"
30+
31+
echo "VERSION_NAME=$VERSION_NAME"
32+
echo "RELEASE_TAG=$RELEASE_TAG"
33+
34+
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
35+
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
36+
37+
- name: Validate Plugin
38+
run: ./gradlew :tools:gradle-plugin:validatePlugins
39+
40+
- name: Publish to Gradle Plugin Portal
41+
run: |
42+
./gradlew :tools:gradle-plugin:publishPlugins \
43+
-Pgradle.publish.key="${GRADLE_PUBLISH_KEY}" \
44+
-Pgradle.publish.secret="${GRADLE_PUBLISH_SECRET}"
45+
46+
- name: Create GitHub release
47+
run: |
48+
gh release create ${{ env.RELEASE_TAG }} --generate-notes
149

DEVELOPMENT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Update changelog with new version: `./gradlew patchChangelog`
4040

4141
Build CLI: `./gradlew buildCLI`
4242

43+
## Gradle Plugin
44+
45+
Test plugin locally: `./gradlew :tools:gradle-plugin:publishToMavenLocal`
46+
4347
## WEB
4448

4549
- Run WASM: `./gradlew tools:compose-app:wasmJsBrowserDevelopmentRun`

gradle/gradle.versions.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[versions]
2+
gradle-plugin-version = "0.1.0"
3+
4+
agp = "8.13.1"
5+
6+
[libraries]
7+
agp-api = { module = "com.android.tools.build:gradle-api", version.ref = "agp" }
8+
agp-full = { module = "com.android.tools.build:gradle", version.ref = "agp" }
9+
10+
[plugins]
11+
plugin-publish = { id = "com.gradle.plugin-publish", version = "2.0.0" }
12+

gradle/libs.versions.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ semver = "net.swiftzer.semver:semver:2.1.0"
3939
ktlint = "com.pinterest.ktlint:ktlint-cli:1.8.0"
4040
composeRules = "io.nlopez.compose.rules:ktlint:0.4.28"
4141

42-
agp-api = { module = "com.android.tools.build:gradle-api", version.ref = "agp" }
43-
agp-full = { module = "com.android.tools.build:gradle", version.ref = "agp" }
44-
4542
# Dependencies for build-logic module
4643
kotlin-compose-compiler-plugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" }
4744
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }

settings.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ dependencyResolutionManagement {
4545
create("cli") {
4646
from(files("gradle/cli.versions.toml"))
4747
}
48+
create("gradlePluginVersions") {
49+
from(files("gradle/gradle.versions.toml"))
50+
}
4851
}
4952
}
5053
}

tools/gradle-plugin/build.gradle.kts

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,13 @@ plugins {
99
alias(libs.plugins.valkyrie.kover)
1010
alias(libs.plugins.valkyrie.abi)
1111
alias(libs.plugins.buildconfig)
12+
alias(libs.plugins.shadow)
13+
alias(gradlePluginVersions.plugins.plugin.publish)
1214
`java-gradle-plugin`
1315
}
1416

15-
tasks.validatePlugins {
16-
// TODO: https://github.com/gradle/gradle/issues/22600
17-
enableStricterValidation = true
18-
}
19-
20-
kotlin {
21-
compilerOptions {
22-
// https://docs.gradle.org/current/userguide/compatibility.html#kotlin
23-
apiVersion = KotlinVersion.KOTLIN_2_2
24-
languageVersion = apiVersion
25-
}
26-
}
17+
group = "io.github.composegears.valkyrie"
18+
version = gradlePluginVersions.versions.gradle.plugin.version.get()
2719

2820
gradlePlugin {
2921
vcsUrl = "https://github.com/ComposeGears/Valkyrie"
@@ -32,13 +24,29 @@ gradlePlugin {
3224
plugins {
3325
create("valkyrie") {
3426
id = "io.github.composegears.valkyrie"
35-
displayName = name
27+
displayName = "Valkyrie Gradle Plugin"
3628
implementationClass = "io.github.composegears.valkyrie.gradle.ValkyrieGradlePlugin"
37-
description = "Generates Kotlin accessors for ImageVectors, based on input SVG files"
38-
tags.addAll("kotlin", "svg", "xml", "imagevector", "valkyrie")
29+
description = "Convert SVG/XML icons into Compose ImageVector format"
30+
tags.addAll("kotlin", "svg", "xml", "imagevector", "valkyrie", "compose")
3931
}
4032
}
4133
}
34+
kotlin {
35+
compilerOptions {
36+
// https://docs.gradle.org/current/userguide/compatibility.html#kotlin
37+
apiVersion = KotlinVersion.KOTLIN_2_2
38+
languageVersion = apiVersion
39+
}
40+
}
41+
42+
tasks.validatePlugins {
43+
// TODO: https://github.com/gradle/gradle/issues/22600
44+
enableStricterValidation = true
45+
}
46+
47+
tasks.shadowJar {
48+
archiveClassifier = ""
49+
}
4250

4351
configurations.named(API_ELEMENTS_CONFIGURATION_NAME) {
4452
attributes.attribute(
@@ -82,19 +90,19 @@ tasks.pluginUnderTestMetadata {
8290
}
8391

8492
dependencies {
85-
compileOnly(libs.agp.api)
93+
compileOnly(gradlePluginVersions.agp.api)
8694
compileOnly(libs.kotlin.gradle.plugin)
8795

88-
api(projects.sdk.core.extensions)
89-
api(projects.sdk.ir.core)
90-
api(projects.components.generator.iconpack)
91-
api(projects.components.generator.jvm.imagevector)
92-
api(projects.components.parser.unified)
96+
implementation(projects.sdk.core.extensions)
97+
implementation(projects.sdk.ir.core)
98+
implementation(projects.components.generator.iconpack)
99+
implementation(projects.components.generator.jvm.imagevector)
100+
implementation(projects.components.parser.unified)
93101

94102
testImplementation(libs.bundles.test)
95103
testRuntimeOnly(libs.junit.launcher)
96104

97-
testPluginClasspath(libs.agp.full)
105+
testPluginClasspath(gradlePluginVersions.agp.full)
98106
testPluginClasspath(libs.kotlin.gradle.plugin)
99107
}
100108

0 commit comments

Comments
 (0)