在Windows上使用Gradle构建时,如何修复OverlappingFileLockException?

时间:2014-02-19 23:17:22

标签: windows gradle

在尝试遍历使用Gradle的Spring REST tutorial时,我在尝试运行./gradlew clean test时遇到了OverlappingFileLockException。当我尝试使用Gradle的完整安装而不是包含的包装器时,我会得到相同的异常。所以,我决定更简单地开始,并遵循Gradle自己的Hello World example,结果相同。这是堆栈跟踪:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'hello-world'.
> Could not open no_buildscript class cache for build file 'D:\gradle-playground\hello-world\build.gradle' (\\omafp01.co
rp.planetci.com\ramc01\.gradle\caches\1.11\scripts\build_5trnq1oe4m84o6rmggev8gku4t\ProjectScript\no_buildscript).
   > java.nio.channels.OverlappingFileLockException (no error message)

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

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'hello-world'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.
java:79)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:57)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:507)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:82)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter
.java:64)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:20
1)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:17
4)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
        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:46)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.Main.main(Main.java:37)
        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:23)
Caused by: org.gradle.cache.CacheOpenException: Could not open no_buildscript class cache for build file 'D:\gradle-play
ground\hello-world\build.gradle' (\\omafp01.corp.planetci.com\ramc01\.gradle\caches\1.11\scripts\build_5trnq1oe4m84o6rmg
gev8gku4t\ProjectScript\no_buildscript).
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:48)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:28)
        at org.gradle.cache.internal.DefaultCacheFactory.doOpen(DefaultCacheFactory.java:81)
        at org.gradle.cache.internal.DefaultCacheFactory.open(DefaultCacheFactory.java:51)
        at org.gradle.cache.internal.DefaultCacheRepository$PersistentCacheBuilder.doOpen(DefaultCacheRepository.java:14
1)
        at org.gradle.cache.internal.DefaultCacheRepository$AbstractCacheBuilder.open(DefaultCacheRepository.java:124)
        at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler.compile(FileCacheBackedScriptClassCompi
ler.java:57)
        at org.gradle.groovy.scripts.internal.ShortCircuitEmptyScriptCompiler.compile(ShortCircuitEmptyScriptCompiler.ja
va:35)
        at org.gradle.groovy.scripts.internal.CachingScriptClassCompiler.compile(CachingScriptClassCompiler.java:36)
        at org.gradle.groovy.scripts.DefaultScriptCompilerFactory$ScriptCompilerImpl.compile(DefaultScriptCompilerFactor
y.java:57)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:17
1)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.j
ava:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        ... 25 more
Caused by: java.nio.channels.OverlappingFileLockException
        at org.gradle.cache.internal.filelock.LockStateAccess.tryLock(LockStateAccess.java:83)
        at org.gradle.cache.internal.filelock.LockFileAccess.tryLockState(LockFileAccess.java:83)
        at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lockStateRegion(DefaultFileLockManager.java:
312)
        at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lock(DefaultFileLockManager.java:255)
        at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.<init>(DefaultFileLockManager.java:127)
        at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:80)
        at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:67)
        at org.gradle.cache.internal.DefaultCacheAccess.open(DefaultCacheAccess.java:86)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:46)
        ... 39 more

以下是build.gradle的内容:

task hello {
    doLast {
        println 'Hello world!'
    }
}

我在连接到VPN时运行Windows 8,64位JDK(1.6_043)和Gradle 1.11。当然,这在我的Macbook上工作正常,但我需要让它在我的工作机器上工作。

1 个答案:

答案 0 :(得分:5)

这似乎是写入我的默认缓存目录的问题,该目录存在于网络位置。为了解决这个问题,我添加了一个GRADLE_USER_HOME环境变量,指向本地驱动器:C:\Users\ramc01\.gradle。固定!