Skip to content

Commit 4ba0129

Browse files
authored
[7.17] Backport maven central aggregation zip (#2418)
* Make aggregation zip compatible with release manager (#2398) (#2411) - Update nmcp version on the way - fix typo - use unique name and compatible folder for zip (cherry picked from commit c468d8a) * Run zipAggregation when building DRAs
1 parent a0ec07a commit 4ba0129

File tree

10 files changed

+91
-37
lines changed

10 files changed

+91
-37
lines changed

.buildkite/dra.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mkdir localRepo
3838
wget --quiet "https://artifacts-$DRA_WORKFLOW.elastic.co/elasticsearch/${ES_BUILD_ID}/maven/org/elasticsearch/gradle/build-tools/${HADOOP_VERSION}${VERSION_SUFFIX}/build-tools-${HADOOP_VERSION}${VERSION_SUFFIX}.jar" \
3939
-O "localRepo/build-tools-${HADOOP_VERSION}${VERSION_SUFFIX}.jar"
4040

41-
./gradlew -S -PlocalRepo=true "${BUILD_ARGS}" -Dorg.gradle.warning.mode=summary -Dcsv="$WORKSPACE/build/distributions/dependencies-${HADOOP_VERSION}${VERSION_SUFFIX}.csv" :dist:generateDependenciesReport distribution
41+
./gradlew -S -PlocalRepo=true "${BUILD_ARGS}" -Dorg.gradle.warning.mode=summary -Dcsv="$WORKSPACE/build/distributions/dependencies-${HADOOP_VERSION}${VERSION_SUFFIX}.csv" :dist:generateDependenciesReport distribution zipAggregation
4242

4343
# Allow other users access to read the artifacts so they are readable in the container
4444
find "$WORKSPACE" -type f -path "*/build/distributions/*" -exec chmod a+r {} \;

build.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
import org.elasticsearch.hadoop.gradle.buildtools.ConcatFilesTask
2+
import java.lang.management.ManagementFactory;
3+
import java.time.LocalDateTime;
4+
import org.elasticsearch.gradle.VersionProperties
25

36
description = 'Elasticsearch for Apache Hadoop'
47

58
apply plugin: 'es.hadoop.build.root'
9+
apply plugin: 'com.gradleup.nmcp.aggregation'
610

711
defaultTasks 'build'
812

13+
repositories {
14+
mavenCentral()
15+
}
16+
dependencies {
17+
nmcpAggregation(project(":dist"))
18+
nmcpAggregation(project(":elasticsearch-hadoop-mr"))
19+
nmcpAggregation(project(":elasticsearch-hadoop-pig"))
20+
nmcpAggregation(project(":elasticsearch-hadoop-hive"))
21+
nmcpAggregation(project(":elasticsearch-spark-20"))
22+
nmcpAggregation(project(":elasticsearch-spark-13"))
23+
nmcpAggregation(project(":elasticsearch-spark-30"))
24+
nmcpAggregation(project(":elasticsearch-storm"))
25+
}
26+
27+
tasks.named('zipAggregation').configure {
28+
archiveFileName.unset();
29+
archiveBaseName.set("elasticsearch-hadoop-maven-aggregation")
30+
destinationDirectory.set(layout.buildDirectory.dir("distributions"));
31+
archiveVersion.set(VersionProperties.elasticsearch)
32+
}
33+
934
allprojects {
1035
group = "org.elasticsearch"
1136
tasks.withType(AbstractCopyTask) {

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ dependencies {
7272
// Required for dependency licenses task
7373
implementation 'org.apache.rat:apache-rat:0.11'
7474
implementation 'commons-codec:commons-codec:1.12'
75+
implementation 'com.gradleup.nmcp:nmcp:0.1.5'
7576

7677
if (localRepo) {
7778
implementation name: "build-tools-${buildToolsVersion}"

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/BuildPlugin.groovy

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ class BuildPlugin implements Plugin<Project> {
581581

582582
private void configureMaven(Project project) {
583583
project.getPluginManager().apply("maven-publish")
584+
project.getPluginManager().apply("com.gradleup.nmcp")
584585

585586
// Configure Maven publication
586587
project.publishing {
@@ -601,13 +602,6 @@ class BuildPlugin implements Plugin<Project> {
601602
// Configure Maven Pom
602603
configurePom(project, project.publishing.publications.main)
603604

604-
// Disable the publishing tasks since we only need the pom generation tasks.
605-
// If we are working with a project that has a scala variant (see below), we need to modify the pom's
606-
// artifact id which the publish task does not like (it fails validation when run).
607-
project.getTasks().withType(PublishToMavenRepository) { PublishToMavenRepository m ->
608-
m.enabled = false
609-
}
610-
611605
// Configure Scala Variants if present
612606
project.getPlugins().withType(SparkVariantPlugin).whenPluginAdded {
613607
// Publishing gets weird when you introduce variants into the project.
@@ -622,7 +616,7 @@ class BuildPlugin implements Plugin<Project> {
622616

623617
// Main variant needs the least configuration on its own, since it is the default publication created above.
624618
sparkVariants.defaultVariant { SparkVariant variant ->
625-
updateVariantPomLocationAndArtifactId(project, project.publishing.publications.main, variant)
619+
updateVariantArtifactId(project, project.publishing.publications.main, variant)
626620
}
627621

628622
// For each spark variant added, we need to do a few things:
@@ -672,8 +666,9 @@ class BuildPlugin implements Plugin<Project> {
672666
from variantComponent
673667
suppressAllPomMetadataWarnings() // We get it. Gradle metadata is better than Maven Poms
674668
}
669+
variantPublication.setAlias(true)
675670
configurePom(project, variantPublication)
676-
updateVariantPomLocationAndArtifactId(project, variantPublication, variant)
671+
updateVariantArtifactId(project, variantPublication, variant)
677672
}
678673
}
679674
}
@@ -686,14 +681,6 @@ class BuildPlugin implements Plugin<Project> {
686681
}
687682

688683
private static void configurePom(Project project, MavenPublication publication) {
689-
// Set the pom's destination to the distribution directory
690-
project.tasks.withType(GenerateMavenPom).all { GenerateMavenPom pom ->
691-
if (pom.name == "generatePomFileFor${publication.name.capitalize()}Publication") {
692-
BasePluginExtension baseExtension = project.getExtensions().getByType(BasePluginExtension.class);
693-
pom.destination = project.provider({"${project.buildDir}/distributions/${baseExtension.archivesName.get()}-${project.getVersion()}.pom"})
694-
}
695-
}
696-
697684
// add all items necessary for publication
698685
Provider<String> descriptionProvider = project.provider({ project.getDescription() })
699686
MavenPom pom = publication.getPom()
@@ -746,23 +733,12 @@ class BuildPlugin implements Plugin<Project> {
746733
}
747734
}
748735

749-
private static void updateVariantPomLocationAndArtifactId(Project project, MavenPublication publication, SparkVariant variant) {
736+
private static void updateVariantArtifactId(Project project, MavenPublication publication, SparkVariant variant) {
750737
// Add variant classifier to the pom file name if required
751738
String classifier = variant.shouldClassifySparkVersion() && variant.isDefaultVariant() == false ? "-${variant.getName()}" : ''
752739
BasePluginExtension baseExtension = project.getExtensions().getByType(BasePluginExtension.class);
753-
String filename = "${baseExtension.archivesName.get()}_${variant.scalaMajorVersion}-${project.getVersion()}${classifier}"
754-
// Fix the pom name
755-
project.tasks.withType(GenerateMavenPom).all { GenerateMavenPom pom ->
756-
if (pom.name == "generatePomFileFor${publication.name.capitalize()}Publication") {
757-
pom.destination = project.provider({"${project.buildDir}/distributions/${filename}.pom"})
758-
}
759-
}
760-
// Fix the artifactId. Note: The publishing task does not like this happening. Hence it is disabled.
761-
publication.getPom().withXml { XmlProvider xml ->
762-
Node root = xml.asNode()
763-
Node artifactId = (root.get('artifactId') as NodeList).get(0) as Node
764-
artifactId.setValue("${baseExtension.archivesName.get()}_${variant.scalaMajorVersion}")
765-
}
740+
// Fix the artifact id
741+
publication.setArtifactId("${baseExtension.archivesName.get()}_${variant.scalaMajorVersion}")
766742
}
767743

768744
/**

dist/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ javadoc {
140140
publishing {
141141
publications {
142142
main {
143+
artifactId = "elasticsearch-hadoop"
143144
getPom().withXml { XmlProvider xml ->
144145
Node root = xml.asNode()
145146

@@ -148,10 +149,6 @@ publishing {
148149
Node repository = repositories.appendNode('repository')
149150
repository.appendNode('id', 'clojars.org')
150151
repository.appendNode('url', 'https://clojars.org/repo')
151-
BasePluginExtension baseExtension = project.getExtensions().getByType(BasePluginExtension.class)
152-
153-
// Correct the artifact Id, otherwise it is listed as 'dist'
154-
root.get('artifactId').get(0).setValue(baseExtension.archivesName.get())
155152
}
156153
}
157154
}

mr/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ dependencies {
5656
exclude group: 'com.fasterxml.jackson.core'
5757
}
5858

59-
embedded(project(path: ":thirdparty", configuration: "shadow"))
59+
embedded(project(path: ":thirdparty", configuration: "nmcp"))
6060
implementation("commons-logging:commons-logging:1.1.1")
6161
implementation("commons-codec:commons-codec:1.4")
6262
implementation("javax.xml.bind:jaxb-api:2.3.1")

spark/sql-13/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,20 @@ sparkVariants {
197197
}
198198
}
199199
}
200+
201+
tasks.register('copyPoms', Copy) {
202+
// from(tasks.named('generatePomFileForMainPublication')) {
203+
// rename 'pom-default.xml', "elasticsearch-spark-20_2.12-${project.getVersion()}.pom"
204+
// }
205+
// from(tasks.named('generatePomFileForSpark13scala211Publication')) {
206+
// rename 'pom-default.xml', "elasticsearch-spark-13_2.11-${project.getVersion()}.pom"
207+
// }
208+
from(tasks.named('generatePomFileForSpark13scala210Publication')) {
209+
rename 'pom-default.xml', "elasticsearch-spark-13_2.10-${project.getVersion()}.pom"
210+
}
211+
into(new File(project.buildDir, 'distributions'))
212+
}
213+
214+
tasks.named('distribution').configure {
215+
dependsOn 'copyPoms'
216+
}

spark/sql-20/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,20 @@ sparkVariants {
218218
}
219219
}
220220
}
221+
222+
tasks.register('copyPoms', Copy) {
223+
// from(tasks.named('generatePomFileForMainPublication')) {
224+
// rename 'pom-default.xml', "elasticsearch-spark-20_2.12-${project.getVersion()}.pom"
225+
// }
226+
from(tasks.named('generatePomFileForSpark20scala211Publication')) {
227+
rename 'pom-default.xml', "elasticsearch-spark-20_2.11-${project.getVersion()}.pom"
228+
}
229+
from(tasks.named('generatePomFileForSpark20scala210Publication')) {
230+
rename 'pom-default.xml', "elasticsearch-spark-20_2.10-${project.getVersion()}.pom"
231+
}
232+
into(new File(project.buildDir, 'distributions'))
233+
}
234+
235+
tasks.named('distribution').configure {
236+
dependsOn 'copyPoms'
237+
}

spark/sql-30/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,15 @@ sparkVariants {
202202
}
203203
}
204204
}
205+
206+
207+
tasks.register('copyPoms', Copy) {
208+
from(tasks.named('generatePomFileForMainPublication')) {
209+
rename 'pom-default.xml', "elasticsearch-spark-30_2.12-${project.getVersion()}.pom"
210+
}
211+
into(new File(project.buildDir, 'distributions'))
212+
}
213+
214+
tasks.named('distribution').configure {
215+
dependsOn 'copyPoms'
216+
}

thirdparty/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ configurations {
2828
transitive = false
2929
canBeResolved = true
3030
}
31+
nmcp {
32+
canBeConsumed = true
33+
canBeResolved = false
34+
// attributes {
35+
// attribute(Usage.USAGE_ATTRIBUTE, project.getObjects().named(Usage.class, "nmcp"))
36+
// }
37+
}
3138
implementation {
3239
extendsFrom shaded
3340
}
@@ -46,3 +53,5 @@ shadowJar {
4653
relocate 'org.apache.commons.httpclient', 'org.elasticsearch.hadoop.thirdparty.apache.commons.httpclient'
4754
relocate 'org.codehaus.jackson', 'org.elasticsearch.hadoop.thirdparty.codehaus.jackson'
4855
}
56+
57+
artifacts.add("nmcp", shadowJar)

0 commit comments

Comments
 (0)