Creating a distribution zip file without parent directory

I’m using shadow to create a distribution file containing fat jar with dependencies and all dist files together. The resulting directory tree in the Zip file looks like

project-1.0-SNAPSHOT/
├── Dockerfile
├── Dockerrun.aws.json
├── bin
│   ├── project
│   └── project.bat
├── config
│   └── beanstalk.yml
└── lib
    └── project-1.0-SNAPSHOT-all.jar

The issue is that to deploy on ElasticBeanstalk, the Dockerfile has to be in the root directory of the zip and that there is no top directory.

I tried

distShadowZip {
    into ''
}

to no success, but adding a path into the into block actually wraps it into another subdirectory.

Could you lead me into the right direction? Thanks

Hi @vvondra

If you don’t specify directory by into method, you can obtain zip file as you wish.

Here is a sample of archiving task.

task archiveZip(type: Zip, dependsOn: 'jar') {
    baseName = 'project'

    from fileTree('resources') // do not specify directory

    // if you would like to put file into some directory, specify it.
    from (tasks.jar.archivePath) {
        into 'lib'
    }
}

with a project structure…

project-root
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── resources
│   ├── Dockerfile
│   ├── Dockerrun.aws.json
│   ├── bin
│   │   ├── project
│   │   └── project.bat
│   └── config
│       └── beanstalk.yml
├── settings.gradle
└── src
    └── main
        └── java
            └── org
                └── sample
                    └── Hello.java

archiveZip task will generate a zip file with the structure as follows…

├── Dockerfile
├── Dockerrun.aws.json
├── bin
│   ├── project
│   └── project.bat
├── config
│   └── beanstalk.yml
└── lib
    └── project-root-1.0.jar