does the gradle plugin publish... plugin just publ...
# community-support
c
does the gradle plugin publish... plugin just publish to the repository configured for maven publishing? or will it always try to publish to the portal. How should I conditionalize where artifacts are published to?
v
Iirc, the gradle plugin publish plugin adds a task
publishPlugins
which publishes always to plugin central. As long as you do not call that task, it should not do that. For publishing to any arbitrary Maven repo, just use the normal
maven-publish
means. The Gradle Plugin Development Plugin should still integrate with the
maven-publish
plugin and declare the publications for the plugins and plugin marker artifacts. So if you do not want to publish to the portal at all, you probabably don't even need to apply the gradle plugin publish plugin.
1
c
well... I want to publish my not quite snapshots to somewhere else
but publish to plugin central when I do a release
probably both, when I do a release
so if I just call
publish
it will publish the plugin fully correctly to the maven repo? and if I were to add such a repo as a repo that can be consumed as a plugin (some settings configuration), then I could still reference by the plugin id?
v
Iirc yes, afair
publish
does not get wired to
publishPlugins
by the plugin. But just to make sure, execute
./gradlew publish -m
to see which tasks will be executed.
c
sure, I just wasn't certain it'd actually publish all of the gradle metadata
so if I wanted to publish to either a private maven repo, or a public one depending on the job, is there a good way to do that outside of a big fat if statement?
v
sure, I just wasn't certain it'd actually publish all of the gradle metadata
Should so, yes.
so if I wanted to publish to either a private maven repo, or a public one depending on the job, is there a good way to do that outside of a big fat if statement
Declare both repositories and do not use
publish
but
publishAllPublicationsToPrivateRepository
or
publishAllPublicationsToPublicRepository
respectively.
c
how do you declare as a public/private? or is "public" just the name you assign it?
v
Yes, it is the name you assign to the repository when declaring it
👍 1
c
so... gradle is publishing an artifact that is
Copy code
<group>.<id>.gradle:plugin
... even though the id probably might contain the group. Mine does
and such
Copy code
com.xenoterracide.gradle.convention.publish.com.xenoterracide.gradle.convention.publish.gradle
Is needed so that
id("com.xenoterracide.gradle.convention.publish")
works
mostly mentioning because that artifact name is so crazy that I feel the need to make sure something isn't wrong
v
I don't really get what you are saying. That
id("com.xenoterracide.gradle.convention.publish")
works you need the plugin marker artifact which is
com.xenoterracide.gradle.convention.publish:com.xenoterracide.gradle.convention.publish.gradle.plugin:<plugin version>
(
<plugin id>:<plugin id>.gradle.plugin:<plugin version>
). It depends on the artifact with the actual code. Under which coordinates the code artifact is published is fully your decision. It is the normal
<project group>:<project name>
by default.
c
Copy code
<dependency>
  <groupId>com.xenoterracide.gradle.convention.publish.com.xenoterracide.gradle.convention.publish.gradle</groupId>
  <artifactId>plugin</artifactId>
  <version>0.0.1-alpha.0.7+04630115</version>
</dependency>
well, I have 2, but that would probably be the metadata
but doesn't seem to have the metadata... or rather isn't being found when I include the
com.xenoterracide.gradle.convention:publish:
Copy code
gradlePlugin {
  plugins {
    create("pub") {
      id = "${rootProject.group}.${project.name}"
      displayName = "My conventions for publishing"
      tags = setOf("publish", "convention")
      implementationClass = "$id.PublishPlugin"
    }
  }
}
and it's creating these for maven
Copy code
publication plugin com.xenoterracide.gradle.convention.publish:0.0.0
publication pluginMaven com.xenoterracide.gradle.convention:publish:0.0.0
publication pluginPluginMarkerMaven com.xenoterracide.gradle.convention:publish:0.0.0
the plugin
Copy code
plugin com.xenoterracide.gradle.convention com.xenoterracide.gradle.convention.publish:0.0.0
that's the
<group> <id>:<version>
I don't get it, doesn't seem to match what you're saying should be there?
and certainly isn't behaving exactly as I'd expect
hrm... thought maybe it had something to do with pluginManagement not having it in buildSrc, but that doesn't help
Copy code
Precompiled script plugin '/home/xeno/IdeaProjects/gradle-convention/buildSrc/src/main/kotlin/our.javalibrary.gradle.kts' line: 1

* What went wrong:
An exception occurred applying plugin request [id: 'com.xenoterracide.gradle.convention.publish']
> Failed to apply plugin 'com.xenoterracide.gradle.convention.publish'.
   > Cannot query the value of extension 'repositoryHost' property 'namespace' because it has no value available.
wait, repositoryHost... that's in my extension, sigh...
v
and it's creating these for maven
```publication plugin com.xenoterracide.gradle.convention.publish:0.0.0
publication pluginMaven com.xenoterracide.gradle.conventionpublish0.0.0
publication pluginPluginMarkerMaven com.xenoterracide.gradle.conventionpublish0.0.0```
Who is "it"? Where is the "publication plugin" coming from?
pluginMaven
and
pluginPluginMarkerMaven
should be the one created for you iirc.
https://github.com/xenoterracide/gradle-convention/packages/2275134 is what got created
This looks a bit shifted. If this should be the marker artifact, it should not be
Copy code
<dependency>
  <groupId>com.xenoterracide.gradle.convention.publish.com.xenoterracide.gradle.convention.publish.gradle</groupId>
  <artifactId>plugin</artifactId>
  <version>0.0.1-alpha.0.8+cb482dec</version>
</dependency>
but
Copy code
<dependency>
  <groupId>com.xenoterracide.gradle.convention.publish</groupId>
  <artifactId>com.xenoterracide.gradle.convention.publish.gradle.plugin</artifactId>
  <version>0.0.1-alpha.0.8+cb482dec</version>
</dependency>
So all before
.plugin
wandered to the group somehow.
But as the POM is named correctly
com.xenoterracide.gradle.convention.publish.gradle.plugin-0.0.1-alpha.0.8+cb482dec.pom
, this might just be a web display glitch of GPR
I mean, that +
https://github.com/xenoterracide/gradle-convention/blob/main/module/publish/build.gradle.kts is what's doing it, don't think I'm doing anything weird that would cause it
v
As I said, the POM is named correctly, so I'd exepect it to just be a display problem of GPR. Did you try to actually consume the plugin?
c
it probably is, I made a different post about consuming. I think it's applying it's just erroring