Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add sources and javadoc to gradlePluginPublication #25

Open
mpetuska opened this issue Oct 27, 2024 · 5 comments
Open

Cannot add sources and javadoc to gradlePluginPublication #25

mpetuska opened this issue Oct 27, 2024 · 5 comments

Comments

@mpetuska
Copy link

I get this error when trying to add sources and docs to the publication

Execution failed for task ':publishCentralPortalPluginMavenClonePublicationToCentralPortalStorageRepository'.
> Failed to publish publication 'centralPortalPluginMavenClone' to repository 'centralPortalStorage'
   > Invalid publication 'centralPortalPluginMavenClone': multiple artifacts with the identical extension and classifier ('jar.asc', 'sources').

Config file is as follows

@file:Suppress("UnstableApiUsage")

gradlePlugin {
  website = "xxx"
  vcsUrl = "xxx"
  plugins {
    create("xxx") {
      // ...
    }
  }
}

tasks {
  register<Jar>("javadocJar") {
    from(dokkatooGeneratePublicationHtml)
    archiveClassifier = "javadoc"
  }
  whenTaskAdded {
    // Needed to bypass missing task dependency declarations of the MavenDeployer
    if (name.contains("CentralPortal", ignoreCase = true) || name.contains("Github", ignoreCase = true)) {
      dependsOn("javadocJar", "sourcesJar", "jar")
    }
  }
}

deployer {
  content {
    gradlePluginComponents {
      sources(
        artifact = tasks.named("sourcesJar"),
        builtBy = tasks.named("sourcesJar"),
      )
      docs(
        artifact = tasks.named("javadocJar"),
        builtBy = tasks.named("javadocJar"),
      )
    }
  }
}

Any workarounds until the fix is released?

P.S. Publishing with empty source and javadoc jars work just fine (default configuration of gradlePluginComponents).

@mpetuska
Copy link
Author

Looks like it was a misunderstanding of how the plugin works in this scenario on my part. I have managed to get it working now, however a smaller issue still remains - task dependencies are not configured correctly by the plugin. Namely, the publication fails without this extra input from my earlier snippet

tasks {
  whenTaskAdded {
    // Needed to bypass missing task dependency declarations of the MavenDeployer
    if (name.contains("CentralPortal", ignoreCase = true) || name.contains("Github", ignoreCase = true)) {
      dependsOn("javadocJar", "sourcesJar", "jar", "makeEmptySourcesJar", "makeEmptyDocJar")
    }
  }
}

@natario1
Copy link
Member

natario1 commented Oct 28, 2024

Thanks for reporting! I'll check later today, glad you found a workaround.

@natario1
Copy link
Member

I tried to replicate this in MavenDeployer's own deployment, which has:

val javadocs = tasks.register<Jar>("dokkaJavadocJar") {
    dependsOn(tasks.dokkaJavadoc)
    from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
    archiveClassifier.set("javadoc")
}

deployer {
    content {
        gradlePluginComponents {
            kotlinSources()
            docs(javadocs)
        }
    }
}

Tasks seem to be properly wired. Could there be a problem in your task definition (e.g. "dokkaJavadocJar" not depending on tasks.dokkaJavadoc?)? Or can you help me reproduce your issue?

Here's the build file: https://github.com/deepmedia/MavenDeployer/blob/main/deployer/build.gradle.kts

@mpetuska
Copy link
Author

Odd, the issue was present with general tasks like jar too. I'll build a reproducer later today.

@mpetuska
Copy link
Author

In the meantime try upgrading gradle version to latest as the errors I got were gradle configuration validation which has gotten stricter in recent releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants