Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build-logic/src/main/kotlin/Environment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ enum class SupportedAgp(
AGP_8_9("8.9.3", gradle = "8.11.1"),
AGP_8_10("8.10.1", gradle = "8.11.1"),
AGP_8_11("8.11.1", gradle = "8.13"),
AGP_8_12("8.12.0", gradle = "8.13"),
AGP_8_12("8.12.1", gradle = "8.13"),
AGP_8_13("8.13.0-rc01", gradle = "8.13"),
AGP_9_0("9.0.0-alpha01", gradle = "9.0.0"),
AGP_9_0("9.0.0-alpha02", gradle = "9.0.0"),
;

companion object {
Expand Down
46 changes: 24 additions & 22 deletions build-logic/src/main/kotlin/Tasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,30 @@ fun Project.configureTestResources() {
val agpDependency = libs.plugins.android(plugin).substringBeforeLast(":")
project.dependencies.add(this.name, "${agpDependency}:${plugin.version}")

// Add the Kotlin Gradle Plugin explicitly,
// For Android Gradle Plugins before 9.x, add the Kotlin Gradle Plugin explicitly,
// acknowledging the different plugin variants introduced in Kotlin 1.7.
// Acknowleding the minimum required Gradle version, request the correct variant for KGP
// Acknowledging the minimum required Gradle version, request the correct variant for KGP
// (see https://docs.gradle.org/current/userguide/implementing_gradle_plugins.html#plugin-with-variants)
project.dependencies.add(
this.name,
"org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin}"
).apply {
with(this as ExternalModuleDependency) {
attributes {
attribute(
TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment::class.java, STANDARD_JVM)
)
attribute(
USAGE_ATTRIBUTE,
objects.named(Usage::class.java, JAVA_RUNTIME)
)
attribute(
GRADLE_PLUGIN_API_VERSION_ATTRIBUTE,
objects.named(GradlePluginApiVersion::class.java, minimumGradleVersion)
)
if (plugin < SupportedAgp.AGP_9_0) {
project.dependencies.add(
this.name,
"org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin}"
).apply {
with(this as ExternalModuleDependency) {
attributes {
attribute(
TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment::class.java, STANDARD_JVM)
)
attribute(
USAGE_ATTRIBUTE,
objects.named(Usage::class.java, JAVA_RUNTIME)
)
attribute(
GRADLE_PLUGIN_API_VERSION_ATTRIBUTE,
objects.named(GradlePluginApiVersion::class.java, minimumGradleVersion)
)
}
}
}
}
Expand All @@ -128,12 +130,12 @@ fun Project.configureTestResources() {
// 1) Use output classes from the plugin itself
// 2) Use resources from the plugin (i.e. plugin IDs etc.)
// 3) Use AGP-specific dependencies
val classesDirs = file("$buildDir/classes").listFiles()
val classesDirs = layout.buildDirectory.dir("classes").get().asFile.listFiles()
?.filter { it.isDirectory }
?.map { File(it, "main") }
?.filter { it.exists() && it.isDirectory && it.list()?.isEmpty() == false }
?: emptyList()
val resourcesDirs = file("$buildDir/resources").listFiles()
val resourcesDirs = layout.buildDirectory.dir("resources").get().asFile.listFiles()
?.filter { it.isDirectory }
?: emptyList()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ internal val Project.android

@OptIn(ExperimentalContracts::class)
internal fun Project.whenAndroidPluginAdded(block: (BasePlugin) -> Unit) {
contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) }

val configured = AtomicBoolean(false)
plugins.withType(BasePlugin::class.java) { plugin ->
// Prevent duplicate configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ class FunctionalTestProjectCreator(
file.write("sdk.dir = ${environment.androidSdkFolder.absolutePath}")
}
File(projectFolder, "gradle.properties").bufferedWriter().use { file ->
file.write("android.useAndroidX = true")
file.appendLine("android.useAndroidX = true")

// From AGP 9, test components are only generated for the debug build type; disable this behavior
file.appendLine("android.onlyEnableUnitTestForTheTestedBuildType = false")
}

// Copy over the source folders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ useCustomBuildType = "staging"

[[expectations]]
buildType = "debug"
tests = "JavaTest"
tests = "JavaTest,JavaDebugTest"

[[expectations]]
buildType = "release"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.mannodermaus.app;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

class JavaDebugTest {
@Test
void test() {
Adder adder = new Adder();
assertEquals(4, adder.add(2, 2), "This should succeed!");
}
}