Skip to content

Commit

Permalink
Build: Remove pom generation for plugin zip files (#32180)
Browse files Browse the repository at this point in the history
In 1.x and 2.x, plugins were published to maven and the plugin
installer downloaded them from there. This was later changed to install
from the download service, and in 5.0 plugin zips were no longer
published to maven. However, the build still currently produces an
unused pom file. This is troublesome in the special case when the main
jar of a plugin needs to be published (and thus needs a pom file of
the same name).

closes #31946
  • Loading branch information
rjernst committed Jul 19, 2018
1 parent 838a832 commit ef4f51c
Showing 1 changed file with 7 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public class PluginBuildPlugin extends BuildPlugin {
// and generate a different pom for the zip
addClientJarPomGeneration(project)
addClientJarTask(project)
} else {
// no client plugin, so use the pom file from nebula, without jar, for the zip
project.ext.set("nebulaPublish.maven.jar", false)
}
// while the jar isn't normally published, we still at least build a pom of deps
// in case it is published, for instance when other plugins extend this plugin
configureJarPom(project)

project.integTestCluster.dependsOn(project.bundlePlugin)
project.tasks.run.dependsOn(project.bundlePlugin)
Expand All @@ -92,7 +92,6 @@ public class PluginBuildPlugin extends BuildPlugin {
}

if (isModule == false || isXPackModule) {
addZipPomGeneration(project)
addNoticeGeneration(project)
}

Expand Down Expand Up @@ -237,36 +236,15 @@ public class PluginBuildPlugin extends BuildPlugin {
}
}

/** Adds a task to generate a pom file for the zip distribution. */
public static void addZipPomGeneration(Project project) {
/** Configure the pom for the main jar of this plugin */
protected static void configureJarPom(Project project) {
project.plugins.apply(ScmInfoPlugin.class)
project.plugins.apply(MavenPublishPlugin.class)

project.publishing {
publications {
zip(MavenPublication) {
artifact project.bundlePlugin
}
/* HUGE HACK: the underlying maven publication library refuses to deploy any attached artifacts
* when the packaging type is set to 'pom'. But Sonatype's OSS repositories require source files
* for artifacts that are of type 'zip'. We already publish the source and javadoc for Elasticsearch
* under the various other subprojects. So here we create another publication using the same
* name that has the "real" pom, and rely on the fact that gradle will execute the publish tasks
* in alphabetical order. This lets us publish the zip file and even though the pom says the
* type is 'pom' instead of 'zip'. We cannot setup a dependency between the tasks because the
* publishing tasks are created *extremely* late in the configuration phase, so that we cannot get
* ahold of the actual task. Furthermore, this entire hack only exists so we can make publishing to
* maven local work, since we publish to maven central externally. */
zipReal(MavenPublication) {
artifactId = project.pluginProperties.extension.name
pom.withXml { XmlProvider xml ->
Node root = xml.asNode()
root.appendNode('name', project.pluginProperties.extension.name)
root.appendNode('description', project.pluginProperties.extension.description)
root.appendNode('url', urlFromOrigin(project.scminfo.origin))
Node scmNode = root.appendNode('scm')
scmNode.appendNode('url', project.scminfo.origin)
}
nebula(MavenPublication) {
artifactId project.pluginProperties.extension.name
}
}
}
Expand Down

0 comments on commit ef4f51c

Please sign in to comment.