Skip to content

Commit

Permalink
[CELEBORN-1203] Add LicenseAndNoticeMergeStrategy to resolve inner …
Browse files Browse the repository at this point in the history
…project LICENSE/NOTICE conflict for shaded client packaging

### What changes were proposed in this pull request?

### Why are the changes needed?

### Does this PR introduce _any_ user-facing change?

### How was this patch tested?

Closes apache#2197 from cfmcgrady/license.

Authored-by: Fu Chen <cfmcgrady@gmail.com>
Signed-off-by: Fu Chen <cfmcgrady@gmail.com>
  • Loading branch information
cfmcgrady committed Dec 31, 2023
1 parent b4b8684 commit 9619958
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions project/CelebornBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,13 @@ trait SparkClientProjects {

(assembly / assemblyMergeStrategy) := {
case m if m.toLowerCase(Locale.ROOT).endsWith("manifest.mf") => MergeStrategy.discard
case "META-INF/LICENSE" | "META-INF/NOTICE" => MergeStrategy.preferProject
// the LicenseAndNoticeMergeStrategy always picks the license/notice file from the current project
case m @ ("META-INF/LICENSE" | "META-INF/NOTICE") => CustomMergeStrategy("LicenseAndNoticeMergeStrategy") { conflicts =>
val entry = conflicts.head
val projectLicenseFile = (Compile / resourceDirectory).value / entry.target
val stream = () => new java.io.BufferedInputStream(new java.io.FileInputStream(projectLicenseFile))
Right(Vector(JarEntry(entry.target, stream)))
}
case PathList(ps@_*) if Assembly.isLicenseFile(ps.last) => MergeStrategy.discard
// Drop all proto files that are not needed as artifacts of the build.
case m if m.toLowerCase(Locale.ROOT).endsWith(".proto") => MergeStrategy.discard
Expand Down Expand Up @@ -951,7 +957,13 @@ trait FlinkClientProjects {

(assembly / assemblyMergeStrategy) := {
case m if m.toLowerCase(Locale.ROOT).endsWith("manifest.mf") => MergeStrategy.discard
case "META-INF/LICENSE" | "META-INF/NOTICE" => MergeStrategy.preferProject
// the LicenseAndNoticeMergeStrategy always picks the license/notice file from the current project
case m @ ("META-INF/LICENSE" | "META-INF/NOTICE") => CustomMergeStrategy("LicenseAndNoticeMergeStrategy") { conflicts =>
val entry = conflicts.head
val projectLicenseFile = (Compile / resourceDirectory).value / entry.target
val stream = () => new java.io.BufferedInputStream(new java.io.FileInputStream(projectLicenseFile))
Right(Vector(JarEntry(entry.target, stream)))
}
case PathList(ps@_*) if Assembly.isLicenseFile(ps.last) => MergeStrategy.discard
// Drop all proto files that are not needed as artifacts of the build.
case m if m.toLowerCase(Locale.ROOT).endsWith(".proto") => MergeStrategy.discard
Expand Down Expand Up @@ -1056,7 +1068,13 @@ object MRClientProjects {
case m if m.toLowerCase(Locale.ROOT).endsWith("manifest.mf") => MergeStrategy.discard
// For netty-3.x.y.Final.jar
case m if m.startsWith("META-INF/license/") => MergeStrategy.discard
case "META-INF/LICENSE" | "META-INF/NOTICE" => MergeStrategy.preferProject
// the LicenseAndNoticeMergeStrategy always picks the license/notice file from the current project
case m @ ("META-INF/LICENSE" | "META-INF/NOTICE") => CustomMergeStrategy("LicenseAndNoticeMergeStrategy") { conflicts =>
val entry = conflicts.head
val projectLicenseFile = (Compile / resourceDirectory).value / entry.target
val stream = () => new java.io.BufferedInputStream(new java.io.FileInputStream(projectLicenseFile))
Right(Vector(JarEntry(entry.target, stream)))
}
case PathList(ps@_*) if Assembly.isLicenseFile(ps.last) => MergeStrategy.discard
// Drop all proto files that are not needed as artifacts of the build.
case m if m.toLowerCase(Locale.ROOT).endsWith(".proto") => MergeStrategy.discard
Expand Down

0 comments on commit 9619958

Please sign in to comment.