Clean way of adding .ebextensions to Spring Boot Jar using Gradle

For Spring Boot 2 (Gradle) if .ebextensions is located at the root of your project, use the following task:

bootJar {
    from('./.ebextensions') { into '.ebextensions' }
}

or

bootWar {
    from('./.ebextensions') { into '.ebextensions' }
}

This way Gradle will copy .ebextensions into the root of the application package.

But if you prefer convention over configuration, move .ebextensions folder inside src/main/resources. The content of resources directory is packaged automatically in /BOOT-INF/classes/ (no scripting required). And the .ebextensions directory will be discovered by EB deployment scripts when unpacked.


I'm still working on deploying Spring Boot to EBS myself...

I think the folder has to be called .ebextensions (notice the leading dot). So you would say into('./.ebextensions') instead of into('ebextensions').

Alternatively, you might try uploading a ZIP file containing your JAR and your .ebextensions folder:

task zip(type: Zip, dependsOn: bootRepackage) {
    from ('./.ebextensions') {
        into '.ebextensions'
    }
    from (jar.outputs.files) {
        into '.'
    }
    destinationDir project.buildDir
}

I have my .ebextensions at the root of my project. This seems to work for me.

war { from ('./.ebextensions') { into '.ebextensions' } }


If you move your src/main/ebextensions folder to src/main/resources/.ebextensions, it will be automatically copied by the jar task to the root of the .jar (along with any other files in /resources), where EBS expects it, without any additional scripting.

That's about as clean as you can get!