我们可以通过在Gradle中使用脚本插件来包含buildscript吗? [英] Can we include buildscript by using script plugins in Gradle?
问题描述
我试图从外部gradle脚本中包含buildscript,但是不断出错.然后我找到了这个论坛的主题,但是在2012年进行了讨论.
I was trying to include buildscript from an external gradle script but constantly getting some error. Then I found this forum subject, but it was discussed in 2012.
https://discuss.gradle.org/t/how-do-i-include-buildscript-block-from-external-gradle-script/7016
从那以后有什么变化吗?
Any changes since then?
这是我的代码:
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 更改为以下代码:
In order to make it work, I change the build.gradle to this code:
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply from: "../myProject/myPlugin.gradle"
哪个工作正常.
谢谢...
推荐答案
否,没有更改.这仍然有效.我已经回答了问题a>最近与该主题相关的SO,因此没有任何变化.
No, no changes. This is still valid. I've answered to the question on SO related to this topic recently so nothing has changed.
这篇关于我们可以通过在Gradle中使用脚本插件来包含buildscript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!