2

I'm following the latest SpringBoot gradle plugin reference in order to setup a SpringBoot project that can build a uberjar.

Below is the full content of build.gradle.kts:

plugins {
    java
    application
    id("org.springframework.boot") version "2.2.1.RELEASE"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
}

repositories {
    jcenter()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-web")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    testImplementation("org.testng:testng:6.14.3")
}

application {
    // Define the main class for the application.
    mainClassName = "com.demo.App"
}

val test by tasks.getting(Test::class) {
    // Use TestNG for unit tests
    useTestNG()
}

dependencyManagement {
    imports {
        mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
    }
}

Unfortunately, when I run gradle commands I get the following error:

> Configure project :
e: /Users/xux/Documents/toys/web/build.gradle.kts:15:5: Unresolved reference: providedRuntime

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/xux/Documents/toys/web/build.gradle.kts' line: 15

* What went wrong:
Script compilation error:

  Line 15:     providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
               ^ Unresolved reference: providedRuntime

1 error

I'm using Java 1.8.0_201, Gradle 6.0, Kotlin 1.3.50, Mac OS X 10.15.1 x86_64.

adamsmith
  • 5,759
  • 4
  • 27
  • 39
  • 2
    `providedRuntime` is a configuration exposed by the Gradle `war` plugin (see https://docs.gradle.org/current/userguide/war_plugin.html#sec:war_dependency_management) . You need to apply this plugin in your build script (default behavior with Springboot Gradle plugin is to produce executable `jar`, not `war) – M.Ricciuti Nov 26 '19 at 13:06
  • I just need a uberjar, it works without `providedRuntime`. Thanks @M.Ricciuti! – adamsmith Nov 27 '19 at 04:51

0 Answers0