This message was deleted.
# community-support
s
This message was deleted.
c
You mean it’s not seen as part of the
sourcesElements
outgoing variant?
t
Copy code
{
  "name": "sourcesElements",
  "attributes": {
    "org.gradle.category": "documentation",
    "org.gradle.dependency.bundling": "external",
    "org.gradle.docstype": "sources",
    "org.gradle.usage": "java-runtime"
  },
  "files": [
    {
      "name": "testkit-truth-1.0-SNAPSHOT-sources.jar",
      "url": "testkit-truth-1.0-SNAPSHOT-sources.jar",
      "size": 3473,
      "sha512": "918e200ba2d912ae4ef5fe7587a244b65aac881cf9d376c7e72c3c004212ae7889929ac629cff2ef5d09c157eaf14bc14391c302a3d8545103e797894de5496c",
      "sha256": "0a02a5dcb8d96d1104eb421e7e4eefdd63b83b81cfce635660927830cddb61b6",
      "sha1": "0b628e4fb67a3d5350ec44dd8514592f9f9b0ff9",
      "md5": "a87112d777f22b9cc6e09c81cf0be356"
    }
  ]
}
e
withJavadocJar()
calls into https://github.com/gradle/gradle/blob/2cb4012f55636266937b504cf580c1077c070969/subprojects/plugins/src/main/java/org/gradle/api/plugins/internal/JvmPluginsHelper.java#L251 which is the the bit that adds it to the software component so that it gets published in the module metadata. not sure how to set that up with Dokka but maybe that'll point you in the right direction
c
you can add as it as an artifact to the outgoing of the
sourcesElements
but consumers will probably want it identified explicitly… this might mean creating your own outgoing configuration and setting appropriate attributes so that it can be resolved when needed
t
ok, thanks!
c
something like this… since I’m deep in some of this goo atm:
Copy code
jvmPluginServices.createOutgoingElements("dokkaElements", builder -> builder.withDescription("Dokka documentation stuff")
        .published().artifact(dokkaJarTask).providesAttributes(attributes -> attributes.documentation("dokka").asJar()));
Then in principle if someone had an incoming configuration that had a documentation attribute with the value “dokka” they would resolve to your variant. Of course that string value is completely non-standard… so no one will pull it unless told to.
t
one of these days (maybe soon?!), I'll feel like I actually understand variant-aware publishing and artifact resolution
ah, turns out I can just hijack
withJavadocJar()
with
Copy code
val javadocJar = tasks.named<Jar>("javadocJar") {
  from(dokkaJavadoc)
}
and that seems to work the .module file has it now, and the javadoc jar is published
j
Always when you use API directly on the “Publication” interface it is too late for the metadata (like the
artifact(...)
, don’t use that anymore!). So ideally you should only use
from(...)
there. (+ Maybe some POM-Metadata additions for informational data that can only be represented there - like
<licenses>
,
<scm>
etc. - if you need it.)
👍 1
til 2
t
Jendrik, do you happen to have a recipe for such a thing? I know you maintain a repo with many recipes 🙂
j
thank you 1