-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Kotlin Android plugin #33
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile | ||
|
||
buildscript { | ||
repositories { | ||
maven { | ||
url = file("$rootDir/../../../../../build/testMaven").toURI() | ||
} | ||
mavenCentral() | ||
google() | ||
} | ||
dependencies { | ||
classpath("app.cash.burst:burst-gradle-plugin:${project.property("burstVersion")}") | ||
classpath(libs.android.gradlePlugin) | ||
classpath(libs.kotlin.gradlePlugin) | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
maven { | ||
url = file("$rootDir/../../../../../build/testMaven").toURI() | ||
} | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
tasks.withType(JavaCompile::class.java).configureEach { | ||
sourceCompatibility = "1.8" | ||
targetCompatibility = "1.8" | ||
} | ||
|
||
tasks.withType(KotlinJvmCompile::class.java).configureEach { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_1_8) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
id("com.android.library") | ||
kotlin("android") | ||
id("app.cash.burst") | ||
} | ||
|
||
android { | ||
namespace = "com.example" | ||
compileSdk = 35 | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
} | ||
} | ||
|
||
dependencies { | ||
testImplementation(libs.kotlin.test) | ||
androidTestImplementation(libs.kotlin.test) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import app.cash.burst.Burst | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
|
||
@Burst | ||
class AndroidCoffeeTest( | ||
private val espresso: Espresso, | ||
) { | ||
@BeforeTest | ||
fun setUp() { | ||
println("set up $espresso") | ||
} | ||
|
||
@Test | ||
fun test(dairy: Dairy) { | ||
println("running $espresso $dairy") | ||
} | ||
} | ||
|
||
enum class Espresso { Decaf, Regular, Double } | ||
|
||
enum class Dairy { None, Milk, Oat } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import app.cash.burst.Burst | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
|
||
@Burst | ||
class CoffeeTest( | ||
private val espresso: Espresso, | ||
) { | ||
@BeforeTest | ||
fun setUp() { | ||
println("set up $espresso") | ||
} | ||
|
||
@Test | ||
fun test(dairy: Dairy) { | ||
println("running $espresso $dairy") | ||
} | ||
} | ||
Comment on lines
+5
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are those tests just validating the compilation step ? I don't think we're reading the printed lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. We'd need an emulator to run the instrumented tests and the JVM ones are identical to the existing JVM tests. I can add it in a follow-up if we want them. |
||
|
||
enum class Espresso { Decaf, Regular, Double } | ||
|
||
enum class Dairy { None, Milk, Oat } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../../../../../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
include(":lib") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile | ||
|
||
buildscript { | ||
repositories { | ||
maven { | ||
|
@@ -8,7 +11,7 @@ buildscript { | |
} | ||
dependencies { | ||
classpath("app.cash.burst:burst-gradle-plugin:${project.property("burstVersion")}") | ||
classpath(libs.kotlin.gradle.plugin) | ||
classpath(libs.kotlin.gradlePlugin) | ||
} | ||
} | ||
|
||
|
@@ -20,4 +23,15 @@ allprojects { | |
mavenCentral() | ||
google() | ||
} | ||
|
||
tasks.withType(JavaCompile::class.java).configureEach { | ||
sourceCompatibility = "1.8" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of these projects built on my machine without this. My default JDK is 23, but Kotlin doesn't know about that version so it drops down to target 22 and then complains Kotlin and Java targets don't match. |
||
targetCompatibility = "1.8" | ||
} | ||
|
||
tasks.withType(KotlinJvmCompile::class.java).configureEach { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_1_8) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
willowtreeapps/assertk#549