Gradle jar任务失败,并且“在最新检查期间无法捕获任务'jar'属性'archivePath'的输出文件的快照。”

时间:2017-01-24 12:34:39

标签: gradle jar

我的gradle文件中有这个jar任务,如下所示:

jar {
    manifest {
        attributes "Main-Class": "nameSpace.myClass"
    }

    from {
        configurations.compile.collect {
            it.isDirectory() ? it : project.zipTree(it).matching {
                exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA','build','.gradle/**','build.gradle','gradle','gradlew','gradlew.bat','test'
            }
        }
    }

}

运行jar任务很少会呈现成功的结果。大多数时候它会给我以下错误:

* What went wrong:
Failed to capture snapshot of output files for task 'jar' property 'archivePath' during up-to-date check.
> Failed to create MD5 hash for file 'PATH/build/libs/filename.jar'.

使用--stacktrace和--debug运行任务可以为我提供更多数据:

* Exception is:
13:21:45.559 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.UncheckedIOException: Failed to capture snapshot of output files for task 'jar' property 'archivePath' during up-to-date check.

进一步向下:

Caused by: java.io.FileNotFoundException: PATH/build/libs/filename.jar (Permission denied)

有人认识到这一点吗?我运行OS X,运行Linux的同事从未遇到过这个问题。

jar任务运行了很长时间。这部分似乎是运行时间最长的部分:

13:54:08.324 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':jar'.
13:54:12.992 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
13:54:12.994 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
13:54:12.994 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
13:54:12.994 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
13:54:12.995 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
13:54:12.995 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
13:54:12.996 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
13:54:22.993 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
13:54:22.994 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
13:54:22.994 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
13:54:22.995 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
13:54:22.996 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
13:54:22.996 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
13:54:22.996 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
13:54:32.297 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.

我曾尝试运行clean任务,删除build文件夹,重启守护进程等,但没有任何帮助。

编辑: 将Gradle升级到3.3并没有解决任何问题。

1 个答案:

答案 0 :(得分:3)

这很可能是一个防病毒问题。尝试禁用防病毒软件并重新执行此操作。它发生在我身上。非常奇怪!