# Copy task implicit dependency

**URL:** <https://discuss.gradle.org/t/copy-task-implicit-dependency/52102>\
**Category:** Help/Discuss\
**Created:** [June 22, 2026, 9:21am UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102 "2026-06-22T09:21:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xF](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/0xf/32/11989_2.png) [@0xF](https://discuss.gradle.org/u/0xF)\
**Post date:** [June 22, 2026, 9:21am UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/1 "2026-06-22T09:21:48Z")

</div>

My Android project fails to build after updating Gradle to 9.6.0.

```gradle
A problem was found with the configuration of task ‘:processReleaseJavaRes’ (type ‘ProcessJavaResTask’).
Property has implicit dependency
Gradle detected a problem with the following location: ‘C:\0\a8\recoil\git\android\build\generated\resources’
Task ‘:processReleaseJavaRes’ uses this output of task ‘:copyJavaResources’ without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed
For more information, please refer to 
 in the Gradle documentation.
Possible solutions:
1. Declare task ‘:copyJavaResources’ as an input of ‘:processReleaseJavaRes’.
2. Declare an explicit dependency on ‘:copyJavaResources’ from ‘:processReleaseJavaRes’ using Task#dependsOn.
3. Declare an explicit dependency on ‘:copyJavaResources’ from ‘:processReleaseJavaRes’ using Task#mustRunAfter.

```

The relevent part of build.gradle:

```gradle
final FUT_RESOURCES = [‘altirrantsc.pal’, ‘altirrapal.pal’, ‘atari8.fnt’, ‘c16.pal’, ‘c64.fnt’, ‘zx81.fnt’]
final JAVA_RESOURCES_DIR = file ‘build/generated/resources’
tasks.register(‘copyJavaResources’, Copy) {
    from ‘..’
    into new File(JAVA_RESOURCES_DIR, ‘net/sf/recoil’)
    include FUT_RESOURCES
}
preBuild.dependsOn generateIcon, generateRoundIcon, copyJavaResources

```

How to fix this?

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [June 22, 2026, 9:58am UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/2 "2026-06-22T09:58:18Z")

</div>

There are quite some problems in that snippet.

For example you use `new File(...)` with a relative path which is almost never what you want in no JVM application whatsoever, as it resolves paths relative to the user working directory.  
In Gradle builds that often is the root project directory, but this is not guaranteed and not always the case.

The actual error you get says, that the task `copyJavaResources` has `build/generated/resources` as output and `processReleaseJavaRes` uses those files as input but without any dependency or ordering constraint between those tasks.

The suggested solutions are actually usually **not** what you want to do, but are only symptom treatment.  
In almost all cases it means that you either have overlapping outputs of tasks (for example having multiple tasks that have `build/generated/resources` as output directory), which is a big build bug and should never happen, or that you manually configured paths to use instead of properly wiring task outputs to task inputs.

How to fix it in your build is hard to say with only that small snippet.  
But usually, each task should have unique outputs that do not overlap and tasks that generate sources or resource are registered **as** source directory for the respective source directory set, so that every consumer of those files automatically get those files and also automatically get the necessary task dependencies without needing to configure it manually.

Practically any explicit `dependsOn` that does not have lifecycle task on the left-hand side is a code-smell and usually a sign of task outputs not being wired to task inputs properly.

But how to do it properly in an Android build no idea, because Android builds are always a bit “special” and I don’t do Android.

---

<div class="post-metadata">

**Author:** ![0xF](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/0xf/32/11989_2.png) [@0xF](https://discuss.gradle.org/u/0xF)\
**Post date:** [June 22, 2026, 1:41pm UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/3 "2026-06-22T13:41:22Z")

</div>

Thank you for a quick response!

This is the complete script:

> **[RECOIL / Code /
  \[db7e2a\]
  /android/build.gradle](https://sourceforge.net/p/recoil/code/ci/db7e2a4ef3dfce173a2ec9b431138f44e0112e60/tree/android/build.gradle)**

The project is cross-platform and the Copy task copies Git-versioned binary files to be embedded in the APK and used with `Foo.class.getResourceAsStream()`.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [June 22, 2026, 3:55pm UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/4 "2026-06-22T15:55:40Z")

</div>

If the files are versioned, why do you need to copy them anywhere at all?  
Just check them in at the correct place and you are done, no need to waste time with copying something somewhere.  
And if you do need, then as I said, do not configure literal paths, but register the actual task _as_`srcDir` of the source directory set like `sourcesSet.main.resources` or however you do it in an Android build.

---

<div class="post-metadata">

**Author:** ![0xF](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/0xf/32/11989_2.png) [@0xF](https://discuss.gradle.org/u/0xF)\
**Post date:** [June 23, 2026, 6:26pm UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/5 "2026-06-23T18:26:47Z")

</div>

The important part is that in addition to Android (built by Gradle), my project works natively on Windows, macOS, Linux and in web browsers.  
I don’t like the idea of checking into Git copies in the Android subdirectory, hence the copy.  
The TOTAL size of these six files is four kilobytes and I have a 2 TB NVMe disk. 🙂

> register the actual task as srcDir of the source directory set like sourcesSet.main.resources or however you do it in an Android build

Wouldn’t that put the whole directory in the APK? I only need these six files.

---

<div class="post-metadata">

**Author:** ![0xF](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/0xf/32/11989_2.png) [@0xF](https://discuss.gradle.org/u/0xF)\
**Post date:** [June 23, 2026, 6:57pm UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/6 "2026-06-23T18:57:41Z")

</div>

Ok, this works:

```gradle
android {
    sourceSets {
        main {
            resources {
                srcDir '..'
                include FUT_RESOURCES
            }
        }
    }
}

```

If `‘..'` is no good, what should I use instead?

Edit:

I posted too fast - it doesn’t work. This packages the files into the root directory of APK. They need to be in a specific directory in APK to work.

Please explain how to copy files.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [June 24, 2026, 9:29am UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/7 "2026-06-24T09:29:20Z")

</div>

Ah, well, if you need them in multiple places then not, yeah.  
But still, then have a separate fully-owned output directory for your copy task (which should usually be a sync task) and declare the task as source directory.

Something like

```kotlin
val prepareJavaResources = tasks.register<Sync>("prepareJavaResources") {
    from("..")
    into(layout.buildDirectory.dir("java-resources"))
    include(...)
}
android {
    sourceSets {
        main {
            resources {
                srcDir(prepareJavaResources)
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![0xF](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/0xf/32/11989_2.png) [@0xF](https://discuss.gradle.org/u/0xF)\
**Post date:** [July 20, 2026, 5:15pm UTC](https://discuss.gradle.org/t/copy-task-implicit-dependency/52102/8 "2026-07-20T17:15:34Z")

</div>

This didn’t work. I ended up with:

```gradle
final FUT_RESOURCES = ['../altirrantsc.pal', '../altirrapal.pal', '../atari8.fnt', '../c16.pal', '../c64.fnt', '../zx81.fnt']
abstract class CopyJavaResourcesTask extends DefaultTask {
    @InputFiles
    abstract ConfigurableFileCollection getInputFiles()

    @OutputDirectory
    abstract DirectoryProperty getOutputDir()

    @Inject
    abstract FileSystemOperations getFs()

    @TaskAction
    void run() {
        fs.sync {
            from inputFiles
            into outputDir.dir('net/sf/recoil')
        }
    }
}
final copyJavaResources = tasks.register('copyJavaResources', CopyJavaResourcesTask) {
    inputFiles.from FUT_RESOURCES
}

androidComponents {
    onVariants(selector().all()) { variant ->
        variant.sources.resources?.addGeneratedSourceDirectory(copyJavaResources, { it.outputDir })
    }
}

```
