我试图从外部gradle脚本中包含buildscript,但不断收到一些错误。然后我找到了这个论坛主题,但是在2012年进行了讨论。
https://discuss.gradle.org/t/how-do-i-include-buildscript-block-from-external-gradle-script/7016
此后有任何变化吗?
这是我的代码:
myPlugin.gradle
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'spring-boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
/*
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile('org.springframework.boot:spring-boot-starter-test')
*/
}
}
的build.gradle
apply from: "../myProject/myPlugin.gradle"
抛出以下错误:
> Plugin with id 'spring-boot' not found.
为了使其有效,我将 build.gradle 更改为此代码:
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply from: "../myProject/myPlugin.gradle"
哪种方法正常。
...谢谢