Gradle 6.0打破了源集依赖性 [英] Gradle 6.0 breaks source set dependency
问题描述
我在这里为学生提供了一些课程: https://github.com/emign /engineEmi_Lektionen/tree/master
I have a collection of lessons for students here: https://github.com/emign/engineEmi_Lektionen/tree/master
The dependant lib for this project gets injected via a gradle plugin here: https://github.com/emign/engineEmi_GradlePlugin/blob/98a70b6a54c21c730a9d1cb6e4fee9ac369b8fc6/src/main/kotlin/me/emig/engineEmi/gradle/EngineEmiGradlePlugin.kt#L43
在gradle 5.6.4之前,一切都很好.但是,当我升级包装器时,它会损坏并丢失上述库的源集".有人可以帮我吗?
It all works great up until gradle 5.6.4. But when I upgrade the wrapper, it breaks and loses the Source Set of the above mentioned library. Can anyone help me with that?
复制步骤:
- 克隆存储库
- 使用gradle包装器版本5.6.4->示例有效. (集成了源集依赖引擎Emi)
- 使用gradle wrapper 6.0或更高版本->示例中断(缺少源集依赖项engineEmi)
编辑 忘记了错误信息:
> Task :compileKotlinJvm FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.2/userguide/command_line_interface.html#sec:command_line_warnings
1 actionable task: 1 executed
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (1, 8): Unresolved reference: me
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (16, 9): Unresolved reference: engine
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (21, 13): Unresolved reference: init
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (28, 13): Unresolved reference: viewWillLoad
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (35, 13): Unresolved reference: viewDidLoad
e: /Users/username/dev/engineEmi/engineEmi_Template/src/commonMain/kotlin/Main.kt: (39, 13): Unresolved reference: start
它只是没有找到库(包).切换回5.6.4,可以再次找到该库
It just doestnt find the library (package). Switching back to 5.6.4 lets it find the lib again
推荐答案
最后我能够修复它.
问题是我可以复制的两件事的组合:
The problem was a combination of two things as I could reproduce:
1. Kotlin多平台发布
您不需要使用kotlin手动创建出版物 multipatform:与发布普通的Kotlin/JVM或Java相比 项目,则无需通过 发布{...}(请参见此处:
You do NOT need to create the publications manually with kotlin multipatform: Compared to publishing a plain Kotlin/JVM or Java project, there is no need to create publications manually via the publishing { ... } (see here: 1)
kotlin {}
块几乎可以为您做任何事情.您只需要在publishing {}
块中添加发布的存储库即可.例如:
The kotlin {}
block does almost anything for you. You only have to add the repository you publish to in the publishing {}
block. For example::
publishing {
publications {
val kotlinMultiplatform by getting {
repositories {
maven {
credentials {
username = "USERNAME"
password = System.getenv("bintrayApiKey")
}
url = uri(
"https://api.bintray.com/maven/ORG/REPO/ARTIFACT/"
)
}
}
}
}
}
2. gradle发布任务
以某种方式,任务publishAllPublicationsToMavenRepository
对我不起作用.您确实需要使用publish
任务
Somehow, the task publishAllPublicationsToMavenRepository
did not work for me. You really need to use the publish
task
这篇关于Gradle 6.0打破了源集依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!