[英]dependencies added in subprojects.forEach in gradle multi-module kotlin DSL is not visible to sub projects
I have multi-module gradle project with kotlin dsl called stream-data-processing. 我有一个带有kotlin dsl的多模块gradle项目,称为流数据处理。 It is in github here . 它在github 这里 。
The build.gradle.kts
file of root project is - 根项目的build.gradle.kts
文件是 -
plugins {
base
java
}
allprojects {
group = "streams-data-processing"
version = "1.0"
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
subprojects.forEach {
compile("org.apache.kafka:kafka-streams:2.2.0")
testImplementation("junit:junit:4.12")
}
}
}
settings.gradle.kts
is - settings.gradle.kts
是 -
rootProject.name = "stream-data-processing"
include ("word-count-demo")
I have some sub-project called word-count-demo
. 我有一些名为word-count-demo
子项目。
The build.gradle.kts
file for this sub project is - 此子项目的build.gradle.kts
文件是 -
plugins {
java
application
}
But the classes in kafka-streams
are not available in word-count-demo
. 但是kafka-streams
中的类在word-count-demo
中不可用。
when I did `gradle word-count-demo:dependencies, it doesn't show the kafka dependencies available to the sub project. 当我做`gradle word-count-demo:dependencies时,它没有显示子项目可用的kafka依赖项。
I don't want to explicitly specify the dependencies in every project. 我不想在每个项目中明确指定依赖项。
What is the mistake that went wrong here? 这里出错的错误是什么?
It appears this would be adding the same dependencies multiple times. 看起来这将是多次添加相同的依赖项。 I think you need to flip it around and call dependencies
inside subprojects
, and outside of allprojects
, like so: 我认为你需要翻转它并在subprojects
调用dependencies
,并在所有subprojects
之外 allprojects
,如下所示:
allprojects {
group ...
version ...
repositories ...
}
subprojects {
dependencies {
compile("org.apache.kafka:kafka-streams:2.2.0")
testImplementation("junit:junit:4.12")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.