Provided dependencies with Spring Boot, the War plugin and IntelliJ Idea

Here’s a workaround that goes the opposite way: Keep the dependencies in compile configuration (IntelliJ maps them correctly to “Compile” scope), but prevent them from being added to the WAR lib folder. Instead they are put in lib-provided as with providedRuntime configuration.

    configurations {
        customProvidedRuntime
    }

    dependencies {
        compile(
            // Spring Boot dependencies
        )

        customProvidedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    }

    war {
        classpath = files(configurations.runtime.minus(configurations.customProvidedRuntime))
    }

    springBoot {
        providedConfiguration = "customProvidedRuntime"
    }
1 Like