如何将存储库部分移至父build.gradle配置?

时间:2019-04-01 12:47:08

标签: java spring-boot gradle build.gradle

我的项目具有以下结构:

-root project
 -settings.gradle
 -build.gradle
 -moduleA
  -build.gradle
  moduleB
  -build.gradle

我在每个模块中都有此配置:

repositories {
    maven {
        credentials {
            username "username"
            password "password"
        }
        url "http://artifactory..."
    }
}

我不想复制此配置,而是要将其移动到父配置。我该怎么办?

现在我有这个build.gradle(父母):

group = 'my.group'
version = '0.0.1-SNAPSHOT'

ext {
    springBootVersion = '2.1.3.RELEASE'
    cxfVersion = '3.2.7'
    uuidGeneratorVersion = '3.1.5'
    commonLang3Version = '3.7'
    encacheVersion = '2.6.11'
    logstashVersion = '5.2'
}

repositories {
    maven {
        credentials {
            username "username"
            password "password"
        }
        url "http://artifactory...."
    }
}

1 个答案:

答案 0 :(得分:1)

假设moduleAmoduleB是子项目,请在build.gradle中这样定义它:

subprojects {
    repositories {
        maven {
            credentials {
                username "username"
                password "password"
            }
            url "http://artifactory...."
        }
    }
}