Skip to content

Commit

Permalink
bumps and switch to version catalogs - fixes #479 (#480)
Browse files Browse the repository at this point in the history
* bumps and switch to version catalogs - fixes #479

* gradle action

* more version catalog and better testing

* depend on correct publishing

* docker mac

* only docker on mac

* ergg mac

* fix typo

* try this way

* omg
  • Loading branch information
jamesward authored Dec 14, 2023
1 parent 936c710 commit 8429b87
Show file tree
Hide file tree
Showing 26 changed files with 375 additions and 209 deletions.
44 changes: 11 additions & 33 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,25 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
java: ['8', '11', '17']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
java-version: '11'
cache: 'gradle'

- name: Build Library
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 5
command: |
./gradlew build
- name: Publish to Maven Local
run: ./gradlew publishToMavenLocal
- uses: gradle/gradle-build-action@v2

- name: Build Examples
if: matrix.java == '17'
run: ./gradlew build
working-directory: ./examples
- name: Setup docker (missing on MacOS)
if: matrix.os == 'macos-latest'
run: |
brew install docker
colima start
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
- id: test-data
name: Run HelloWorld
if: matrix.java == '17'
working-directory: ./examples
run: |-
./gradlew :server:HelloWorldServer &
sleep 30
OUTPUT=$(./gradlew :client:HelloWorldClient)
echo "stdout=${OUTPUT//$'\n'/'%0A'}" >> $GITHUB_OUTPUT
- name: Test HelloWorld
if: matrix.java == '17'
uses: nick-invision/assert-action@v1
with:
expected: "Received: Hello world"
actual: ${{ steps.test-data.outputs.stdout }}
comparison: contains
- name: Test
run: |
./gradlew test
47 changes: 0 additions & 47 deletions .github/workflows/gradle_arm.yaml

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
java-version: '11'
cache: 'gradle'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: release
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
Expand Down
30 changes: 22 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.8.0" apply false
id("com.google.protobuf") version "0.9.4" apply false
id("org.gradle.test-retry") version "1.5.7"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.test.retry)
alias(libs.plugins.publish.plugin)
alias(libs.plugins.qoomon.git.versioning)
}

group = "io.grpc"
version = "1.4.1" // CURRENT_GRPC_KOTLIN_VERSION

ext["grpcVersion"] = "1.57.2"
ext["protobufVersion"] = "3.24.1"
ext["coroutinesVersion"] = "1.7.3"
gitVersioning.apply {
refs {
tag("v(?<version>.*)") {
version = "\${ref.version}"
}
}

rev {
version = "\${commit}"
}
}

subprojects {

Expand Down Expand Up @@ -94,6 +102,12 @@ subprojects {
)
}

extensions.getByType<PublishingExtension>().repositories {
maven {
url = uri(rootProject.layout.buildDirectory.dir("maven-repo"))
}
}

extensions.getByType<PublishingExtension>().publications {
create<MavenPublication>("maven") {
pom {
Expand Down
33 changes: 20 additions & 13 deletions compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,34 @@ application {
mainClass.set("io.grpc.kotlin.generator.GeneratorRunner")
}

java {
withSourcesJar()
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

dependencies {
// Kotlin and Java
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.ext["coroutinesVersion"]}")
implementation(libs.kotlinx.coroutines.core)

// Grpc and Protobuf
implementation(project(":stub"))
implementation("io.grpc:grpc-protobuf:${rootProject.ext["grpcVersion"]}")
implementation(libs.grpc.protobuf)

// Misc
implementation(kotlin("reflect"))
implementation("com.squareup:kotlinpoet:1.15.1")
implementation("com.google.truth:truth:1.1.5")
implementation(libs.kotlinpoet)
implementation(libs.truth)

// Testing
testImplementation("junit:junit:4.13.2")
testImplementation("com.google.guava:guava:32.1.3-jre")
testImplementation("com.google.jimfs:jimfs:1.3.0")
testImplementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.1")
testImplementation("org.mockito:mockito-core:4.11.0")
testImplementation(libs.junit)
testImplementation(libs.guava)
testImplementation(libs.jimfs)
testImplementation(libs.protobuf.gradle.plugin)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.junit.jupiter.engine)
testImplementation(libs.mockito.core)
}

tasks.jar {
Expand Down Expand Up @@ -65,11 +72,11 @@ publishing {

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${rootProject.ext["protobufVersion"]}"
artifact = libs.protoc.asProvider().get().toString()
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:${rootProject.ext["grpcVersion"]}"
artifact = libs.protoc.gen.grpc.java.get().toString()
}
id("grpckt") {
path = tasks.jar.get().archiveFile.get().asFile.absolutePath
Expand Down
22 changes: 10 additions & 12 deletions examples/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
plugins {
id("com.android.application")
kotlin("android")
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
}

val composeVersion = "1.5.4"
val composeCompilerVersion = "1.5.4"

dependencies {
implementation(project(":stub-android"))
implementation("androidx.activity:activity-compose:1.8.2")
implementation("androidx.compose.foundation:foundation-layout:$composeVersion")
implementation("androidx.compose.material:material:$composeVersion")
implementation("androidx.compose.runtime:runtime:$composeVersion")
implementation("androidx.compose.ui:ui:$composeVersion")

runtimeOnly("io.grpc:grpc-okhttp:${rootProject.ext["grpcVersion"]}")
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.compose.foundation.layout)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.ui)

runtimeOnly(libs.grpc.okhttp)
}

kotlin {
Expand Down Expand Up @@ -46,6 +44,6 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion = composeCompilerVersion
kotlinCompilerExtensionVersion = libs.androidx.compose.compiler.get().version
}
}
22 changes: 6 additions & 16 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
plugins {
id("com.android.application") version "8.1.1" apply false
id("com.google.protobuf") version "0.9.4" apply false
kotlin("jvm") version "1.9.20" apply false
id("org.jlleitschuh.gradle.ktlint") version "11.6.1" apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.ktlint) apply false
}

// todo: move to subprojects, but how?
ext["grpcVersion"] = "1.57.2"
ext["grpcKotlinVersion"] = "1.4.1" // CURRENT_GRPC_KOTLIN_VERSION
ext["protobufVersion"] = "3.24.1"
ext["coroutinesVersion"] = "1.7.3"

subprojects {
repositories {
mavenLocal() // For testing new releases of gRPC Kotlin
mavenCentral()
google()
}

apply(plugin = "org.jlleitschuh.gradle.ktlint")

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
Expand Down
4 changes: 2 additions & 2 deletions examples/client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
application
kotlin("jvm")
alias(libs.plugins.kotlin.jvm)
}

kotlin {
Expand All @@ -9,7 +9,7 @@ kotlin {

dependencies {
implementation(project(":stub"))
runtimeOnly("io.grpc:grpc-netty:${rootProject.ext["grpcVersion"]}")
runtimeOnly(libs.grpc.netty)
}

tasks.register<JavaExec>("HelloWorldClient") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class HelloWorldClient(private val channel: ManagedChannel) : Closeable {
* greets "world" otherwise.
*/
suspend fun main(args: Array<String>) {
val port = 50051
val port = System.getenv("PORT")?.toInt() ?: 50051

val channel = ManagedChannelBuilder.forAddress("localhost", port).usePlaintext().build()

Expand Down
35 changes: 35 additions & 0 deletions examples/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[plugins]
android-application = { id = "com.android.application", version = "8.2.0" }
android-library = { id = "com.android.library", version = "8.2.0" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.21" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version = "1.9.21" }
protobuf = { id = "com.google.protobuf", version = "0.9.4" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "11.6.1" }
palantir-graal = { id = "com.palantir.graal", version = "0.12.0" }
jib = { id = "com.google.cloud.tools.jib", version = "3.4.0" }

[libraries]
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.7.3" }
grpc-protobuf = { group = "io.grpc", name = "grpc-protobuf", version = "1.60.0" }
grpc-protobuf-lite = { group = "io.grpc", name = "grpc-protobuf-lite", version = "1.60.0" }
grpc-netty = { group = "io.grpc", name = "grpc-netty", version = "1.60.0" }
grpc-okhttp = { group = "io.grpc", name = "grpc-okhttp", version = "1.60.0" }
grpc-testing = { group = "io.grpc", name = "grpc-testing", version = "1.60.0" }
grpc-stub = { group = "io.grpc", name = "grpc-stub", version = "1.60.0" }
grpc-kotlin-stub = { group = "io.grpc", name = "grpc-kotlin-stub", version = "1.4.1" }

protoc = { group = "com.google.protobuf", name = "protoc", version = "3.24.1" }
protobuf-kotlin = { group = "com.google.protobuf", name = "protobuf-kotlin", version = "3.24.1" }
protobuf-kotlin-lite = { group = "com.google.protobuf", name = "protobuf-kotlin-lite", version = "3.24.1" }
protobuf-java-util = { group = "com.google.protobuf", name = "protobuf-java-util", version = "3.24.1" }
protoc-gen-grpc-java = { group = "io.grpc", name = "protoc-gen-grpc-java", version = "1.60.0" }
protoc-gen-grpc-kotlin = { group = "io.grpc", name = "protoc-gen-grpc-kotlin", version = "1.4.1" }

androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version = "1.8.2" }
androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout", version = "1.5.4" }
androidx-compose-material = { group = "androidx.compose.material", name = "material", version = "1.5.4" }
androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime", version = "1.5.4" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui", version = "1.5.4" }
androidx-compose-compiler = { group = "androidx.compose.compiler", name = "compiler", version = "1.5.6" }

kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version = "1.9.21" }
2 changes: 1 addition & 1 deletion examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 4 additions & 3 deletions examples/native-client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
application
kotlin("jvm")
id("com.palantir.graal") version "0.12.0"
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.palantir.graal)
}

kotlin {
Expand All @@ -10,7 +10,8 @@ kotlin {

dependencies {
implementation(project(":stub-lite"))
runtimeOnly("io.grpc:grpc-okhttp:${rootProject.ext["grpcVersion"]}")

runtimeOnly(libs.grpc.okhttp)
}

application {
Expand Down
Loading

0 comments on commit 8429b87

Please sign in to comment.