I'm trying to get a catalog and a platform publish...
# community-support
g
I'm trying to get a catalog and a platform published under the same gav here, Maven basically calls Gradle to publish the platform
.module
and then the catalog
.toml
and inject those into the publications (alongside with the hardcoded comment on the pom.xml) I can successfully depends on the platform, but whenever I try to use the catalog, I get: > ould not resolve all artifacts for configuration 'incomingCatalogForLibs0'. > > Could not resolve org.scijavapom scijava38.0.0-SNAPSHOT. > Required by: > unspecifiedunspecifiedunspecified > > No matching variant of org.scijavapom scijava38.0.0-SNAPSHOT:20240623.051958-54 was found. The consumer was configured to find attribute 'org.gradle.category' with value 'platform', attribute 'org.gradle.usage' with value 'version-catalog' but: while the
org.gradle.usage
are all set to
java-api
Is there a workaround for this?
v
You publish the component
javaPlatform
which is the platform. For the version catalog you need to publish the component
versionCatalog
.
g
so, there is no way to have them published under the same gav? Alternatively I may simply point to the cloud toml file
v
Did you try to publish from both components? Never tried that, no idea whether it works.
g
how? Because I presume I have to publish them in sequence, and the first one will be always overwritten
v
No, it does not work.
Copy code
if (getComponent().isPresent()) {
    throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name));
}
Maybe you need change the configuration you are publishing then. 🤷‍♂️
g
wouldnt that be an issue on the consumer side?
v
Why? The component is the container containing the feature variants to publish. The consumer should get the variant he needs by using the proper capability or attributes.
g
you mean publishing then a
apiElements2
and
runtimeElements2
?
v
No, the platform plugin publishes
apiElements
and
runtimeElements
. The version catalog plugin publishes
versionCatalogElements
.
Something like this could maybe work:
Copy code
val javaPlatform by components.existing {
    this as AdhocComponentWithVariants
    val versionCatalogElements by configurations
    addVariantsFromConfiguration(versionCatalogElements) {
    }
}
g
I see what you mean, I published the catalog locally and this is what I'd need in the
.module
file
Copy code
"variants": [
    {
      "name": "versionCatalogElements",
      "attributes": {
        "org.gradle.category": "platform",
        "org.gradle.usage": "version-catalog"
      },
      "files": [...]
    }
  ]
nice, it looks like it works as you proposed!
👌 1