Skip to content

Commit

Permalink
Kotlin 2.1.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppeman committed Nov 30, 2024
1 parent 3750188 commit 1ae62a4
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 28 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

buildscript {
repositories {
Expand All @@ -9,7 +10,6 @@ buildscript {
}

dependencies {
classpath(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
classpath(libs.android.gradle)
classpath(libs.paparazzi)
classpath("com.jeppeman.mockposable:mockposable-gradle")
Expand All @@ -30,7 +30,7 @@ allprojects {

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
jvmTarget = JvmTarget.JVM_21.target
}
}

Expand Down
24 changes: 12 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
kotlin = '2.0.20'
compose-ui = '1.6.8'
google-ksp = '2.0.20-1.0.24'
activity = '1.9.0'
agp = '8.5.0'
kotlin = '2.1.0'
compose-ui = '1.7.5'
google-ksp = '2.1.0-1.0.29' # https://mvnrepository.com/artifact/com.google.devtools.ksp/com.google.devtools.ksp.gradle.plugin?repo=central
activity = '1.9.3'
agp = '8.5.2'
espresso = '3.6.1'
mockk = '1.13.12'
mockito = '4.8.1'
Expand All @@ -15,18 +15,18 @@ kotlin-compiler = { module = 'org.jetbrains.kotlin:kotlin-compiler-embeddable',
androidx-activity = { module = 'androidx.activity:activity', version.ref = 'activity' }
androidx-appcompat = { module = 'androidx.appcompat:appcompat', version = '1.7.0' }
androidx-activity-compose = { module = 'androidx.activity:activity-compose', version.ref = 'activity' }
androidx-lifecycle-viewmodel-compose = { module = 'androidx.lifecycle:lifecycle-viewmodel-compose', version = '2.8.2' }
androidx-test-runner = { module = 'androidx.test:runner', version = '1.6.1'}
androidx-lifecycle-viewmodel-compose = { module = 'androidx.lifecycle:lifecycle-viewmodel-compose', version = '2.8.7' }
androidx-test-runner = { module = 'androidx.test:runner', version = '1.6.2'}
androidx-test-espresso-core = { module = 'androidx.test.espresso:espresso-core', version.ref = 'espresso' }
androidx-test-annotation = { module = 'androidx.test:annotation', version = '1.0.1' }
androidx-fragment-testing = { module = 'androidx.fragment:fragment-testing', version = '1.8.1' }
androidx-fragment-testing = { module = 'androidx.fragment:fragment-testing', version = '1.8.5' }

compose-compiler = { module = 'org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable', version.ref = 'kotlin' }
compose-compiler-gradle = { module = 'org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin', version.ref = 'kotlin' }
compose-runtime = { module = 'org.jetbrains.compose.runtime:runtime', version = '1.6.11' }
compose-ui = { module = 'androidx.compose.ui:ui', version.ref = 'compose-ui' }
compose-material = { module = 'androidx.compose.material:material', version = '1.6.8' }
compose-foundation = { module = 'androidx.compose.foundation:foundation', version = '1.6.8' }
compose-material = { module = 'androidx.compose.material:material', version = '1.7.5' }
compose-foundation = { module = 'androidx.compose.foundation:foundation', version = '1.7.5' }
compose-ui-test-junit4 = { module = 'androidx.compose.ui:ui-test-junit4', version.ref = 'compose-ui' }
compose-ui-test-manifest = { module = 'androidx.compose.ui:ui-test-manifest', version.ref = 'compose-ui' }

Expand All @@ -38,7 +38,7 @@ autoservice-annotations = { module = 'com.google.auto.service:auto-service-annot
google-ksp = { module = 'com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin', version.ref = 'google-ksp' }

# compile-testing = { module = 'com.github.tschuchortdev:kotlin-compile-testing', version = '1.5.0' }
compile-testing = { module = 'dev.zacsweers.kctfork:core', version = '0.5.1' }
compile-testing = { module = 'dev.zacsweers.kctfork:core', version = '0.7.0' }

junit = { module = 'androidx.test.ext:junit', version = '1.1.3' }

Expand All @@ -51,7 +51,7 @@ hamcrest = { module = 'org.hamcrest:hamcrest', version = '2.2' }
mockk-core = { module = 'io.mockk:mockk', version.ref = 'mockk' }
mockk-android = { module = 'io.mockk:mockk-android', version.ref = 'mockk' }

mockito-kotlin = { module = 'org.mockito.kotlin:mockito-kotlin', version = '4.0.0' }
mockito-kotlin = { module = 'org.mockito.kotlin:mockito-kotlin', version = '5.4.0' }
mockito-inline = { module = 'org.mockito:mockito-inline', version.ref = 'mockito' }
mockito-android = { module = 'org.mockito:mockito-android', version.ref = 'mockito' }

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Oct 18 11:21:10 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
5 changes: 2 additions & 3 deletions integration-tests/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ plugins {

mockposable {
plugins = listOf(MOCKK, MOCKITO, COMPOSE_UI)
composeCompilerPluginVersion = libs.versions.kotlin.get()
}

android {
Expand Down Expand Up @@ -51,8 +50,8 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}

Expand Down
4 changes: 2 additions & 2 deletions mockposable/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

buildscript {
repositories {
Expand All @@ -10,7 +11,6 @@ buildscript {
}

dependencies {
classpath(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
classpath(libs.android.gradle)
classpath(libs.google.ksp)
}
Expand All @@ -30,7 +30,7 @@ allprojects {

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
jvmTarget = JvmTarget.JVM_21.target
}
}

Expand Down
4 changes: 2 additions & 2 deletions mockposable/mockposable-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ plugins {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jeppeman.mockposable.compiler

import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
import org.jetbrains.kotlin.backend.common.IrValidatorConfig
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.validateIr
Expand Down Expand Up @@ -48,7 +49,8 @@ class MockKIrGenerationExtension(
performBasicIrValidation(
moduleFragment,
moduleFragment.irBuiltins,
"MockK transformation"
"MockK transformation",
IrValidatorConfig(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jeppeman.mockposable.compiler

import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
import org.jetbrains.kotlin.backend.common.IrValidatorConfig
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.validateIr
Expand Down Expand Up @@ -42,7 +43,8 @@ class MockitoIrGenerationExtension(
performBasicIrValidation(
moduleFragment,
moduleFragment.irBuiltins,
"Mockito transformation"
"Mockito transformation",
IrValidatorConfig(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.PluginOption
import com.tschuchort.compiletesting.SourceFile
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.jetbrains.kotlin.config.JvmTarget
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
Expand Down Expand Up @@ -93,8 +94,10 @@ fun compile(
return KotlinCompilation().apply {
languageVersion = "2.0"
sources = sourceFiles
jvmTarget = JvmTarget.JVM_21.description
commandLineProcessors = listOf(mockposableCommandLineProcessor, composeCommandLineProcessor)
componentRegistrars = listOf(ComposePluginRegistrar(), MockposablePlugin())
componentRegistrars = listOf(MockposablePlugin())
compilerPluginRegistrars = listOf(ComposePluginRegistrar())
pluginOptions = listOf(
PluginOption(
pluginId = mockposableCommandLineProcessor.pluginId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class MockposableSubPlugin : KotlinCompilerPluginSupportPlugin {
.getByName("implementation")
.dependencies
.add(project.dependencies.create(COMPOSE_RUNTIME_COORDINATES))
project.plugins.whenPluginAdded { plugin ->
println("yo ${plugin::class.java.name}")
}

project.plugins.apply(ComposeCompilerGradleSubplugin::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.mockito.verification.VerificationMode
/**
* @see [KStubbing.on]
*/
fun <T, R> KStubbing<T>.onComposable(stubBlock: @Composable T.() -> R): OngoingStubbing<R> = try {
fun <T : Any, R> KStubbing<T>.onComposable(stubBlock: @Composable T.() -> R): OngoingStubbing<R> = try {
runComposableOneShot { Mockito.`when`(mock.stubBlock()) }
} catch (e: NullPointerException) {
throw MockitoKotlinException(
Expand Down

0 comments on commit 1ae62a4

Please sign in to comment.