Skip to content

Build error: subprojects use ':core:allMetadataJar' without declaring an explicit or implicit dependency #207

@lesserwhirls

Description

@lesserwhirls

As I was upgrading gradle, I noticed the follow error when trying to run ./gradlew build:

    Reason: Task ':testfiles:test' uses this output of task ':core:allMetadataJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':core:allMetadataJar' as an input of ':testfiles:test'.
      2. Declare an explicit dependency on ':core:allMetadataJar' from ':testfiles:test' using Task#dependsOn.
      3. Declare an explicit dependency on ':core:allMetadataJar' from ':testfiles:test' using Task#mustRunAfter.

The error happens on current main as well. The reason is that all <Jar> tasks are getting archive names set to the same value (see here):

tasks.withType<Jar> {
    archiveFileName.set("netchdf-$version.jar")
}

Currently, the assemble task produces one jar file:

core/
  build/
    libs/
      core-macosarm64-0.7.0-metadata.jar
      netchdf-0.7.0.jar

If we take out the tasks.withType<Jar> config, we see that the build tries to produce:

core/
  build/
    libs/
      core-jvm-0.7.0.jar
      core-macosarm64-0.7.0-metadata.jar
      core-metadata-0.7.0.jar

./gradlew build currently fails because core-metadata-0.7.0.jar is missing (the output of the :core:allMetadataJar task).

It's an easy fix, but I want to be sure I capture the reason the jar artifact was renamed to begin with. We can still rename core-jvm-0.7.0.jar to be netchdf-0.7.0.jar if you'd like, but what about the other jar files? We can change all of their names, or we can go back to the default settings where the default name is derived from the subproject name (i.e. core).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions