Skip to content

Commit 0b3140e

Browse files
authored
Refactor build logic (#203)
Co-authored-by: hfhbd <[email protected]>
1 parent b162b98 commit 0b3140e

File tree

13 files changed

+86
-32
lines changed

13 files changed

+86
-32
lines changed

.github/workflows/CD.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010

11+
env:
12+
GRADLE_OPTS: -Dorg.gradle.caching=true
13+
1114
steps:
1215
- uses: actions/checkout@v3
13-
- uses: gradle/wrapper-validation-action@v1
14-
- name: Set environment for version
15-
run: long="${{ github.ref }}"; version=${long#"refs/tags/v"}; echo "version=${version}" >> $GITHUB_ENV
1616
- uses: gradle/gradle-build-action@v2
17-
- name: Build all modules with Gradle
18-
run: ./gradlew build -Pversion=$version
1917
- name: Publish
20-
run: ./gradlew -Pversion=$version -Dorg.gradle.parallel=false publish closeAndReleaseStagingRepository
18+
run: ./gradlew -Pversion=${{ github.ref_name }} -Dorg.gradle.parallel=false publish closeAndReleaseStagingRepository
2119
env:
2220
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
2321
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

.github/workflows/CI.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
env:
16+
GRADLE_OPTS: -Dorg.gradle.caching=true
1217

1318
steps:
1419
- uses: actions/checkout@v3
15-
- uses: gradle/wrapper-validation-action@v1
1620
- uses: gradle/gradle-build-action@v2
21+
with:
22+
dependency-graph: generate-and-submit
23+
gradle-home-cache-cleanup: true
1724
- name: Build all modules with Gradle
1825
run: ./gradlew build
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Gradle Wrapper Validation
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'gradlew'
7+
- 'gradlew.bat'
8+
- 'gradle/wrapper/'
9+
10+
jobs:
11+
validateWrapper:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: gradle/wrapper-validation-action@v1

build-logic/build.gradle.kts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ plugins {
33
}
44

55
dependencies {
6-
val kotlin = "1.9.0"
7-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin")
8-
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlin")
9-
implementation("app.cash.licensee:licensee-gradle-plugin:1.7.0")
10-
implementation("org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin:0.13.2")
11-
implementation("org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:1.8.20")
6+
implementation(libs.plugins.kotlin.mpp.toDep())
7+
implementation(libs.plugins.kotlin.serialization.toDep())
8+
implementation(libs.plugins.licensee.toDep())
9+
implementation(libs.plugins.binary.toDep())
10+
implementation(libs.plugins.dokka.toDep())
11+
implementation(libs.plugins.publish.toDep())
1212
}
1313

1414
gradlePlugin {
@@ -19,3 +19,7 @@ gradlePlugin {
1919
}
2020
}
2121
}
22+
23+
fun Provider<PluginDependency>.toDep() = map {
24+
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}"
25+
}

build-logic/settings.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ dependencyResolutionManagement {
44
mavenCentral()
55
gradlePluginPortal()
66
}
7+
versionCatalogs.register("libs") {
8+
from(files("../gradle/libs.versions.toml"))
9+
}
710
}
811

912
rootProject.name = "build-logic"

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
2+
id("io.github.gradle-nexus.publish-plugin")
33
}
44

55
nexusPublishing {

cloudkitclient-core/build.gradle.kts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ plugins {
66

77
kotlin {
88
sourceSets {
9-
// Apache 2, https://github.com/ktorio/ktor/releases/latest
10-
val ktorVersion = "2.3.3"
119
commonMain {
1210
dependencies {
13-
api("io.ktor:ktor-client-core:$ktorVersion")
14-
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
15-
api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
11+
api(libs.ktor.client.core)
12+
api(libs.serialization.json)
13+
api(libs.datetime)
1614
}
1715
}
1816
commonTest {
1917
dependencies {
2018
implementation(kotlin("test"))
19+
implementation(libs.coroutines.test)
2120
}
2221
}
2322
named("jvmMain") {
2423
dependencies {
25-
api("io.ktor:ktor-client-cio:$ktorVersion")
24+
api(libs.ktor.client.cio)
2625
}
2726
}
2827
}

cloudkitclient-core/src/commonTest/kotlin/app/softwork/cloudkitclient/internal/SHA256Test.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package app.softwork.cloudkitclient.internal
22

3+
import kotlinx.coroutines.test.*
34
import kotlin.test.*
45

56
internal class SHA256Test {

cloudkitclient-core/src/commonTest/kotlin/app/softwork/cloudkitclient/internal/runTest.kt

Lines changed: 0 additions & 3 deletions
This file was deleted.

cloudkitclient-core/src/jvmTest/kotlin/app/softwork/cloudkitclient/internal/runTest.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)