使用Spring-boot Gradle插件,但从依赖管理获得spring boot版本

时间:2016-08-29 08:45:11

标签: spring gradle gradle-plugin spring-io

我有一个Gradle设置,我目前需要硬编码spring-boot版本。是否可以通过依赖管理来实现此目的?问题发生在包含实际代码的项目模块中。我需要打电话给:

application/json

为此,我需要应用springBoot { requiresUnpack = ["com.example:util"] } 。要使该插件可用,我需要依赖spring-boot plugin。为此,我需要指定"org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"硬编码...

这是我的父gradle文件:

springBootVersion

这是我的模块gradle文件:

buildscript {

    ext {
        springBootVersion = '1.4.0.RELEASE'
    }
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
        classpath 'io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE'
    }
}

plugins {
    id "io.spring.dependency-management" version "0.6.0.RELEASE"
}

group 'test'


repositories {
    mavenCentral()
}

allprojects {
    apply plugin: 'java'
    apply plugin: 'io.spring.dependency-management'

    dependencyManagement {
        imports {
            // Note that these two BOM's are not always easy to combine, always define cloud first and try to find versions with same version of spring-boot when upgrading.
            mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Brixton.SR5'
            mavenBom 'io.spring.platform:platform-bom:2.0.7.RELEASE'

        }
    }
}

如果我在父gradle文件中删除了对group = "test" apply plugin: 'spring-boot' apply plugin: 'io.spring.dependency-management' sourceCompatibility = 1.8 targetCompatibility = 1.8 // Temporary fix for jersey springBoot { requiresUnpack = ["com.example:util"] } 的依赖关系,那么我就无法在模块gradle文件中使用spring-boot-gradle-plugin,如果没有,则不会定义gradle DLS方法apply plugin: 'spring-boot'。 ..

我是否可以在父gradle文件中硬编码springBoot {来实现此目的?

0 个答案:

没有答案