Niels Doucet
11/13/2025, 11:01 AMarchives configuration, but I can't seem to resolve that from a different module 🤔
--------------------------------------------------
Variant archives
--------------------------------------------------
Configuration for archive artifacts.
Capabilities
- com.acme:web-module:0.0.0 (default capability)
Artifacts
- build/libs/web-module-0.0.0.jar (artifactType = jar)
- build/libs/web-module-0.0.0.war (artifactType = war)
I tried
implementation(projects.webModule) { artifact { type = "war" } }
or
implementation(projects.webModule) { artifact { extension = "war" } }
but neither worked resulting in
Could not find web-module.war (project :web-module).
According to the documentation, the war plugin creates a new components.web component, but I'm not sure how to depend on/resolve that.Vampire
11/13/2025, 11:09 AMwar unfortunately, neither does the ear plugin.
See https://github.com/gradle/gradle/issues/1353 and https://github.com/gradle/gradle/issues/34192 for reference.
What I do in such cases is to modify the default outgoing variants to include the war instead of the jar.
This works properly as long as the project does not produce a jar that should also be consumed by other projects, but only the war.
So for example
val apiElements by configurations.existing {
outgoing.artifacts.clear()
outgoing.artifact(war)
attributes {
attribute(BUNDLING_ATTRIBUTE, objects.named(EMBEDDED))
}
}
val runtimeElements by configurations.existing {
outgoing.artifacts.clear()
outgoing.artifact(war)
attributes {
attribute(BUNDLING_ATTRIBUTE, objects.named(EMBEDDED))
}
}
This removes the jar from the two outgoing variants and adds the war instead.
Then you can just depend on the project that produces the war and you get the war as artifact.
The archives configuration is not something you should or can consume by default and iirc in recent Gradle versions also does not exist anymore. It was iirc mainly defining which artifacts get built if you use the assemble task.Niels Doucet
11/13/2025, 12:22 PM