This message was deleted.
# community-support
s
This message was deleted.
j
I am not sure why that is not working (I think in general it looks like it should), but it’s kind of an outdated approach. (Some of the APIs might/should be deprecated soon… maybe…) I would do it all through the configurations and use a USAGE attribute to match them. On the producer side:
Copy code
configurations.create("specFiles") {
    isCanBeResolved = false
    isCanBeConsumed = true
    attributes {
        attribute(Usage.USAGE_ATTRIBUTE, objects.named("spec-files"))
    }
    outgoing.artifact(resourcesJar)
}
// No artifacts{} block!
And this on the consumer side:
Copy code
val specFilesPath = configurations.create("specFilesPath") {
    isCanBeResolved = true
    isCanBeConsumed = false
    attributes {
        attribute(Usage.USAGE_ATTRIBUTE, objects.named("spec-files"))
    }
}

dependencies {
    specFilesPath(project(":producer"))
}
See also a full sample here: Consumer : https://github.com/jjohannes/understanding-gradle/blob/main/13_Aggregating_Custom_[…]gic/java-plugins/src/main/kotlin/my-java-application.gradle.kts Producer: https://github.com/jjohannes/understanding-gradle/blob/main/13_Aggregating_Custom_[…]uild-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts
Now I I see that the problem is somewhere else (solving it should make it work with both approaches):
This is not “lazy”
Copy code
from(zipTree(specFiles.singleFile))
Should be:
Copy code
from(specFiles.elements.map { zipTree(it.first()) })
v
Also, there is no need to jar the resources just to unjar them again, is there? That should just be unnecessary work and add an artificial manifest file in the result. You could add as well just publish the directory with the resources and directly use it, either the result of
processResources
to also get eventual transformations, or the source of you want it. Actually, iirc the
java-library
plugin should already publish such a variant that you can directly use in
consumer
. Make sure it is applied and have a look at
:producer:outgoingVariants
output.
s
Thank you @Jendrik Johannes - that was the missing piece. @Vampire - Thanks for that. Yup, java-library produces a secondary variant called
resources
and that is exactly what I needed.
👌 1