【发布时间】:2016-07-13 20:01:43
【问题描述】:
我试图从外部 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"
效果很好。
谢谢...
【问题讨论】:
标签: gradle gradle-plugin