7
7
// The individual configuration of each test depends on the config.toml file,
8
8
// located in the sub-folder next to its source code.
9
9
10
+ import com.android.build.api.variant.HasUnitTestBuilder
10
11
import org.gradle.api.tasks.testing.Test
11
12
import org.gradle.api.tasks.testing.logging.TestLogEvent
13
+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
14
13
15
val androidGradlePluginVersion: String = "{{ AGP_VERSION }}"
14
16
val kotlinVersion: String = "{{ KOTLIN_VERSION }}"
15
17
val junitJupiterVersion: String = "{{ JUNIT_JUPITER_VERSION }}"
16
18
val junit5AndroidLibsVersion: String = "{{ JUNIT5_ANDROID_LIBS_VERSION }}"
19
+ val javaVersion = JavaVersion.VERSION_17
17
20
18
21
buildscript {
19
22
repositories {
@@ -42,7 +45,7 @@ plugins {
42
45
}
43
46
44
47
// Double-checking the integrity of the AGP version under test
45
- val version = com.android.builder.model. Version.ANDROID_GRADLE_PLUGIN_VERSION
48
+ val version = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
46
49
if (version != "${androidGradlePluginVersion}") {
47
50
throw IllegalStateException("Incorrect AGP version. Expected ${androidGradlePluginVersion}, got $version")
48
51
}
@@ -58,23 +61,23 @@ repositories {
58
61
}
59
62
60
63
android {
61
- val minSdk : Int = {{ MIN_SDK_VERSION }}
64
+ val minSdkVersion : Int = {{ MIN_SDK_VERSION }}
62
65
63
66
{% if OVERRIDE_SDK_VERSION %}
64
67
val compileSdk: String = "android-{{ OVERRIDE_SDK_VERSION }}"
65
- val targetSdk : Int = {{ OVERRIDE_SDK_VERSION }}
68
+ val targetSdkVersion : Int = {{ OVERRIDE_SDK_VERSION }}
66
69
{% else %}
67
70
val compileSdk: String = "{{ COMPILE_SDK_VERSION }}"
68
- val targetSdk : Int = {{ TARGET_SDK_VERSION }}
71
+ val targetSdkVersion : Int = {{ TARGET_SDK_VERSION }}
69
72
{% endif %}
70
73
71
74
compileSdkVersion("${compileSdk}")
72
75
73
76
defaultConfig {
74
77
namespace = "de.mannodermaus.app"
75
78
76
- minSdkVersion( minSdk)
77
- targetSdkVersion( targetSdk)
79
+ minSdk = minSdkVersion
80
+ targetSdk = targetSdkVersion
78
81
79
82
{% if INCLUDE_ANDROID_RESOURCES %}
80
83
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -88,27 +91,19 @@ android {
88
91
{% endif %}
89
92
}
90
93
91
- val javaVersion = JavaVersion.VERSION_17
92
-
93
94
compileOptions {
94
95
sourceCompatibility = javaVersion
95
96
targetCompatibility = javaVersion
96
97
}
97
98
98
- {% if USE_KOTLIN %}
99
- tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
100
- kotlinOptions.jvmTarget = javaVersion.toString()
101
- }
102
- {% endif %}
103
-
104
99
{% if USE_FLAVORS %}
105
100
flavorDimensions("environment")
106
101
productFlavors {
107
102
register("free") {
108
- setDimension( "environment")
103
+ dimension = "environment"
109
104
}
110
105
register("paid") {
111
- setDimension( "environment")
106
+ dimension = "environment"
112
107
}
113
108
}
114
109
{% endif %}
@@ -131,6 +126,14 @@ android {
131
126
}
132
127
}
133
128
129
+ {% if USE_KOTLIN %}
130
+ kotlin {
131
+ compilerOptions {
132
+ jvmTarget = JvmTarget.fromTarget(javaVersion.toString())
133
+ }
134
+ }
135
+ {% endif %}
136
+
134
137
junitPlatform {
135
138
{% if USE_JACOCO %}
136
139
jacocoOptions {
@@ -144,8 +147,8 @@ junitPlatform {
144
147
145
148
{% for type in DISABLE_TESTS_FOR_BUILD_TYPES %}
146
149
androidComponents {
147
- beforeVariants(selector().withBuildType("{{ type }}")) { variant ->
148
- variant .enableUnitTest = false
150
+ beforeVariants(selector().withBuildType("{{ type }}")) { variantBuilder ->
151
+ (variantBuilder as HasUnitTestBuilder) .enableUnitTest = false
149
152
}
150
153
}
151
154
{% end %}
0 commit comments