Spring-boot: Support Gradle 6

Created on 19 Oct 2019  路  6Comments  路  Source: spring-projects/spring-boot


Hello,

I'm using Spring Boot 2.2.0.RELEASE with Gradle 6.0-rc-1 and during build Gradle warns with next message:

$ ./gradlew --warning-mode all ... 
> Configure project :
The baseName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveBaseName property instead.
        at Build_gradle$4$3.invoke(build.gradle.kts:61)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

Here is my build.gradle.kts file:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.dsl.SpringBootExtension
import org.springframework.boot.gradle.tasks.bundling.BootJar

plugins {
    kotlin("jvm") version "1.3.50"
    kotlin("plugin.spring") version "1.3.50"
    id("org.springframework.boot") version "2.2.0.RELEASE"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
}

allprojects {
    group = "com.example"
    version = "1.0.0-SNAPSHOT"
    java.sourceCompatibility = JavaVersion.VERSION_1_8
}

repositories {
    mavenCentral()
}

dependencies {
    runtimeOnly("org.springframework.boot:spring-boot-devtools")

    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
    implementation("org.webjars:webjars-locator:0.37")
    implementation("org.webjars:Semantic-UI:2.4.1")

    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
    }
    testImplementation("io.projectreactor:reactor-test")
}

tasks {
    withType<Test> {
        useJUnitPlatform()
        testLogging {
            showExceptions = true
            showStandardStreams = true
            events(
                    org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED,
                    org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED,
                    org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
            )
        }
    }
    withType<KotlinCompile> {
        kotlinOptions {
            freeCompilerArgs = listOf("-Xjsr305=strict")
            jvmTarget = "1.8"
        }
    }
    withType<BootJar> {
        launchScript() //                  <--- warning is here, line: 61
    }
    withType<Wrapper> {
        gradleVersion = "6.0-rc-1"
    }
}

springBoot {
    buildInfo() // http :8080/actuator/info
}

defaultTasks("clean", "build")

I have quickly looked in spring-boot-gradle-plugin and seem like warning comes because of these usages from https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java#L53 method: org.springframework.boot.gradle.tasks.bundling.LaunchScriptConfiguration#LaunchScriptConfiguration(org.gradle.api.tasks.bundling.AbstractArchiveTask)

Thanks!


Regards,
Maksim

enhancement

Most helpful comment

I have a branch that contains the changes that are necessary to avoid deprecation warnings with Gradle 6. There's a bit of reflection involved but it's not too bad. It's currently testing against Gradle 6.0-rc2. I'd like to wait for 6.0 to GA before merging.

All 6 comments

Thanks for the report. We don't test against or support Gradle 6.0 at the moment. This particular warning seems fairly easy to fix. We'll have to see what else is involved.

I have a branch that contains the changes that are necessary to avoid deprecation warnings with Gradle 6. There's a bit of reflection involved but it's not too bad. It's currently testing against Gradle 6.0-rc2. I'd like to wait for 6.0 to GA before merging.

This needs to be tweaked a little to handle archive base name properly.

I get another deprecation warning with Gradle 6 and spring-boot-starter-test:

The testCompile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the testImplementation configuration instead.
at Build_gradle$3.invoke(build.gradle.kts:269)

Where the line 269 in my build.gradle.kts is

testImplementation("org.springframework.boot:spring-boot-starter-test")

@darioseidl That doesn't seem to be related to Spring Boot's Gradle plugin but to your build script and Gradle itself. If you believe it is caused by Boot's Gradle plugin, can you please provide a small sample that reproduces the problem and we'll take a look.

OK, thanks, you're probably right. I can't seem to reproduce it in a simply project.

Was this page helpful?
0 / 5 - 0 ratings