Skip to content

Commit

Permalink
Migrate all buildfiles to Gradle Kotlin DSL (#1994)
Browse files Browse the repository at this point in the history
* maestro-orchestra: rewrite buildscript to KTS

* bump protobuf and grpc versions

* maestro-client: rewrite buildscript to KTS

* maestro-orchestra: rewrite buildscript to KTS

* maestro-ios: rewrite buildscript to KTS

* maestro-android: rewrite buildscript to KTS

* fix protobuf/grpc setup

* rewrite the rest, standarize maven publishing config
  • Loading branch information
bartekpacia authored Aug 31, 2024
1 parent 0357b5e commit 3ee902e
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 248 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.mavenPublish)
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ detekt = "1.19.0"
googleFindbugs = "3.0.2"
googleGson = "2.11.0"
googleProtobuf = "3.21.9"
googleProtobufPlugin = "0.9.1"
googleProtobufPlugin = "0.9.4"
googleTruth = "1.4.2"
graaljs = "22.0.0" # Latest version that supports Java 8
grpc = "1.50.2"
grpcKotlinStub = "1.3.0"
grpcKotlinStub = "1.4.1"
imageComparison = "4.4.0"
hiddenapibypass = "4.3"
jackson = "2.17.1"
Expand Down
7 changes: 3 additions & 4 deletions maestro-ai/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
Expand All @@ -13,10 +14,8 @@ application {
mainClass.set("maestro.ai.DemoAppKt")
}

plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = com.vanniktech.maven.publish.SonatypeHost.S01
}
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01)
}

tasks.named<Jar>("jar") {
Expand Down
162 changes: 0 additions & 162 deletions maestro-android/build.gradle

This file was deleted.

166 changes: 166 additions & 0 deletions maestro-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.protobuf)
}

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${libs.versions.googleProtobuf.get()}"
}

plugins {
create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:${libs.versions.grpc.get()}"
}
}

generateProtoTasks {
all().forEach { task ->
task.plugins {
create("grpc") { option("lite") }
}

task.builtins {
create("java") { option("lite") }
create("kotlin") { option("lite") }
}
}
}
}

kotlin.sourceSets.configureEach {
// Prevent build warnings for grpc's generated opt-in code
languageSettings.optIn("kotlin.RequiresOptIn")
}

android {
namespace = "dev.mobile.maestro"
compileSdk = 34

defaultConfig {
applicationId = "dev.mobile.maestro"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
named("release") {
isMinifyEnabled = false

proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}

named("debug") {
signingConfig = signingConfigs.getByName("debug")
}
}

signingConfigs {
named("debug") {
storeFile = file("../debug.keystore")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

packagingOptions {
resources {
excludes += listOf("META-INF/INDEX.LIST", "META-INF/io.netty.versions.properties")
}
}
}

tasks.register<Copy>("copyMaestroAndroid") {
val maestroAndroidApkPath = "outputs/apk/debug/maestro-android-debug.apk"
val maestroAndroidApkDest = "../../maestro-client/src/main/resources"
val maestroAndroidApkDestPath = "../../maestro-client/src/main/resources/maestro-android-debug.apk"

from(layout.buildDirectory.dir(maestroAndroidApkPath))
into(layout.buildDirectory.file(maestroAndroidApkDest))

doLast {
if (!layout.buildDirectory.file(maestroAndroidApkDestPath).get().asFile.exists()) {
throw GradleException("Error: Input source for copyMaestroAndroid doesn't exist")
}

File("./maestro-client/src/main/resources/maestro-android-debug.apk").renameTo(File("./maestro-client/src/main/resources/maestro-app.apk"))
}
}

tasks.register<Copy>("copyMaestroServer") {
val maestroServerApkPath = "outputs/apk/androidTest/debug/maestro-android-debug-androidTest.apk"
val maestroServerApkDest = "../../maestro-client/src/main/resources"
val maestroServerApkDestPath = "../../maestro-client/src/main/resources/maestro-android-debug-androidTest.apk"

from(layout.buildDirectory.dir(maestroServerApkPath))
into(layout.buildDirectory.file(maestroServerApkDest))

doLast {
if (!layout.buildDirectory.file(maestroServerApkDestPath).get().asFile.exists()) {
throw GradleException("Error: Input source for copyMaestroServer doesn't exist")
}

File("./maestro-client/src/main/resources/maestro-android-debug-androidTest.apk").renameTo(File("./maestro-client/src/main/resources/maestro-server.apk"))
}
}

tasks.named("assemble") {
// lint.enabled = false
// lintVitalRelease.enabled = false
finalizedBy("copyMaestroAndroid")
}

tasks.named("assembleAndroidTest") {
// lint.enabled = false
// lintVitalRelease.enabled = false
finalizedBy("copyMaestroServer")
}

sourceSets {
create("generated") {
java {
srcDirs(
"build/generated/source/proto/main/grpc",
"build/generated/source/proto/main/java",
"build/generated/source/proto/main/kotlin",
)
}
}
}

dependencies {
protobuf(project(":maestro-proto"))

implementation(libs.grpc.kotlin.stub)
implementation(libs.grpc.netty.shaded)
implementation(libs.grpc.stub)
implementation(libs.grpc.protobuf.lite)
implementation(libs.grpc.okhttp)
implementation(libs.google.protobuf.kotlin.lite)

implementation(libs.ktor.server.core)
implementation(libs.ktor.server.cio)
implementation(libs.ktor.server.content.negotiation)
implementation(libs.ktor.serial.gson)

implementation(libs.commons.lang3)
implementation(libs.hiddenapibypass)

androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.uiautomator)
}
Loading

0 comments on commit 3ee902e

Please sign in to comment.