Oleksandr Cherniaiev
Oleksandr Cherniaiev

Reputation: 813

Gradle 7: How to create folders in ZIP task?

I try to create zip-task in Gradle 7 and I want to have different folders for different files.

task myZipTask(type: Zip) {
    from 'first/source'
    into 'firstFolderInsideZipFile'

    from 'second/source'
    into 'secondFolderInsideZipFile'
}

It obviously doesn't work like this, but is there a way to implement it?

Upvotes: 0

Views: 165

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27220

You should be able to do something like this:

plugins {
    id 'java'
}
task myZipTask(type: Zip) {
    from('first/source') {
        into('firstFolderInsideZipFile')
    }
    from('second/source') {
        into('secondFolderInsideZipFile')
    }
}

Upvotes: 1

Related Questions