Skip to content

Commit

Permalink
Always use archive base name as the pom artifact id (#56447) (#56467)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed May 8, 2020
1 parent 24760fa commit 81a1e9e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import nebula.plugin.info.InfoBrokerPlugin
import org.apache.commons.io.IOUtils
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
import org.elasticsearch.gradle.info.JavaHome
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
import org.elasticsearch.gradle.precommit.PrecommitTasks
Expand Down Expand Up @@ -56,13 +55,11 @@ import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.credentials.HttpHeaderCredentials
import org.gradle.api.execution.TaskActionListener
import org.gradle.api.execution.TaskExecutionGraph
import org.gradle.api.file.CopySpec
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.plugins.BasePluginConvention
import org.gradle.api.plugins.ExtraPropertiesExtension
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
Expand All @@ -71,16 +68,13 @@ import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.compile.GroovyCompile
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestLoggingContainer
import org.gradle.authentication.http.HttpHeaderAuthentication
import org.gradle.external.javadoc.CoreJavadocOptions
import org.gradle.internal.jvm.Jvm
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.gradle.process.CommandLineArgumentProvider
import org.gradle.util.GradleVersion

import java.nio.charset.StandardCharsets
Expand Down Expand Up @@ -312,6 +306,16 @@ class BuildPlugin implements Plugin<Project> {

/**Configuration generation of maven poms. */
static void configurePomGeneration(Project project) {
// have to defer this until archivesBaseName is set
project.afterEvaluate {
project.pluginManager.withPlugin('maven-publish') {
PublishingExtension publishing = project.extensions.getByType(PublishingExtension)
publishing.publications.withType(MavenPublication) { MavenPublication publication ->
publication.artifactId = project.convention.getPlugin(BasePluginConvention).archivesBaseName
}
}
}

project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
TaskProvider generatePomTask = project.tasks.register("generatePom") { Task task ->
task.dependsOn 'generatePomFileForNebulaPublication'
Expand All @@ -322,7 +326,7 @@ class BuildPlugin implements Plugin<Project> {
}

project.tasks.withType(GenerateMavenPom).configureEach({ GenerateMavenPom pomTask ->
pomTask.destination = "${project.buildDir}/distributions/${project.convention.getPlugin(BasePluginConvention).archivesBaseName}-${project.version}.pom"
pomTask.destination = { "${project.buildDir}/distributions/${project.convention.getPlugin(BasePluginConvention).archivesBaseName}-${project.version}.pom" }
} as Action<GenerateMavenPom>)

PublishingExtension publishing = project.extensions.getByType(PublishingExtension)
Expand All @@ -335,7 +339,7 @@ class BuildPlugin implements Plugin<Project> {
// Here we manually add any project dependencies in the "shadow" configuration to our generated POM
publication.pom.withXml(this.&addScmInfo)
publication.pom.withXml { xml ->
Node root = xml.asNode();
Node root = xml.asNode()
root.appendNode('name', project.name)
root.appendNode('description', project.description)
Node dependenciesNode = (root.get('dependencies') as NodeList).get(0) as Node
Expand Down
8 changes: 0 additions & 8 deletions client/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ sourceCompatibility = JavaVersion.VERSION_1_8
group = 'org.elasticsearch.client'
archivesBaseName = 'elasticsearch-rest-client'

publishing {
publications {
nebula {
artifactId = archivesBaseName
}
}
}

dependencies {
compile "org.apache.httpcomponents:httpclient:${versions.httpclient}"
compile "org.apache.httpcomponents:httpcore:${versions.httpcore}"
Expand Down
8 changes: 0 additions & 8 deletions client/sniffer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ sourceCompatibility = JavaVersion.VERSION_1_8
group = 'org.elasticsearch.client'
archivesBaseName = 'elasticsearch-rest-client-sniffer'

publishing {
publications {
nebula {
artifactId = archivesBaseName
}
}
}

dependencies {
compile project(":client:rest")
compile "org.apache.httpcomponents:httpclient:${versions.httpclient}"
Expand Down
8 changes: 0 additions & 8 deletions libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ if (!isEclipse) {
}
}

publishing {
publications {
nebula {
artifactId = archivesBaseName
}
}
}

dependencies {
// This dependency is used only by :libs:core for null-checking interop with other tools
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
Expand Down
8 changes: 0 additions & 8 deletions modules/lang-painless/spi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ apply plugin: 'nebula.maven-base-publish'
group = 'org.elasticsearch.plugin'
archivesBaseName = 'elasticsearch-scripting-painless-spi'

publishing {
publications {
nebula {
artifactId = archivesBaseName
}
}
}

dependencies {
compile project(":server")
}
Expand Down
8 changes: 0 additions & 8 deletions x-pack/transport-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,3 @@ testingConventions {
}
}
}

publishing {
publications {
nebula(MavenPublication) {
artifactId = archivesBaseName
}
}
}

0 comments on commit 81a1e9e

Please sign in to comment.