Error running customDistribution sample code


(nm2501) #1

I ran the ‘dist’ task on the customDistribution sample as follows:

<gradle_dir>\samples\customDistribution\plugin> gradle dist -Dhttp.proxyHost=<host> -Dhttp.proxyPort=<port>

The output was:

:compileJava UP-TO-DATE
:compileGroovy
Download http://repo1.maven.org/maven2/com/google/guava/guava/11.0.2/guava-11.0.2.pom
Download http://repo1.maven.org/maven2/com/google/guava/guava-parent/11.0.2/guava-parent-11.0.2.pom
Download http://repo1.maven.org/maven2/org/sonatype/oss/oss-parent/7/oss-parent-7.pom
Download http://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.pom
Download http://repo1.maven.org/maven2/com/google/guava/guava/11.0.2/guava-11.0.2.jar
Download http://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar
:processResources
:classes
:jar
:dist
  FAILURE: Build aborted because of an internal error.
  * What went wrong:
Build aborted because of an unexpected internal error. Please file an issue at: http://forums.gradle.org.
  * Try:
Run with --debug option to get additional debug info.
  * Exception is:
org.gradle.api.UncheckedIOException: java.io.IOException: The process cannot access the file because another process has
 locked a portion of the file
        at org.gradle.util.hash.HashUtil.createHash(HashUtil.java:56)
        at org.gradle.util.hash.HashUtil.createHash(HashUtil.java:34)
        at org.gradle.api.internal.changedetection.DefaultHasher.hash(DefaultHasher.java:24)
        at org.gradle.api.internal.changedetection.CachingHasher.hash(CachingHasher.java:42)
        at org.gradle.api.internal.changedetection.DefaultFileSnapshotter.snapshot(DefaultFileSnapshotter.java:44)
        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.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:52)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:38)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:30)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.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.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
        at org.gradle.cache.internal.DefaultCacheAccess$2.create(DefaultCacheAccess.java:118)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:133)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:116)
        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:158)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)
        at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:61)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:185)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
        at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:52)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:142)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
  Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:220)
        at org.gradle.util.hash.HashUtil.createHash(HashUtil.java:46)
        ... 82 more
    BUILD FAILED
  Total time: 37.797 secs

Version info:

C:\Tools\gradle-1.2\samples\customDistribution\plugin>gradle -v
  ------------------------------------------------------------
Gradle 1.2
------------------------------------------------------------
  Gradle build time: Wednesday, 12 September 2012 10:46:02 o'clock UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_07 (Oracle Corporation 23.3-b01)
OS: Windows 7 6.1 amd64

(Peter Niederwieser) #2

Sounds like you might have multiple Gradle daemons running. Try ‘gradle --stop’. Also note that you must do a clean build whenever you switch Gradle versions.


(nm2501) #3

I tried ‘gradle --stop’ and then reran the ‘dist’ task - same error.

I also tried deleting my ‘%USERPROFILE%/.gradle/daemon’ directory because I’ve had a problem with dead daemons before - no difference.

I tried ‘clean’ as well, even though it shouldn’t have been necessary because I haven’t changed the gradle version specified in the build script.


(Peter Niederwieser) #4

Can you try without the daemon? Do you have a tool to check which process keeps the file locked? ‘gradle dist’ works just fine for me (with daemon).


(nm2501) #5

I tried running

<gradle_dir>\samples\customDistribution\plugin> gradle --no-daemon dist -Dhttp.proxyHost=<host> -Dhttp.proxyPort=<port>

and found the same problem. (I also ran ‘gradle --stop’ prior to this.) The same error occurred - “org.gradle.api.UncheckedIOException: java.io.IOException: The process cannot access the file because another process has locked a portion of the file”.

I’ll be happy to check which process is keeping the file locked, but I don’t know which file. I would assume that it’s a zip file that I should be looking for, but here’s the output of ‘tree /F’ after invoking the above command:

C:\TOOLS\GRADLE-1.2\SAMPLES\CUSTOMDISTRIBUTION\PLUGIN
│
 build.gradle
│
 settings.gradle
│
├───.gradle
│
 └───1.2
│
     └───taskArtifacts
│
             cache.properties
│
             cache.properties.lock
│
             fileHashes.bin
│
             fileSnapshots.bin
│
             outputFileStates.bin
│
             taskArtifacts.bin
│
├───build
│
 ├───classes
│
 │
 └───main
│
 │
     └───org
│
 │
         └───gradle
│
 │
                 GreetingPlugin.class
│
 │
                 GreetingTask.class
│
 │
│
 ├───libs
│
 │
     customDistribution.jar
│
 │
│
 ├───resources
│
 │
 └───main
│
 │
     └───META-INF
│
 │
         └───gradle-plugins
│
 │
                 greeting.properties
│
 │
│
 └───tmp
│
     ├───groovy-java-stubs
│
     └───jar
│
             MANIFEST.MF
│
└───src
    ├───initScripts
    │
     custom-plugins.gradle
    │
    └───main
        ├───groovy
        │
 └───org
        │
     └───gradle
        │
             GreetingPlugin.groovy
        │
             GreetingTask.groovy
        │
        └───resources
            └───META-INF
                └───gradle-plugins
                        greeting.properties

(Peter Niederwieser) #6

Turn on debug log with ‘-d’, and stack trace with ‘-s’. Maybe that gives a hint. Also run ‘jps’ and make sure that there are no other Gradle daemons running. Reboot may also help.


(nm2501) #7

Ok, I found the problem. I noticed that the build script was copying from ‘gradle.gradleHomeDir’ which in my case was ‘C:\Tools\gradle-1.2’. However, the location of the sample project (and the output zip) was a subfolder of this, resulting in an attempt to recursively zip, or running into a file-lock problem.

(If memory serves me correctly I also ran into a similar issue when creating a zip without explicitly excluding the zip from the zipping task, if that makes sense. The task would run indefinitely, resulting in a zip file gigabytes in size. But that’s a separate issue.)

My workaround was to move the ‘samples’ directory outside of my ‘gradle-1.2’ directory.

I have been using your Standard Distribution from http://services.gradle.org/distributions/gradle-1.2-all.zip which puts the ‘samples’ directory inside ‘gradle-1.2’.

I don’t know if my workaround is the most appropriate solution, but I would have thought better error reporting would be worthwhile. And possibly change the structure of your Standard Distribution.