我试图从外部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"效果很好。
谢谢..。
发布于 2016-07-13 07:33:41
不,没有变化。这仍然有效。我最近回答了关于这个话题的question,所以没有什么改变。
https://stackoverflow.com/questions/38345248
复制相似问题