diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 9b0e303d009c1..7e1384eccd4e4 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -365,6 +365,16 @@ class BuildPlugin implements Plugin { /**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' @@ -375,7 +385,7 @@ class BuildPlugin implements Plugin { } 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) PublishingExtension publishing = project.extensions.getByType(PublishingExtension) diff --git a/client/rest-high-level/build.gradle b/client/rest-high-level/build.gradle index 60381802b4a73..f3112d825160d 100644 --- a/client/rest-high-level/build.gradle +++ b/client/rest-high-level/build.gradle @@ -28,14 +28,6 @@ apply plugin: 'elasticsearch.rest-resources' group = 'org.elasticsearch.client' archivesBaseName = 'elasticsearch-rest-high-level-client' -publishing { - publications { - nebula { - artifactId = archivesBaseName - } - } -} - restResources { //we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions) restApi { diff --git a/client/rest/build.gradle b/client/rest/build.gradle index be48321be1278..e6895d54e7f95 100644 --- a/client/rest/build.gradle +++ b/client/rest/build.gradle @@ -28,14 +28,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}" diff --git a/client/sniffer/build.gradle b/client/sniffer/build.gradle index a0bea7a7b69bf..bcb405fbc98c4 100644 --- a/client/sniffer/build.gradle +++ b/client/sniffer/build.gradle @@ -26,14 +26,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}" diff --git a/libs/core/build.gradle b/libs/core/build.gradle index 5515acf6fa3dd..d5283cc625769 100644 --- a/libs/core/build.gradle +++ b/libs/core/build.gradle @@ -64,14 +64,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" diff --git a/modules/lang-painless/spi/build.gradle b/modules/lang-painless/spi/build.gradle index 3f25f247a2b67..a73ec4a7e922d 100644 --- a/modules/lang-painless/spi/build.gradle +++ b/modules/lang-painless/spi/build.gradle @@ -24,14 +24,6 @@ apply plugin: 'nebula.maven-scm' group = 'org.elasticsearch.plugin' archivesBaseName = 'elasticsearch-scripting-painless-spi' -publishing { - publications { - nebula { - artifactId = archivesBaseName - } - } -} - dependencies { compile project(":server") } diff --git a/x-pack/transport-client/build.gradle b/x-pack/transport-client/build.gradle index 0254cbabcf3a5..d8d5a190a3580 100644 --- a/x-pack/transport-client/build.gradle +++ b/x-pack/transport-client/build.gradle @@ -31,11 +31,3 @@ testingConventions { } } } - -publishing { - publications { - nebula(MavenPublication) { - artifactId = archivesBaseName - } - } -}