FileNotFoundException in copy task during change detection of destination folder


(Søren Therkildsen) #1

I am copying a war file from my build folder to my JBoss application server deployments folder using this piece of code:

task deploy(type: Copy, dependsOn: [war, deployProperties, ':common:deployProperties'], description: 'Deploys the WAR for this module to JBoss EAP', group: 'JBoss') {
    onlyIf { projectIsDeployable(project.name) }
    from(war.archivePath) {
        include war.archiveName
    }
    into project.eapDeployFolder
} 

Sometimes the get the following error, during this process:

Gradle failure report
FAILURE: Build failed with an exception.

* What went wrong:
java.io.FileNotFoundException: C:\b1\work\2e63a1414d0cd1b2\integrations\build\eap\jboss-eap-7.0\standalone\deployments\myapp.war.pending (The system cannot find the file specified)
> C:\b1\work\2e63a1414d0cd1b2\integrations\build\eap\jboss-eap-7.0\standalone\deployments\myapp.war.pending (The system cannot find the file specified)

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

* Exception is:
org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: C:\b1\work\2e63a1414d0cd1b2\integrations\build\eap\jboss-eap-7.0\standalone\deployments\myapp.war.pending (The system cannot find the file specified)
	at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:39)
	at org.gradle.api.internal.hash.DefaultHasher.hash(DefaultHasher.java:24)
	at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.snapshot(CachingFileSnapshotter.java:57)
	at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.snapshot(CachingFileSnapshotter.java:46)
	at org.gradle.api.internal.changedetection.state.CachingFileSnapshotter.snapshot(CachingFileSnapshotter.java:29)
	at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter$1.run(DefaultFileCollectionSnapshotter.java:77)
	at org.gradle.internal.Factories$1.create(Factories.java:22)
	at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:192)
	at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
	at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
	at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
	at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:60)
	at org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter.snapshot(DefaultFileCollectionSnapshotter.java:69)
	at org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter.snapshot(OutputFilesCollectionSnapshotter.java:93)
	at org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter.snapshot(OutputFilesCollectionSnapshotter.java:44)
	at org.gradle.api.internal.changedetection.rules.OutputFilesStateChangeRule$1.snapshotAfterTask(OutputFilesStateChangeRule.java:79)
	at org.gradle.api.internal.changedetection.rules.CachingTaskStateChanges.snapshotAfterTask(CachingTaskStateChanges.java:84)
	at org.gradle.api.internal.changedetection.rules.SummaryTaskStateChanges.snapshotAfterTask(SummaryTaskStateChanges.java:73)
	at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.afterTask(DefaultTaskArtifactStateRepository.java:126)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)

Looks like gradle is calculating MD5 checksums of files in the destination directory, but failing because another process (JBoss appserver) is creating and deleting files during the copy process.

Is there any way to avoid that gradle is calculating hash codes of files in the destination directory. Files that are not part of the include in the copy task.

Kind regards
Søren


(Søren Therkildsen) #2

Tried this

task deploy(type: Copy, dependsOn: [war, deployProperties, ':common:deployProperties'], description: 'Deploys the WAR for this module to JBoss EAP', group: 'JBoss') {
    onlyIf { projectIsDeployable(project.name) }
    // Try to skip up to date check to avoid hashing errors from blinking files in destination directory.
    outputs.upToDateWhen { return false }
    from(war.archivePath) {
        include war.archiveName
    }
    into project.eapDeployFolder
}

But it still fails with a similar error:

Gradle failure report
FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture snapshot of output files for task 'deploy' during up-to-date check.
> java.io.FileNotFoundException: C:\b1\work\2e63a1414d0cd1b2\integrations\build\eap\jboss-eap-7.0\standalone\deployments\cpr.war.pending (The system cannot find the file specified)

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

* Exception is:
org.gradle.api.UncheckedIOException: Failed to capture snapshot of output files for task 'deploy' during up-to-date check.
	at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init>(TaskUpToDateState.java:51)
	at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository.java:135)
	at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.afterTask(DefaultTaskArtifactStateRepository.java:126)
	at org.gradle.api.internal.changedetection.changes.ShortCircuitTaskArtifactStateRepository$RerunTaskArtifactState.afterTask(ShortCircuitTaskArtifactStateRepository.java:89)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)