War not generated by gradle for Spring boot

Viewed 3978

I have simple spring boot application and it runs as standalone app. I started conversion to WAR using online guides.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.4.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'

bootRun {
    addResources = true
}

war {
    baseName = 'simulator'
    version =  '1.0.0'
}

repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-freemarker")
    compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

Initializer:

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }
}

Assembling:

c:\dev\projekty\Simulator>gradlew war
:compileJava
:processResources
:classes
:war
BUILD SUCCESSFUL
Total time: 3.96 secs

But there is no war created. Why?

3 Answers

SpringBoot disable war task. Just re-enable it in the script. I didn't like BootWar which was creating lib-provided folder and other org folder classes for traditional war deployment.

war {
    enabled= true
}
Related