Skip to content

Commit 1e2d97c

Browse files
authored
fix(build): restore task dependency for Spark bundle jar Maven publication (#4876)
* Fix Spark bundle JAR missing from Maven publication Move artifact registration for createPolarisSparkJar out of PublishingHelperPlugin and into each Spark module build script, using a TaskProvider<ShadowJar> variable to properly wire the task dependency into the Maven publication. * Apply spotless formatting to Spark build scripts
1 parent ce14a43 commit 1e2d97c

3 files changed

Lines changed: 102 additions & 95 deletions

File tree

build-logic/src/main/kotlin/publishing/PublishingHelperPlugin.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ constructor(private val softwareComponentFactory: SoftwareComponentFactory) : Pl
136136
suppressPomMetadataWarningsFor("testFixturesApiElements")
137137
suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
138138

139-
project.tasks
140-
.matching { task -> task.name == "createPolarisSparkJar" }
141-
.configureEach {
142-
// if the project contains spark client jar, also publish the jar to maven
143-
artifact(this)
144-
}
145-
146139
if (project.isSigningEnabled()) {
147140
configure<SigningExtension> { sign(mavenPublication) }
148141
}

plugins/spark/v3.5/spark/build.gradle.kts

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -207,52 +207,59 @@ listOf("intTestCompileClasspath", "intTestRuntimeClasspath").forEach {
207207
}
208208
}
209209

210-
tasks.register<ShadowJar>("createPolarisSparkJar") {
211-
archiveClassifier = "bundle"
212-
isZip64 = true
213-
214-
// pack both the source code and dependencies
215-
from(sourceSets.main.map { it.output })
216-
configurations = provider { listOf(project.configurations.runtimeClasspath.get()) }
217-
218-
// Includes _all_ duplicates (this is applied files processed by `ShadowJar`).
219-
duplicatesStrategy = DuplicatesStrategy.INCLUDE
220-
// This setting applies to the _result_ of the `ShadowJar`.
221-
failOnDuplicateEntries = true
222-
223-
// Generally, preserve META-INF/maven/*/*/pom.* files for downstream tools that
224-
// can analyze dependency jars.
225-
//
226-
// There are quite a few _duplicated_ occurrences of failureaccess, guava,
227-
// listenablefuture, error_prone_annotations, j2objc-annotations, gson.
228-
// Leave those here so that dependency analyzing tools can pick those up.
229-
230-
exclude(
231-
// Recursively remove all LICENSE and NOTICE file under META-INF, includes
232-
// directories contains 'license' in the name.
233-
"META-INF/**/*LICENSE*",
234-
"META-INF/**/*NOTICE*",
235-
// exclude the top level LICENSE, LICENSE-*.txt and NOTICE
236-
"LICENSE*",
237-
"NOTICE*",
238-
239-
// Exclude Jandex indexes
240-
"META-INF/jandex.idx",
241-
242-
// From Hive/Hadoop - exclude those to not confuse people.
243-
"META-INF/DEPENDENCIES",
244-
)
210+
val createPolarisSparkJar =
211+
tasks.register<ShadowJar>("createPolarisSparkJar") {
212+
archiveClassifier = "bundle"
213+
isZip64 = true
214+
215+
// pack both the source code and dependencies
216+
from(sourceSets.main.map { it.output })
217+
configurations = provider { listOf(project.configurations.runtimeClasspath.get()) }
218+
219+
// Includes _all_ duplicates (this is applied files processed by `ShadowJar`).
220+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
221+
// This setting applies to the _result_ of the `ShadowJar`.
222+
failOnDuplicateEntries = true
223+
224+
// Generally, preserve META-INF/maven/*/*/pom.* files for downstream tools that
225+
// can analyze dependency jars.
226+
//
227+
// There are quite a few _duplicated_ occurrences of failureaccess, guava,
228+
// listenablefuture, error_prone_annotations, j2objc-annotations, gson.
229+
// Leave those here so that dependency analyzing tools can pick those up.
230+
231+
exclude(
232+
// Recursively remove all LICENSE and NOTICE file under META-INF, includes
233+
// directories contains 'license' in the name.
234+
"META-INF/**/*LICENSE*",
235+
"META-INF/**/*NOTICE*",
236+
// exclude the top level LICENSE, LICENSE-*.txt and NOTICE
237+
"LICENSE*",
238+
"NOTICE*",
239+
240+
// Exclude Jandex indexes
241+
"META-INF/jandex.idx",
242+
243+
// From Hive/Hadoop - exclude those to not confuse people.
244+
"META-INF/DEPENDENCIES",
245+
)
245246

246-
// add polaris customized LICENSE and NOTICE for the bundle jar at top level. Note that the
247-
// customized LICENSE and NOTICE file are called BUNDLE-LICENSE and BUNDLE-NOTICE,
248-
// and renamed to LICENSE and NOTICE after include, this is to avoid the file
249-
// being excluded due to the exclude pattern matching used above.
250-
from("${projectDir}/BUNDLE-LICENSE") { rename { "LICENSE" } }
251-
from("${projectDir}/BUNDLE-NOTICE") { rename { "NOTICE" } }
252-
}
247+
// add polaris customized LICENSE and NOTICE for the bundle jar at top level. Note that the
248+
// customized LICENSE and NOTICE file are called BUNDLE-LICENSE and BUNDLE-NOTICE,
249+
// and renamed to LICENSE and NOTICE after include, this is to avoid the file
250+
// being excluded due to the exclude pattern matching used above.
251+
from("${projectDir}/BUNDLE-LICENSE") { rename { "LICENSE" } }
252+
from("${projectDir}/BUNDLE-NOTICE") { rename { "NOTICE" } }
253+
}
253254

254255
// ensure the shadow jar job (which will automatically run license addition) is run for both
255256
// `assemble` and `build` task
256-
tasks.named("assemble") { dependsOn("createPolarisSparkJar") }
257+
tasks.named("assemble") { dependsOn(createPolarisSparkJar) }
257258

258-
tasks.named("build") { dependsOn("createPolarisSparkJar") }
259+
tasks.named("build") { dependsOn(createPolarisSparkJar) }
260+
261+
publishing {
262+
publications.named<MavenPublication>("maven") {
263+
artifact(createPolarisSparkJar)
264+
}
265+
}

plugins/spark/v4.0/spark/build.gradle.kts

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -210,52 +210,59 @@ configurations.named("intTestRuntimeClasspath") {
210210
resolutionStrategy { force("jakarta.servlet:jakarta.servlet-api:5.0.0") }
211211
}
212212

213-
tasks.register<ShadowJar>("createPolarisSparkJar") {
214-
archiveClassifier = "bundle"
215-
isZip64 = true
216-
217-
// pack both the source code and dependencies
218-
from(sourceSets.main.map { it.output })
219-
configurations = provider { listOf(project.configurations.runtimeClasspath.get()) }
220-
221-
// Includes _all_ duplicates (this is applied files processed by `ShadowJar`).
222-
duplicatesStrategy = DuplicatesStrategy.INCLUDE
223-
// This setting applies to the _result_ of the `ShadowJar`.
224-
failOnDuplicateEntries = true
225-
226-
// Generally, preserve META-INF/maven/*/*/pom.* files for downstream tools that
227-
// can analyze dependency jars.
228-
//
229-
// There are quite a few _duplicated_ occurrences of failureaccess, guava,
230-
// listenablefuture, error_prone_annotations, j2objc-annotations, gson.
231-
// Leave those here so that dependency analyzing tools can pick those up.
232-
233-
exclude(
234-
// Recursively remove all LICENSE and NOTICE file under META-INF, includes
235-
// directories contains 'license' in the name.
236-
"META-INF/**/*LICENSE*",
237-
"META-INF/**/*NOTICE*",
238-
// exclude the top level LICENSE, LICENSE-*.txt and NOTICE
239-
"LICENSE*",
240-
"NOTICE*",
241-
242-
// Exclude Jandex indexes
243-
"META-INF/jandex.idx",
244-
245-
// From Hive/Hadoop - exclude those to not confuse people.
246-
"META-INF/DEPENDENCIES",
247-
)
213+
val createPolarisSparkJar =
214+
tasks.register<ShadowJar>("createPolarisSparkJar") {
215+
archiveClassifier = "bundle"
216+
isZip64 = true
217+
218+
// pack both the source code and dependencies
219+
from(sourceSets.main.map { it.output })
220+
configurations = provider { listOf(project.configurations.runtimeClasspath.get()) }
221+
222+
// Includes _all_ duplicates (this is applied files processed by `ShadowJar`).
223+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
224+
// This setting applies to the _result_ of the `ShadowJar`.
225+
failOnDuplicateEntries = true
226+
227+
// Generally, preserve META-INF/maven/*/*/pom.* files for downstream tools that
228+
// can analyze dependency jars.
229+
//
230+
// There are quite a few _duplicated_ occurrences of failureaccess, guava,
231+
// listenablefuture, error_prone_annotations, j2objc-annotations, gson.
232+
// Leave those here so that dependency analyzing tools can pick those up.
233+
234+
exclude(
235+
// Recursively remove all LICENSE and NOTICE file under META-INF, includes
236+
// directories contains 'license' in the name.
237+
"META-INF/**/*LICENSE*",
238+
"META-INF/**/*NOTICE*",
239+
// exclude the top level LICENSE, LICENSE-*.txt and NOTICE
240+
"LICENSE*",
241+
"NOTICE*",
242+
243+
// Exclude Jandex indexes
244+
"META-INF/jandex.idx",
245+
246+
// From Hive/Hadoop - exclude those to not confuse people.
247+
"META-INF/DEPENDENCIES",
248+
)
248249

249-
// add polaris customized LICENSE and NOTICE for the bundle jar at top level. Note that the
250-
// customized LICENSE and NOTICE file are called BUNDLE-LICENSE and BUNDLE-NOTICE,
251-
// and renamed to LICENSE and NOTICE after include, this is to avoid the file
252-
// being excluded due to the exclude pattern matching used above.
253-
from("${projectDir}/BUNDLE-LICENSE") { rename { "LICENSE" } }
254-
from("${projectDir}/BUNDLE-NOTICE") { rename { "NOTICE" } }
255-
}
250+
// add polaris customized LICENSE and NOTICE for the bundle jar at top level. Note that the
251+
// customized LICENSE and NOTICE file are called BUNDLE-LICENSE and BUNDLE-NOTICE,
252+
// and renamed to LICENSE and NOTICE after include, this is to avoid the file
253+
// being excluded due to the exclude pattern matching used above.
254+
from("${projectDir}/BUNDLE-LICENSE") { rename { "LICENSE" } }
255+
from("${projectDir}/BUNDLE-NOTICE") { rename { "NOTICE" } }
256+
}
256257

257258
// ensure the shadow jar job (which will automatically run license addition) is run for both
258259
// `assemble` and `build` task
259-
tasks.named("assemble") { dependsOn("createPolarisSparkJar") }
260+
tasks.named("assemble") { dependsOn(createPolarisSparkJar) }
260261

261-
tasks.named("build") { dependsOn("createPolarisSparkJar") }
262+
tasks.named("build") { dependsOn(createPolarisSparkJar) }
263+
264+
publishing {
265+
publications.named<MavenPublication>("maven") {
266+
artifact(createPolarisSparkJar)
267+
}
268+
}

0 commit comments

Comments
 (0)