我尝试了apply from:"other.gradle"
但不行。我的项目有很多模块,所有模块都需要使用一些插件,如development-manage
和maven-publish
。所以我想简化build.gradle
中的脚本。
这些脚本在所有模块中:
buildscript {
repositories {
maven url{ "mynexusUrl" }
mavenLocal()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.5.RELEASE'
}
}
apply plugin: "io.spring.dependency-management"
apply plugin: "maven-publish"
dependencyManagement {
imports {
// we publish a mavenParent pom into the nexus.
mavenBom 'com.xxx.xxx:xx.xx:1.0-SNAPSHOT'
}
}
// above code is for mavenBom
// and all modules I need copy these code into the `build.gradle` file.
// bellow is for publish plugin
task sourceJar(type: Jar, dependsOn: classes){
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives jar
archives sourceJar
}
publishing {
// here I have many script too
}
正如您所看到的,我只想将这些脚本移动到一个文件中,并像import
命令一样导入这些代码。因此,我团队中的其他开发人员可以专注于他们真正关心的事情。