Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle replacing Maven assembly plugin

I'm fairly new to Gradle, and trying to port an existing Maven pom.xml that makes extensive use of maven-assembly-plugin to create various zip files.

In the example below, I'm getting files from various subdirectories (with particular extensions), and then mapping them in a flat structure to a ZIP file.

task batchZip(type: Zip) {
  from fileTree('src/main/sas') {
    include('**/*.sas')
    include('**/*.ds')
  }.files
}

This puts all the files in the root of the zip. What I ideally need though, is for the files to live under a particular path in the root of the zip, e.g. /shared/sas.

Is there a way to do this without first copying all the files to a local directory and then zipping that up?

like image 826
RCross Avatar asked Jul 10 '26 01:07

RCross


2 Answers

task batchZip(type: Zip) {
    into('shared/sas') {
        from { fileTree('src/main/sas').files }
        include('**/*.sas')
        include('**/*.ds')
    }
}
like image 82
Peter Niederwieser Avatar answered Jul 14 '26 23:07

Peter Niederwieser


Have a look at the docs. It seems that if You specify appropriate into You'll get the result You're looking for.

like image 25
Opal Avatar answered Jul 14 '26 23:07

Opal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!