|
| 1 | +import io.gitlab.arturbosch.detekt.Detekt |
| 2 | +import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 3 | +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion |
| 4 | +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile |
| 5 | + |
| 6 | +plugins { |
| 7 | + id 'signing' |
| 8 | + id 'maven-publish' |
| 9 | + id 'com.android.library' |
| 10 | + id 'org.jetbrains.kotlin.android' |
| 11 | + id 'org.jetbrains.kotlin.plugin.serialization' |
| 12 | + id 'io.gitlab.arturbosch.detekt' |
| 13 | +} |
| 14 | + |
| 15 | +apply from: file('../gradle/android-library-versions.gradle') |
| 16 | + |
| 17 | +def androidLibrary = checkoutKitAndroidLibrary |
| 18 | +def versionName = androidLibrary.versionName |
| 19 | + |
| 20 | +ext { |
| 21 | + junit_version = '4.13.2' |
| 22 | + robolectric_version = '4.16.1' |
| 23 | + assertj_version = '3.27.7' |
| 24 | +} |
| 25 | + |
| 26 | +android { |
| 27 | + namespace = 'com.shopify.checkoutkit.protocol' |
| 28 | + compileSdk = androidLibrary.compileSdk |
| 29 | + |
| 30 | + defaultConfig { |
| 31 | + minSdk = androidLibrary.minSdk |
| 32 | + versionCode = 1 |
| 33 | + versionName |
| 34 | + |
| 35 | + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 36 | + |
| 37 | + aarMetadata { |
| 38 | + minCompileSdk = androidLibrary.minCompileSdk |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + lint { |
| 43 | + checkDependencies = true |
| 44 | + warningsAsErrors = true |
| 45 | + warning 'LintBaseline' |
| 46 | + informational 'AndroidGradlePluginVersion' |
| 47 | + } |
| 48 | + |
| 49 | + buildTypes { |
| 50 | + release { |
| 51 | + minifyEnabled false |
| 52 | + } |
| 53 | + } |
| 54 | + compileOptions { |
| 55 | + sourceCompatibility JavaVersion.toVersion(androidLibrary.javaVersion) |
| 56 | + targetCompatibility JavaVersion.toVersion(androidLibrary.javaVersion) |
| 57 | + } |
| 58 | + testOptions { |
| 59 | + unitTests.includeAndroidResources = true |
| 60 | + unitTests.all { |
| 61 | + testLogging { |
| 62 | + events "passed", "skipped", "failed", "standardOut", "standardError" |
| 63 | + outputs.upToDateWhen { false } |
| 64 | + showStandardStreams = true |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | + publishing { |
| 69 | + singleVariant("release") { |
| 70 | + withSourcesJar() |
| 71 | + withJavadocJar() |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +tasks.withType(KotlinJvmCompile).configureEach { |
| 77 | + compilerOptions { |
| 78 | + jvmTarget.set(JvmTarget.valueOf(androidLibrary.kotlinJvmTarget)) |
| 79 | + apiVersion.set(KotlinVersion.valueOf(androidLibrary.kotlinApiVersion)) |
| 80 | + languageVersion.set(KotlinVersion.valueOf(androidLibrary.kotlinLanguageVersion)) |
| 81 | + if (!name.contains("Test")) { |
| 82 | + freeCompilerArgs.add("-Xexplicit-api=strict") |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +dependencies { |
| 88 | + detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:${androidLibrary.detektFormattingVersion}" |
| 89 | + |
| 90 | + testImplementation "junit:junit:$junit_version" |
| 91 | + testImplementation "org.robolectric:robolectric:$robolectric_version" |
| 92 | + testImplementation "org.assertj:assertj-core:$assertj_version" |
| 93 | + |
| 94 | + implementation "org.jetbrains.kotlin:kotlin-stdlib:${androidLibrary.kotlinStdlibVersion}" |
| 95 | + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:${androidLibrary.kotlinSerializationVersion}" |
| 96 | +} |
| 97 | + |
| 98 | +signing { |
| 99 | + def signingKeyId = findProperty("signingKeyId") |
| 100 | + def signingKey = findProperty("signingKey") |
| 101 | + def signingPassword = findProperty("signingPassword") |
| 102 | + if (signingKey) { |
| 103 | + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) |
| 104 | + sign publishing.publications |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +detekt { |
| 109 | + buildUponDefaultConfig = true |
| 110 | + config.setFrom('../lib/detekt.config.yml') |
| 111 | + autoCorrect = true |
| 112 | +} |
| 113 | + |
| 114 | +// Models.kt is generated from UCP JSON Schemas - exclude it from static analysis. |
| 115 | +tasks.withType(Detekt).configureEach { |
| 116 | + exclude('**/Models.kt') |
| 117 | +} |
| 118 | + |
| 119 | +project.afterEvaluate { |
| 120 | + publishing { |
| 121 | + publications { |
| 122 | + release(MavenPublication) { |
| 123 | + pom { |
| 124 | + name = "CheckoutProtocol" |
| 125 | + description = "Shopify Checkout Kit's Embedded Checkout Protocol models and wire helpers." |
| 126 | + url = "https://github.com/Shopify/checkout-kit" |
| 127 | + groupId = "com.shopify" |
| 128 | + artifactId = "checkout-protocol" |
| 129 | + version = versionName |
| 130 | + |
| 131 | + licenses { |
| 132 | + license { |
| 133 | + name = "MIT" |
| 134 | + url = "https://opensource.org/licenses/MIT" |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + developers { |
| 139 | + developer { |
| 140 | + name = "Shopify Inc." |
| 141 | + } |
| 142 | + } |
| 143 | + |
| 144 | + scm { |
| 145 | + connection = "https://github.com/Shopify/checkout-kit.git" |
| 146 | + developerConnection = "https://github.com/Shopify/checkout-kit.git" |
| 147 | + url = "https://github.com/Shopify/checkout-kit.git" |
| 148 | + } |
| 149 | + } |
| 150 | + |
| 151 | + afterEvaluate { |
| 152 | + from components.release |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + repositories { |
| 158 | + maven { |
| 159 | + name = 'ossrh-staging-api' |
| 160 | + url = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/" |
| 161 | + credentials { |
| 162 | + username = System.getenv("OSSRH_USERNAME") |
| 163 | + password = System.getenv("OSSRH_PASSWORD") |
| 164 | + } |
| 165 | + } |
| 166 | + } |
| 167 | + } |
| 168 | +} |
0 commit comments