1

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!!

4

3 回答 3

2

您可能会遇到我们遇到的问题。我不确定我们是否 100% 理解它,但似乎在解压缩包含只读文件的存档时,gradle 可能会遇到困难。Gradle 会尝试根据已解压缩的任何文件检查 zip,以了解解压缩任务是否是最新的,如果存档包含只读文件,则此过程可能会崩溃。

在你的堆栈跟踪中注意这样的行:

org.gradle.api.internal.changedetection.CompositeUpToDateRule.create
Caused by: java.io.IOException: Failed to set file permissions 420 on file

不是一个确凿的证据,而是一个非常强烈的暗示。我们的解决方案(我承认很老套)是使用以下代码:

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)
}

您可以将它放在一个 do first 中,以允许 gradle 在检查最新状态时重新扩展存档。

于 2013-06-05T18:07:12.670 回答
0

在使用 android 库 (aars) 时,我遇到了类似的问题。我通过删除 aars 爆炸的目录来使其工作。

def str = "rm -rf "+buildDir.absolutePath+"/exploded-aar" str.execute()

于 2014-04-07T23:00:31.327 回答
0

我刚刚遇到了同样的问题,涉及黄瓜中一个名为“??.class”的文件。运行的异常原因

./gradlew connectedCheck --debug --stacktrace

显示以下根本原因

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

事实证明,我的语言环境存在问题,我之前忽略了来自其他命令行工具的所有警告。我检查了 中提到了哪些语言环境/etc/locale.conf,取消了相应行的注释/etc/locale.gen并运行

sudo locale-gen

重新生成语言环境。在此之后,文件名显示出来ਅਤੇ.class,并且解压缩工作完美无缺。

于 2016-08-05T05:49:27.897 回答