[GRADLE-2038] Tar decompression should also understand .bz2 and .gz extensions Created: 09/Jan/12  Updated: 04/Jan/13  Resolved: 13/Mar/12

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

Type: Improvement
Reporter: Ben Jansen Assignee: René Gröschke (Inactive)
Resolution: Fixed Votes: 0

Attachments: File tbz-project.tbz    

 Description   

I receive an error when attempting to utilize the compressed tar support that was added to tarTree() in 1.0-m7. See also http://forums.gradle.org/gradle/topics/gradle_1_0_milestone_7_snapshot_available#reply_7555264

I have attached a gradle project which can be used to reproduce this behavior. Just run ./gradlew. I have also tried a gzipped tar file, with the same result.

aogail@bjansen-miroku> ./gradlew --stacktrace
:extract

FAILURE: Build failed with an exception.

* What went wrong:
Unable to expand TAR '/localhome/aogail/Development/cap/tbz/test.tar.bz2'
  The tar might be corrupted or it is compressed in an unexpected way.
  By default the tar tree tries to guess the compression based on the file extension.
  If you need to specify the compression explicitly please refer to the DSL reference.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleException: Unable to expand TAR '/localhome/aogail/Development/cap/tbz/test.tar.bz2'
  The tar might be corrupted or it is compressed in an unexpected way.
  By default the tar tree tries to guess the compression based on the file extension.
  If you need to specify the compression explicitly please refer to the DSL reference.
	at org.gradle.api.internal.file.archive.TarFileTree.visit(TarFileTree.java:80)
	at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:96)
	at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree.visit(AbstractFileTree.java:136)
	at org.gradle.api.internal.file.AbstractFileTree.getFiles(AbstractFileTree.java:37)
	at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:39)
	at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:60)
	at org.gradle.api.internal.changedetection.DefaultFileSnapshotter.snapshot(DefaultFileSnapshotter.java:42)
	at org.gradle.api.internal.changedetection.InputFilesChangedUpToDateRule.create(InputFilesChangedUpToDateRule.java:35)
	at org.gradle.api.internal.changedetection.CompositeUpToDateRule.create(CompositeUpToDateRule.java:35)
	at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$HistoricExecution.calcCurrentState(DefaultTaskArtifactStateRepository.java:80)
	at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$HistoricExecution.isUpToDate(DefaultTaskArtifactStateRepository.java:88)
	at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:128)
	at org.gradle.api.internal.changedetection.ShortCircuitTaskArtifactStateRepository$ShortCircuitArtifactState.isUpToDate(ShortCircuitTaskArtifactStateRepository.java:77)
	at org.gradle.api.internal.changedetection.FileCacheBroadcastTaskArtifactStateRepository$1.isUpToDate(FileCacheBroadcastTaskArtifactStateRepository.java:37)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:44)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
	at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:243)
	at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)
	at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)
	at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)
	at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
	at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
	at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
	at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
	at org.gradle.cache.internal.DefaultCacheAccess$1.create(DefaultCacheAccess.java:111)
	at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:126)
	at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:109)
	at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:103)
	at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
	at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
	at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
	at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
	at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:152)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:76)
	at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
	at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
	at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
	at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
	at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:238)
	at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:222)
	at org.gradle.launcher.Main.doAction(Main.java:48)
	at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
	at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
	at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
	at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
	at org.gradle.launcher.Main.main(Main.java:39)
	at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
	at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
	at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
	at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
	at org.gradle.wrapper.Wrapper.execute(Wrapper.java:87)
	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:37)
Caused by: org.gradle.api.GradleException: Could not copy tar entry /localhome/aogail/Development/cap/tbz/test.tar.bz2!BZh91AY&SYニ﾿Tf to '/localhome/aogail/Development/cap/tbz/build/tmp/expandedArchives/test.tar.bz2_5gvt8s28hfpn622b7g6obpcutr/BZh91AY&SYニ﾿Tf'.
	at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:65)
	at org.gradle.api.internal.file.archive.TarFileTree$DetailsImpl.getFile(TarFileTree.java:122)
	at org.gradle.api.internal.file.AbstractFileTree$1.visitFile(AbstractFileTree.java:39)
	at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree$1.visitFile(AbstractFileTree.java:145)
	at org.gradle.api.internal.file.archive.TarFileTree.visitImpl(TarFileTree.java:92)
	at org.gradle.api.internal.file.archive.TarFileTree.visit(TarFileTree.java:71)
	... 61 more
Caused by: java.lang.IllegalArgumentException: Negative time
	at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:62)
	... 66 more


 Comments   
Comment by Szczepan Faber [ 09/Jan/12 ]

Oh gotcha!

The extension gradle expects is: 'tbz2'. To solve your problem either change the extension or do:

from(tarTree(resources.bzip2('test.tar.bz2')))

Let's keep the issue open - I want to tweak the docs / exception messages or logging to make that obvious.

Thanks a lot for an excellent bug report with neat sample project

Comment by Adam Murdoch [ 09/Jan/12 ]

Shouldn't we change the detection to understand .bz2 as well, particularly given that we've decoupled decompression from untarring? Also, we should change it to understand .gz for gzipped resources.

Comment by Szczepan Faber [ 10/Jan/12 ]

Good idea. Let's do that.

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