Skip to content

Commit 43df58a

Browse files
TapchicomaSpace
authored andcommitted
Pin AGP 'debug.keystore' in the repo.
This change adds shared 'debug.keystore' into the repository and sets all the tests to use it. Fixes issue when keystore was created by AGP 7+, but then consumed in the test using lower versions of AGP. ^KT-45745 In Progress
1 parent e705a36 commit 43df58a

File tree

26 files changed

+323
-8
lines changed

26 files changed

+323
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Description
2+
3+
Contains a plugin for Gradle integration tests applying different fixes
4+
for test that are using Android Gradle plugin.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import plugins.KotlinBuildPublishingPlugin
2+
3+
plugins {
4+
id("java-gradle-plugin")
5+
id("gradle-plugin-common-configuration")
6+
id("com.gradle.plugin-publish")
7+
}
8+
9+
repositories {
10+
google()
11+
}
12+
13+
dependencies {
14+
compileOnly(gradleKotlinDsl())
15+
compileOnly("com.android.tools.build:gradle:3.4.0")
16+
compileOnly("com.android.tools.build:gradle-api:3.4.0")
17+
compileOnly("com.android.tools.build:builder:3.4.0")
18+
compileOnly("com.android.tools.build:builder-model:3.4.0")
19+
}
20+
21+
configure<GradlePluginDevelopmentExtension> {
22+
isAutomatedPublishing = false
23+
}
24+
25+
gradlePlugin {
26+
(plugins) {
27+
create("android-test-fixes") {
28+
id = "org.jetbrains.kotlin.test.fixes.android"
29+
implementationClass = "org.jetbrains.kotlin.gradle.test.fixes.android.AndroidTestFixesPlugin"
30+
}
31+
}
32+
}
33+
34+
pluginBundle {
35+
(plugins) {
36+
named("android-test-fixes") {
37+
id = "org.jetbrains.kotlin.test.fixes.android"
38+
displayName = "AndroidTestFixes"
39+
}
40+
}
41+
}
42+
43+
publishPluginMarkers()
44+
45+
// Disable releasing for this plugin
46+
// It is not intended to be released publicly
47+
tasks.withType<PublishToMavenRepository>()
48+
.configureEach {
49+
if (name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository")) {
50+
enabled = false
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package org.jetbrains.kotlin.gradle.test.fixes.android
7+
8+
import org.gradle.api.Plugin
9+
import org.gradle.api.Project
10+
import org.jetbrains.kotlin.gradle.test.fixes.android.fixes.applyDebugKeystoreFix
11+
12+
class AndroidTestFixesPlugin : Plugin<Project> {
13+
override fun apply(target: Project) {
14+
val testFixesProperties = TestFixesProperties(target)
15+
target.applyDebugKeystoreFix(testFixesProperties)
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package org.jetbrains.kotlin.gradle.test.fixes.android
7+
8+
import org.gradle.api.Project
9+
10+
internal class TestFixesProperties(
11+
private val project: Project
12+
) {
13+
val androidDebugKeystoreLocation: String
14+
get() = project.findProperty(ANDROID_DEBUG_KEYSTORE_LOCATION) as String? ?: throw IllegalArgumentException(
15+
"$ANDROID_DEBUG_KEYSTORE_LOCATION property was not found in 'gradle.properties'."
16+
)
17+
18+
companion object {
19+
private const val PROP_PREFIX = "test.fixes."
20+
private const val ANDROID_DEBUG_KEYSTORE_LOCATION = "${PROP_PREFIX}android.debugKeystore"
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package org.jetbrains.kotlin.gradle.test.fixes.android.fixes
7+
8+
import com.android.build.gradle.AppExtension
9+
import org.gradle.api.Project
10+
import org.gradle.kotlin.dsl.configure
11+
import org.jetbrains.kotlin.gradle.test.fixes.android.TestFixesProperties
12+
13+
/**
14+
* AGP 7+ creates a keystore that is not compatible with lover versions of AGP,
15+
* but could consume keystores created by them.
16+
*
17+
* With this fix 'debug.keystore' could be checked in into the repo and shared
18+
* between test executions.
19+
*/
20+
internal fun Project.applyDebugKeystoreFix(
21+
testFixesProperties: TestFixesProperties
22+
) {
23+
plugins.withId("com.android.application") {
24+
extensions.configure<AppExtension> {
25+
logger.info("Reconfiguring Android debug keystore")
26+
buildTypes.named("debug") {
27+
it.signingConfig?.storeFile = file(testFixesProperties.androidDebugKeystoreLocation)
28+
}
29+
}
30+
}
31+
}

libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ tasks.withType<Test> {
204204

205205
dependsOn(":kotlin-gradle-plugin:validatePlugins")
206206
dependsOnKotlinGradlePluginInstall()
207+
dependsOn(":gradle:android-test-fixes:install")
207208

208209
systemProperty("kotlinVersion", rootProject.extra["kotlinVersion"] as String)
209210
systemProperty("runnerGradleVersion", gradle.gradleVersion)

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import org.jdom.output.XMLOutputter
1818
import org.jetbrains.kotlin.gradle.model.ModelContainer
1919
import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction
2020
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
21+
import org.jetbrains.kotlin.gradle.testbase.applyAndroidTestFixes
2122
import org.jetbrains.kotlin.gradle.testbase.enableCacheRedirector
2223
import org.jetbrains.kotlin.gradle.testbase.addPluginManagementToSettings
2324
import org.jetbrains.kotlin.gradle.util.*
@@ -296,6 +297,7 @@ abstract class BaseGradleIT {
296297
projectDir.toPath().apply {
297298
addPluginManagementToSettings()
298299
if (enableCacheRedirector) enableCacheRedirector()
300+
applyAndroidTestFixes()
299301
}
300302
}
301303
}
@@ -452,7 +454,7 @@ abstract class BaseGradleIT {
452454
}
453455

454456
val options = defaultBuildOptions()
455-
val arguments = mutableListOf("-Pkotlin_version=${options.kotlinVersion}")
457+
val arguments = mutableListOf("-Pkotlin_version=${options.kotlinVersion}", "-Ptest_fixes_version=$KOTLIN_VERSION")
456458
options.androidGradlePluginVersion?.let { arguments.add("-Pandroid_tools_version=$it") }
457459
val env = createEnvironmentVariablesMap(options)
458460
val wrapperVersion = chooseWrapperVersionOrFinishTest()
@@ -929,6 +931,7 @@ Finished executing task ':$taskName'|
929931
}
930932

931933
add("-Pkotlin_version=" + options.kotlinVersion)
934+
add("-Ptest_fixes_version=$KOTLIN_VERSION")
932935
options.incremental?.let {
933936
add("-Pkotlin.incremental=$it")
934937
}

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJavaToolchainTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
776776
""".trimIndent()
777777
)
778778

779-
build("assembleDebug", "-Pagp_version=${TestVersions.AGP.AGP_42}")
779+
build("assembleDebug", "-Pandroid_tools_version=${TestVersions.AGP.AGP_42}")
780780
}
781781
}
782782

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,7 @@ class NewMultiplatformIT : BaseGradleIT() {
15181518
.replace(": ", " = ")
15191519
.replace("def ", " val ")
15201520
.replace("new File(cacheRedirectorFile)", "File(cacheRedirectorFile)")
1521+
.replace("id \"org.jetbrains.kotlin.test.fixes.android\"", "id(\"org.jetbrains.kotlin.test.fixes.android\")")
15211522
}
15221523
renameTo(projectDir.resolve("app/build.gradle.kts"))
15231524
}

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/KGPBaseTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ abstract class KGPBaseTest {
107107
}
108108
}
109109

110+
arguments.add("-Ptest_fixes_version=${TestVersions.Kotlin.CURRENT}")
111+
110112
return arguments.toList()
111113
}
112114
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy