Rav*_*ari 5 eclipse gradle kotlin gradle-plugin gradle-kotlin-dsl
我正在尝试使用 gradle 设置多项目设置,并尝试使用eclipseIDE 插件生成 eclipse 项目。
下面是我的结构。
rootDir/
|---buildSrc/
|---src/
|---main/
|---gradle/
|---eclipse.gradle.kts
|---build.gradle.kts
|---app/
|---build.gradle.kts
|---models/
|---build.gradle.kts
|---services/
|---build.gradle.kts
|---build.gradle.kts
|---settings.gradle.kts
Run Code Online (Sandbox Code Playgroud)
以下是特定文件的内容,例如settings.gradle.kts和build.gradle.kts
设置.gradle.kts
rootProject.name = "platform"
include("app", "models", "services")
Run Code Online (Sandbox Code Playgroud)
根目录/build.gradle.kts
...
val buildSrc by extra("$rootDir/buildSrc")
configure(subprojects) {
apply(from = "$buildSrc/src/main/gradle/eclipse.gradle.kts")
}
Run Code Online (Sandbox Code Playgroud)
rootDir/buildSrc/src/main/gradle/eclipse.gradle.kts
plugins {
eclipse
}
eclipse {
project {
println("Running inside eclipse closure for $name")
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行时./gradlew,出现以下错误:
Expression 'eclipse' cannot be invoked as a function. The function 'invoke()' is not found
FAILURE: Build failed with an exception.
* Where:
Script 'D:\work\sources\repos\platform\buildSrc\src\main\gradle\eclipse.gradle.kts' line: 5
* What went wrong:
Script compilation errors:
Line 5: eclipse {
^ Expression 'eclipse' cannot be invoked as a function. The function 'invoke()' is not found
Line 5: eclipse {
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val PluginDependenciesSpec.eclipse: PluginDependencySpec defined in org.gradle.kotlin.dsl
Line 6: project {
^ Type mismatch: inferred type is () -> Unit but String! was expected
3 errors
Run Code Online (Sandbox Code Playgroud)
但是,当我进行以下更改时,它可以正常工作,不会出现错误
rootDir/buildSrc/src/main/gradle/eclipse.gradle将 文件替换为并按照groovy DSL进行更改eclipse.gradle.ktseclipse.gradle
apply plugin: 'eclipse'
eclipse {
project {
println("Running inside eclipse closure for $name")
}
}
Run Code Online (Sandbox Code Playgroud)
在rootDir/build.gradle.kts中引用正确的文件
...
val buildSrc by extra("$rootDir/buildSrc")
configure(subprojects) {
apply(from = "$buildSrc/src/main/gradle/eclipse.gradle")
}
Run Code Online (Sandbox Code Playgroud)
目录中有一个kotlin文件gradlerootDir/buildSrc/src/main/gradle(自定义脚本插件)如果是这样,有没有办法在 kotlin dsl 中编写自定义脚本插件(而不是二进制插件)?
我尝试过放入 kotlin 脚本,rootDir/buildSrc/src/main/kotlin/eclipse.gradle.kts但这没有帮助。
任何帮助将不胜感激。
| 归档时间: |
|
| 查看次数: |
1016 次 |
| 最近记录: |