0

I have multi-module gradle project with kotlin dsl called stream-data-processing. It is in github here.

The build.gradle.kts file of root project is -

    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 -

   rootProject.name = "stream-data-processing"
   include ("word-count-demo")

I have some sub-project called word-count-demo.

The build.gradle.kts file for this sub project is -

    plugins {
        java

        application
    }

But the classes in kafka-streams are not available in word-count-demo.

Idea Compilation error

when I did `gradle word-count-demo:dependencies, it doesn't show the kafka dependencies available to the sub project.

I don't want to explicitly specify the dependencies in every project.

What is the mistake that went wrong here?

user51
  • 8,843
  • 21
  • 79
  • 158

1 Answers1

1

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:

allprojects {
    group ...
    version ...
    repositories ...
}

subprojects {
    dependencies {
        compile("org.apache.kafka:kafka-streams:2.2.0")
        testImplementation("junit:junit:4.12")
    }
}
mig4
  • 341
  • 2
  • 5