我正在尝试模块化我的build.gradle.kts
. 有人建议我创建一个buildSrc
文件夹。经过一些研究和一些询问后,我发现这篇文章我讨厌 Gradle!......所以这是我的尝试:
buildSrc
树:
buildSrc/
├── build.gradle.kts
├── settings.gradle.kts
└── src
└── main
├── kotlin
│ ├── Docker.kt
│ ├── MyProjectExtensions.kt
│ └── Versions.kt
└── resources
└── META-INF
└── gradle-plugins
└── pt.branden.brandenportal.properties
我的build.gradle.kts
:
plugins {
`kotlin-dsl`
id("com.google.cloud.tools.jib") version Versions.jib
}
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
implementation("gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:${Versions.jib}")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
implementation(gradleApi())
implementation(localGroovy())
}
最后Docker.kt
:
import org.gradle.api.Plugin
import org.gradle.api.Project
open class JibConfigPlugin : Plugin<Project> {
override fun apply(target: Project) {
//configureJib()
TODO("not implemented")
}
}
//internal fun Project.configureJib() = this.extensions.getByType<JibExtension>().run {}
internal fun Project.configureJib() = project.configure<JibExtension>() {
TODO("not implemented")
}
我的问题是我找不到JibExtension
,所以当我尝试实施和配置 Jib 时,它不起作用,但build.gradle.kts
一切正常。