我使用的是Gradle 3.2.1(参见wrapper
任务)。我有:
(1)此build.gradle
脚本:
buildscript {
repositories {
mavenLocal()
}
apply from: 'gradle/buildscript.gradle', to: buildscript
}
plugins {
// ...
}
repositories {
//mavenLocal()
mavenCentral()
}
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
group 'io.shido'
version "${rootProject.version}"
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${spring_boot_version}")
}
}
dependencies {
apt "org.projectlombok:lombok:${lombok_version}"
compile 'org.springframework.boot:spring-boot-starter-actuator'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
task wrapper(type: Wrapper) {
gradleVersion '3.2.1'
}
(2)此buildscript.gradle
(位于${project.root}/gradle
内):
//
// Executed in the context of `buildscript { }`
repositories {
mavenLocal()
}
dependencies {
classpath("io.spring.gradle:dependency-management-plugin:${spring_dependencies_management_version}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}")
}
(3)和gradle.properties
(位于${project.root}
):
#
# Global Project's Properties/Settings
rootProject.version = 0.1.0-SNAPSHOT
#
# Dependency Versions
spring_boot_version = 1.4.2.RELEASE
spring_dependencies_management_version = 0.6.0.RELEASE
问题是Gradle 在我进行此设置后无法再访问gradle.properties
(对于任何脚本)中定义的键/值对。因此,我无法在。{/ p>中访问spring_dependencies_management_version
,spring_boot_version
(例如)的值。
任何线索?
注意:如果我不将Gradle配置拆分为不同的文件,一切都很好,但这不是一个选项。