[GRADLE-673] file permissions not preserved in Tar task Created: 02/Oct/09  Updated: 04/Jan/13  Resolved: 15/Feb/12

Status: Resolved
Project: Gradle
Affects Version/s: 0.8
Fix Version/s: 1.0-milestone-9

Type: Bug
Reporter: Philip Crotwell Assignee: Peter Niederwieser
Resolution: Fixed Votes: 4

Issue Links:
Superceded by GRADLE-679 Implement native archive handling Resolved


I have some sh scripts that I want to package in a tar. Example tasks
using Wrapper are below. The issue is that gradlew has a+x permissions
in the directory before the tar, but when untarred it is rw-rr-.
I think the Tar task should preserve file permissions.

task wrapper(type: Wrapper)

{ gradleVersion = '0.8' jarPath = 'gradleWrapper' }

task testTarDist(type: Tar, dependsOn: 'wrapper') {
dirName = 'testWrapper'
tarFileSet(dir: '.')

{ include('gradleWrapper/**') include('gradlew') include('gradlew.bat') prefix = dirName }


Adam Murdoch said:
You can use the 'filemode' attribute on tarFileSet to specify the permisions for files:
tarFileSet(dir: '.', filemode: '755')

{ ... }

so there is a workaround, but it seems like the default for tar should be to keep the preexisting permissions instead of defaulting to rw-rr-.

Comment by Philip Crotwell [ 02/Oct/09 ]

It is "fileMode" instead of "filemode" in the workaround, so:
tarFileSet(dir: '.', fileMode: '755')

{ ... }
Comment by Peter Niederwieser [ 15/Feb/12 ]

merged https://github.com/gradle/gradle/pull/62

Generated at Wed Jun 30 11:35:55 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.