Search code examples
gradledependency-managementproject-structure

How to set a dependency for a project with all subprojects?


I don't like that I repeat every repository dependency (let us say, junit), for the main project and for subprojects. Is there a possibility to make the subproject to use the dependencies of the main project. Or is there another way to escape that repetition?


Solution

  • root/build.gradle

    allprojects {
        if (plugins.hasPlugin('java')) {
            dependencies {
                testCompile 'junit:junit:4.12'
            }
        }
    }