[#543] Align gradle properties for included builds

This commit is contained in:
Carter Jernigan 2022-06-06 16:46:59 -04:00 committed by Carter Jernigan
parent 9388d5c087
commit 6496d717b9
8 changed files with 24 additions and 22 deletions

View File

@ -1,3 +1,6 @@
import com.android.build.api.dsl.CommonExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
pluginManager.withPlugin("com.android.application") {
project.the<com.android.build.gradle.AppExtension>().apply {
configureBaseExtension()
@ -60,7 +63,8 @@ fun com.android.build.gradle.BaseExtension.configureBaseExtension() {
buildTypes {
getByName("debug").apply {
isTestCoverageEnabled = project.property("IS_COVERAGE_ENABLED").toString().toBoolean()
isTestCoverageEnabled = project.property("IS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED")
.toString().toBoolean()
}
}
@ -82,4 +86,17 @@ fun com.android.build.gradle.BaseExtension.configureBaseExtension() {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}
}
if (this is CommonExtension<*, *, *, *>) {
kotlinOptions {
jvmTarget = project.property("ANDROID_JVM_TARGET").toString()
allWarningsAsErrors = project.property("ZCASH_IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn" +
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" + "-opt-in=kotlinx.coroutines.FlowPreview"
}
}
}
fun CommonExtension<*, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
}

View File

@ -17,7 +17,7 @@ plugins {
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
id("org.owasp.dependencycheck")
id("zcash.ktlint-conventions")
id("zcash-sdk.ktlint-conventions")
}
apply(plugin = "com.vanniktech.maven.publish")

View File

@ -1,7 +1,7 @@
plugins {
id("com.android.library")
id("zcash.android-build-conventions")
id("org.jetbrains.kotlin.android")
id("zcash-sdk.android-conventions")
id("kotlin-kapt")
}
@ -10,12 +10,6 @@ android {
//targetSdk = 30 //Integer.parseInt(project.property("targetSdkVersion"))
multiDexEnabled = true
}
// Need to figure out how to move this into the build-conventions
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
}
}
dependencies {

View File

@ -1,7 +1,7 @@
plugins {
id("com.android.application")
id("zcash.android-build-conventions")
id("org.jetbrains.kotlin.android")
id("zcash-sdk.android-conventions")
id("kotlin-parcelize")
id("androidx.navigation.safeargs")
id("com.osacky.fladle")
@ -47,11 +47,6 @@ android {
}
}
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
}
lint {
baseline = File("lint-baseline.xml")
}

View File

@ -37,10 +37,10 @@ POM_DEVELOPER_URL=https://github.com/zcash/
# Kotlin compiler warnings can be considered errors, failing the build.
# Currently set to false, because this project has a lot of warnings to fix first.
IS_TREAT_WARNINGS_AS_ERRORS=false
ZCASH_IS_TREAT_WARNINGS_AS_ERRORS=false
# Optionally configure code coverage, as historically Jacoco has at times been buggy with respect to new Kotlin versions
IS_COVERAGE_ENABLED=false
IS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=false
# Optionally configure test orchestrator.
# It is disabled by default, because it causes tests to take about 2x longer to run.

View File

@ -7,8 +7,8 @@ import com.google.protobuf.gradle.protoc
plugins {
id("com.android.library")
id("zcash.android-build-conventions")
id("org.jetbrains.kotlin.android")
id("zcash-sdk.android-conventions")
id("com.google.devtools.ksp")
id("org.jetbrains.kotlin.plugin.allopen")
id("org.jetbrains.dokka")
@ -72,10 +72,6 @@ android {
}
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.FlowPreview"
// Tricky: fix: By default, the kotlin_module name will not include the version (in classes.jar/META-INF). Instead it has a colon, which breaks compilation on Windows. This is one way to set it explicitly to the proper value. See https://github.com/zcash/zcash-android-wallet-sdk/issues/222 for more info.
freeCompilerArgs += listOf("-module-name", "$ARTIFACT_ID-${project.version}_release")
}