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
16 changes: 9 additions & 7 deletions build-logic/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@

object libs {
object versions {
const val kotlin = "1.9.25"
const val kotlin = "1.9.25" // Can only once minimum supported AGP is >= 8.2
const val junitJupiter = "5.12.0"
const val junitVintage = "5.12.0"
const val junitPlatform = "1.12.0"

const val composeBom = "2024.09.00"
const val composeBom = "2025.03.00"
const val androidXMultidex = "2.0.1"
const val androidXTestAnnotation = "1.0.1"
const val androidXTestCore = "1.6.1"
const val androidXTestMonitor = "1.7.2"
const val androidXTestRunner = "1.6.2"
const val composeCompiler = "1.5.15"

const val activityCompose = "1.9.0"
const val activityCompose = "1.10.1"
const val apiGuardian = "1.1.2"
const val coroutines = "1.8.1"
const val dokka = "1.9.20"
const val coroutines = "1.8.1" // Can only update once minimum supported AGP is >= 8.2
const val dokka = "2.0.0"
const val espresso = "3.6.1"
const val javaSemver = "0.10.2"
const val junit4 = "4.13.2"
const val konfToml = "1.1.2"
const val korte = "2.4.12"
const val mockitoCore = "5.12.0"
const val mockitoCore = "5.16.0"
const val mockitoKotlin = "5.4.0"
const val robolectric = "4.13"
const val robolectric = "4.14.1"
const val shadow = "8.1.1"
const val truth = "1.4.4"
}
Expand Down Expand Up @@ -76,6 +77,7 @@ object libs {
const val truthJava8Extensions = "com.google.truth.extensions:truth-java8-extension:${versions.truth}"
const val robolectric = "org.robolectric:robolectric:${versions.robolectric}"

const val androidXMultidex = "androidx.multidex:multidex:${versions.androidXMultidex}"
const val androidXTestAnnotation = "androidx.test:annotation:${versions.androidXTestAnnotation}"
const val androidXTestCore = "androidx.test:core:${versions.androidXTestCore}"
const val androidXTestMonitor = "androidx.test:monitor:${versions.androidXTestMonitor}"
Expand Down
16 changes: 10 additions & 6 deletions build-logic/src/main/kotlin/Deployment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.configurationcache.extensions.capitalized
import org.gradle.api.tasks.TaskProvider
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
import org.gradle.kotlin.dsl.withGroovyBuilder
import org.gradle.plugins.signing.Sign
Expand Down Expand Up @@ -43,7 +44,7 @@ fun Project.configureDeployment(deployConfig: Deployed) {
}

// Create artifact tasks
val androidSourcesJar = tasks.create("androidSourcesJar", Jar::class.java) {
val androidSourcesJar = tasks.register<Jar>("androidSourcesJar") {
archiveClassifier.set("sources")

if (isAndroid) {
Expand All @@ -55,9 +56,12 @@ fun Project.configureDeployment(deployConfig: Deployed) {
}
}

val javadocJar = tasks.create("javadocJar", Jar::class.java) {
from(tasks.getByName("dokkaHtml"))
val javadocJar = tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")

// Connect to Dokka for generation of docs
from(layout.buildDirectory.dir("dokka/html"))
dependsOn("dokkaGenerate")
}

artifacts {
Expand Down Expand Up @@ -158,8 +162,8 @@ private fun MavenPublication.applyPublicationDetails(
project: Project,
deployConfig: Deployed,
isAndroid: Boolean,
androidSourcesJar: Jar,
javadocJar: Jar
androidSourcesJar: TaskProvider<Jar>,
javadocJar: TaskProvider<Jar>
) = also {
groupId = deployConfig.groupId
artifactId = deployConfig.artifactId
Expand Down
11 changes: 5 additions & 6 deletions build-logic/src/main/kotlin/Environment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum class SupportedAgp(
AGP_8_7("8.7.3", gradle = "8.9"),
AGP_8_8("8.8.2", gradle = "8.10.2"),
AGP_8_9("8.9.0", gradle = "8.11.1"),
AGP_8_10("8.10.0-alpha08", gradle = "8.11.1"),
AGP_8_10("8.10.0-alpha07", gradle = "8.11.1"),
;

companion object {
Expand All @@ -40,15 +40,14 @@ enum class SupportedAgp(
}

object Android {
const val compileSdkVersion = 34
const val targetSdkVersion = 34
const val compileSdkVersion = 35
const val targetSdkVersion = 35
const val sampleMinSdkVersion = 21
val testRunnerMinSdkVersion = (Artifacts.Instrumentation.Runner.platform as Android).minSdk
val testCoreMinSdkVersion = (Artifacts.Instrumentation.Core.platform as Android).minSdk
val testComposeMinSdkVersion = (Artifacts.Instrumentation.Compose.platform as Android).minSdk
}


sealed class Platform(val name: String) {
object Java : Platform("java")
class Android(val minSdk: Int) : Platform("android")
Expand Down Expand Up @@ -91,7 +90,7 @@ object Artifacts {
platform = Java,
groupId = "de.mannodermaus.gradle.plugins",
artifactId = "android-junit5",
currentVersion = "1.12.0.1-SNAPSHOT",
currentVersion = "1.12.1.0-SNAPSHOT",
latestStableVersion = "1.12.0.0",
description = "Unit Testing with JUnit 5 for Android."
)
Expand All @@ -101,7 +100,7 @@ object Artifacts {
*/
object Instrumentation {
const val groupId = "de.mannodermaus.junit5"
private const val currentVersion = "1.7.1-SNAPSHOT"
private const val currentVersion = "1.8.0-SNAPSHOT"
private const val latestStableVersion = "1.7.0"

val Core = Deployed(
Expand Down
83 changes: 23 additions & 60 deletions build-logic/src/main/kotlin/Utilities.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.tasks.compile.AbstractCompile
import org.gradle.kotlin.dsl.withGroovyBuilder
Expand All @@ -12,32 +10,26 @@ import java.time.format.DateTimeFormatter

/* RepositoryHandler */

fun RepositoryHandler.jitpack() =
this.maven(object: Action<MavenArtifactRepository> {
override fun execute(repo: MavenArtifactRepository) {
repo.setUrl("https://jitpack.io")
}
})
fun RepositoryHandler.jitpack() = maven {
setUrl("https://jitpack.io")
}

fun RepositoryHandler.sonatypeSnapshots() =
this.maven(object: Action<MavenArtifactRepository> {
override fun execute(repo: MavenArtifactRepository) {
repo.setUrl("https://oss.sonatype.org/content/repositories/snapshots")
}
})
fun RepositoryHandler.sonatypeSnapshots() = maven {
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
}

/* Project */

fun Project.fixCompileTaskChain() {
setupCompileChain(
sourceCompileName = "compileKotlin",
targetCompileName = "compileGroovy"
)

setupCompileChain(
sourceCompileName = "compileTestKotlin",
targetCompileName = "compileTestGroovy"
)
setupCompileChain(
sourceCompileName = "compileKotlin",
targetCompileName = "compileGroovy"
)

setupCompileChain(
sourceCompileName = "compileTestKotlin",
targetCompileName = "compileTestGroovy"
)
}

/**
Expand All @@ -48,41 +40,12 @@ private fun Project.setupCompileChain(
sourceCompileName: String,
targetCompileName: String
) {
val targetCompile = tasks.getByName(targetCompileName) as AbstractCompile
val sourceCompile = tasks.getByName(sourceCompileName)

// Allow calling the source language's classes from the target language.
// In this case, we allow calling Kotlin from Groovy - it has to be noted however,
// that the other way does not work!
val sourceDir = sourceCompile.withGroovyBuilder { getProperty("destinationDirectory") } as DirectoryProperty
targetCompile.classpath += project.files(sourceDir.get().asFile)
}

/**
* Provides a dependency object to the JUnit 5 plugin, if any can be found.
* This will look in the build folder of the sibling project to try and find
* a previously built "fat JAR", and return it in a format
* compatible to the Gradle dependency mechanism. If no file can be found,
* this method returns null instead.
*/
fun Project.findLocalPluginJar(): File? {
val localLibsFolder = rootDir.parentFile.toPath()
.resolve("plugin/android-junit5/build/libs")
.toFile()

val localPluginJar = (localLibsFolder.listFiles() ?: emptyArray<File>())
.sortedByDescending(File::lastModified)
.firstOrNull { "fat" in it.name && "javadoc" !in it.name && "sources" !in it.name }

return localPluginJar
val targetCompile = tasks.getByName(targetCompileName) as AbstractCompile
val sourceCompile = tasks.getByName(sourceCompileName)

// Allow calling the source language's classes from the target language.
// In this case, we allow calling Kotlin from Groovy - it has to be noted however,
// that the other way does not work!
val sourceDir = sourceCompile.withGroovyBuilder { getProperty("destinationDirectory") } as DirectoryProperty
targetCompile.classpath += project.files(sourceDir.get().asFile)
}

/* File */

/**
* Format the "last modified" timestamp of a file into a human readable string.
*/
fun File.lastModifiedDate(): String =
Instant.ofEpochMilli(lastModified())
.atZone(ZoneId.systemDefault())
.format(DateTimeFormatter.ISO_DATE_TIME)
6 changes: 5 additions & 1 deletion instrumentation/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
android.useAndroidX = true
org.gradle.jvmargs = -XX:MaxMetaspaceSize=512m
org.gradle.jvmargs = -XX:MetaspaceSize=1g -XX:MaxMetaspaceSize=1g

# Dokka V2 (https://kotlinlang.org/docs/dokka-migration.html)
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
Binary file modified instrumentation/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion instrumentation/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 2 additions & 3 deletions instrumentation/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -206,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
Expand Down
4 changes: 3 additions & 1 deletion instrumentation/testutil/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ android {
compileSdk = Android.compileSdkVersion

defaultConfig {
minSdk = 4
minSdk = 19
multiDexEnabled = true
}

compileOptions {
Expand Down Expand Up @@ -58,6 +59,7 @@ tasks.withType<Test> {

dependencies {
implementation(project(":testutil-reflect"))
implementation(libs.androidXMultidex)

api(libs.androidXTestMonitor)
api(libs.truth)
Expand Down
6 changes: 1 addition & 5 deletions plugin/android-junit5/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ sourceSets {
kotlin.srcDir(genFolder)
}
}
tasks.withType<DokkaTask> {
// Connect additional source folder to Dokka generation task
dependsOn(versionClassTask)
}

// ------------------------------------------------------------------------------------------------
// Dependency Definitions
Expand Down Expand Up @@ -120,7 +116,7 @@ dependencies {
project.configureDeployment(Artifacts.Plugin)

// Register source-processing tasks as dependants of the custom source generation task
listOf("compileKotlin", "androidSourcesJar", "dokkaJavadoc").forEach { taskName ->
listOf("compileKotlin", "androidSourcesJar", "dokkaGeneratePublicationHtml").forEach { taskName ->
tasks.named(taskName).configure {
dependsOn(versionClassTask)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ internal fun requireGradle(version: String, message: () -> String) {
}

internal fun requireVersion(actual: String, required: String, message: () -> String) {
val actualVersion = Version.valueOf(actual)
val requiredVersion = Version.valueOf(required)
require(actualVersion.greaterThanOrEqualTo(requiredVersion)) {
val actualVersion = Version.parse(actual)
val requiredVersion = Version.parse(required)
require(actualVersion.isHigherThanOrEquivalentTo(requiredVersion)) {
throw GradleException(message())
}
}
3 changes: 3 additions & 0 deletions plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Dokka V2 (https://kotlinlang.org/docs/dokka-migration.html)
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true