alp
08/01/2022, 11:02 PMBaseExtension
to access some information and it works fine on the my sample app project since I can find the extension via
extensions.findByType(BaseExtension::class.java) // returns null in functional test but works fine on the actual app project
but when I use GradleRunner
for my plugin’s functional test, the expression above returns null
even though I can find it via:
extensions.findByName("android") // not null in both cases
I was looking for a possible problem and found detekt project that has functional tests for android scenario and was wondering if you can suggest something. In my functional test I use this setup:
File(projectRoot, "settings.gradle")
.apply {
writeText(
"""
include ':app'
"""
)
}
File(projectRoot, "build.gradle")
.apply {
writeText(
"""
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.32"
}
}
"""
)
}
val appModule = File(projectRoot, "app").apply { mkdir() }
File(appModule, "build.gradle")
.apply {
writeText(
"""
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("my.custom.plugin") // plugin under test
}
android {
compileSdkVersion 30
defaultConfig {
applicationId "<http://my.custom.plugin.app|my.custom.plugin.app>"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
}
"""
)
}
ephemient
08/01/2022, 11:09 PMephemient
08/01/2022, 11:10 PMalp
08/01/2022, 11:11 PMalp
08/01/2022, 11:17 PMef classpath = resolveSelfClasspath() +
resolvePlugin('org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10')
alp
08/01/2022, 11:18 PMresolveSelfClasspath
and resolvePlugin
?alp
08/02/2022, 3:11 AMcompileOnly
and pluginCompileOnly
, thank you very much for the link, will continue to figure out the details 👍