In Gradle, how do I declare common dependencies in a single place?

后端 未结 7 1728
余生分开走
余生分开走 2020-11-29 16:08

In Maven there is a very useful feature when you can define a dependency in the section of the parent POM, and reference that depen

7条回答
  •  情书的邮戳
    2020-11-29 16:42

    This blog post suggest managing dependencies and groups as configurations: https://www.javacodegeeks.com/2016/05/manage-dependencies-gradle-multi-project-build.html

    I have not tried it myself, but it looks interesting.

    Root project build.gradle

    subprojects {
      configurations {
        commonsIo
      }
    
      dependencies {
        commonsIo 'commons-io:commons-io:2.5'
      }
    }
    

    Sub-project build.gradle

    configurations {
      compile.extendsFrom commonsIo
    }
    

提交回复
热议问题