How do you build a folder into the .jar root of a

2019-08-26 06:31发布

问题:

AWS elastic beanstalk requires a .ebextensions folder at the root of your jar to configure elastic beanstalk, but I can't figure out how to get a folder to the root of the jar.

With this gradle config I can change the location of a folder:

compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }

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

That moves the folder .ebextensions from the root of my project (not src/main/resources) to

my.jar
 -> BOOT-INF
    -> classes
       -> .ebextensions

I was hoping I could just make it into '../../.ebextensions' but that doesn't work. Is this just impossible? Do I need to figure out how to manually unpack the jar, insert my folder, and then repack it or something?

回答1:

Can configure gradle task called bootJar by following way:

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

Packaging executable jars says:

Executable jars can be built using the bootJar task. The task is automatically created when the java plugin is applied and is an instance of BootJar. The assemble task is automatically configured to depend upon the bootJar task so running assemble (or build) will also run the bootJar task.

Or alternatively you can configure jar task:

jar {
     from('.ebextensions') {
        into('.ebextensions')
    }
}

Packaging executable and normal