问题
I am trying to create an executable jar for functional tests by exploding the dependency jars, using gradle task of type Jar.
Cucumber-1.1.3 is one of the dependencies. I am using gradle 1.1 with JVM 1.6 (company standards)
I get the following error :
org.gradle.api.GradleException: Could not expand ZIP '/dev/shm/263985/transformer/caches/artifacts-14/filestore/info.cukes/cucumber-java/1.1.3/jar/4b389fbe494942b319518d27ae38571f477967f6/cucumber-java-1.1.3.jar'. at org.gradle.api.internal.file.archive.ZipFileTree.visit(ZipFileTree.java:97) 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:247) 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:129) 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:155) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:110) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:78) at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38) at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39) at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50) at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:30) at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:22) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:200) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:173) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:138) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) at org.gradle.launcher.Main.doAction(Main.java:48) at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) at org.gradle.launcher.Main.main(Main.java:39) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32) at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: org.gradle.api.GradleException: Could not copy zip entry /dev/shm/263985/transformer/caches/artifacts-14/filestore/info.cukes/cucumber-java/1.1.3/jar/4b389fbe494942b319518d27ae38571f477967f6/cucumber-java-1.1.3.jar!cucumber/api/java/ar/??.class to '/dev/shm/263985/transformer/target/tmp/expandedArchives/cucumber-java-1.1.3.jar_6mn6efsv2arssmg9fup79f3fm5/cucumber/api/java/ar/??.class'. at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:68) at org.gradle.api.internal.file.archive.ZipFileTree$DetailsImpl.getFile(ZipFileTree.java:124) 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.ZipFileTree.visit(ZipFileTree.java:90) ... 61 more
Caused by: java.io.IOException: Failed to set file permissions 420 on file ??.class. errno: 84 at org.gradle.internal.nativeplatform.filesystem.LibcChmod.chmod(LibcChmod.java:39) at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.chmod(GenericFileSystem.java:67) at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:65) ... 65 more
Note: This works fine when you use gradle 1.1 with JVM 1.7.
Let me know if you guys know why this is happening and is there any fix or alternatives. Thanks in advance!!
回答1:
You may be encountering an issue we've run into. I'm not sure we 100% understand it, but it appears that when unzipping an archive that has read-only files in it gradle can struggle. Gradle attempts to check the zip against any files it has already unzipped in order to know if the unzipping task is up-to-date, and this process can blow up if the archive has read-only files.
Notice lines like this in your stacktrace:
org.gradle.api.internal.changedetection.CompositeUpToDateRule.create
Caused by: java.io.IOException: Failed to set file permissions 420 on file
Not quite a smoking gun, but a pretty strong implication. Our solution (hacky, I'll admit) was to use the following code:
def fixExpandedArchivesForLinux() {
// This interesting hackery fixes the expandedArchives directory
// to avoid the read-only extracted ZIP file contents issue.
def dir = new File(buildDir, "tmp/expandedArchives")
FilePermissions.chmodRecursively(dir, 0200)
}
You can put that in a do first to allow gradle to re-expand the archive while it checks the up-to-date status.
回答2:
I got a similar issue when working with android libraries (aars). I got it working by deleting the directories where the aars are exploded.
def str = "rm -rf "+buildDir.absolutePath+"/exploded-aar" str.execute()
回答3:
I just had the same problem involving a file called "??.class" in cucumber. The exception cause from a run of
./gradlew connectedCheck --debug --stacktrace
showed the following root cause
Caused by: net.rubygrapefruit.platform.NativeException:
Could not set UNIX mode on .../app/build/tmp/expandedArchives/cucumber-java-1.2.4.jar_bkzp93af0tagkjvsr5vkgywjd/cucumber/api/java/ar/??.class:
could not convert string to current locale
It turns out that I had a problem with my locale for which I had previously ignored all warnings from other command line tools.
I checked which locales are mentioned in /etc/locale.conf
, uncommented the corresponding lines in /etc/locale.gen
and ran
sudo locale-gen
to regenerate the locales.
After this, the file names showed up like ਅਤੇ.class
and the unzipping worked flawlessly.
来源:https://stackoverflow.com/questions/16469462/getting-file-permissions-error-when-exploding-the-cucumber-jvm-jar