首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我们可以通过在Gradle中使用脚本插件来包含buildscript吗?

我们可以通过在Gradle中使用脚本插件来包含buildscript吗?
EN

Stack Overflow用户
提问于 2016-07-13 07:29:21
回答 1查看 1K关注 0票数 1

我试图从外部gradle脚本中包含buildscript,但是经常会出现一些错误。然后我找到了这个论坛主题,但它在2012年讨论过。

https://discuss.gradle.org/t/how-do-i-include-buildscript-block-from-external-gradle-script/7016

那以后有什么变化吗?

这是我的代码:

myPlugin.gradle

代码语言:javascript
复制
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

代码语言:javascript
复制
apply from: "../myProject/myPlugin.gradle"

在下面抛出错误:

代码语言:javascript
复制
> Plugin with id 'spring-boot' not found.

为了使其工作,我将build.gradle更改为以下代码:

代码语言:javascript
复制
buildscript {
ext {
    springBootVersion = '1.3.5.RELEASE'
}
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
}
}

apply from: "../myProject/myPlugin.gradle"

效果很好。

谢谢..。

EN

回答 1

Stack Overflow用户

发布于 2016-07-13 07:33:41

不,没有变化。这仍然有效。我最近回答了关于这个话题的question,所以没有什么改变。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38345248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档