Reputation: 727
Hi I have a java project, which contains a submodule which is a gradle plugin. I want to publish this module to maven central.
I used this two plugins in my build.gradle
:
plugins {
id 'java-gradle-plugin'
id 'maven-publish'
}
and my publishing
block looks something like:
publishing {
publications {
javaLibrary(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifactId = project.archivesBaseName
pom {
name = artifactId
description = "..."
url =
licenses {
license {
}
}
developers {
...
}
scm {
...
}
issueManagement {
...
}
ciManagement {
...
}
}
}
}
repositories { maven { url = "some local repo" } }
}
I noticed that when I build this module, the generated pom-default.xml
is what I expected, but when I run gradle publishToMavenLocal
and manually checked the pom.xml
file in the .m2
folder, all the metadata like name
description
licenses
are gone!
I also noticed in the .m2
folder there are 2 artifacts that are related to this single plugin, I think it's somewhat related with https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers but I don't fully understand the meaning. Both these 2 artifacts' pom are missing the pom metadata as I described above.
Could some gradle expert help me here: how to keep the metadata in the published pom?
Upvotes: 1
Views: 3836
Reputation: 1
they are actually two different artifacts.
they have different format requirements.
gradle plugin can only be published to 'Gradle Plugin Portal'.
as its format will never match Maven Central's requirements.
Upvotes: 0
Reputation: 66
Sorry for late answer, but you can do something like this:
afterEvaluate {
tasks.withType(GenerateMavenPom) { task ->
doFirst {
// Update POM here
def pom = task.pom
pom.name = ...
pom.url = ...
pom.description = ...
pom.scm {
...
}
}
}
}
This will catch the pom of the plugin marker artifact as well.
Upvotes: 1
Reputation: 22952
You should not need to manually define a MavenPublication
for your plugin submodule. The java-gradle-plugin
reacts to the application of the maven-publish
plugin and automatically configures/creates publications for the plugin artifacts. See this line.
You are correct for the (2) artifacts produced. One is the plugin marker (single pom.xml
) and the other is the actual plugin JAR artifact.
As for POM customization, Gradle seemingly provides its own the POM irrespective of any POM customization(s) you have defined: https://github.com/gradle/gradle/issues/17022
Upvotes: 4