Я пытался 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
.Чтобы другие разработчики из моей команды могли сосредоточиться на том, что им действительно важно.