Warm tip: This article is reproduced from serverfault.com, please click

how to put folder into a tar file with gradle

发布于 2016-12-14 07:10:45

I am new to gradle. I want to create a filename.tar file which includes (filename.war and data/config/*.properties). The war file stays inside build/libs. The requirement is: inside tar file, we need to have folder data/config and all properties files under that folder. The war file stays in the same level with data folder.

Here is what i have,

task tarz(type: Tar) {
 archiveName = 'filename'
 from 'build/libs','data/config'
 include '*.war','*.properties'
 destinationDir = file('build/tar')
 extension 'tar'
 compression = Compression.GZIP
}

this above script is only copy properties files into tar, not the folder. And the name of the file is 'filename', not 'filename.tar'

Please help me.

Questioner
David
Viewed
0
David 2016-12-23 01:13:10

here is what i have done

task tarz(type: Tar) {
 archiveName = 'aaa.tar'
 into ('/'){
    from 'build/libs'
    include '*.war'
 }

 into ('data/config'){
    from 'data/config'
    include '*.properties.*'

 }

destinationDir  file('build/tar')
 extension 'tar'
 compression = Compression.GZIP
}