Skip to content

Commit 728a9ac

Browse files
committed
build: Always shade commons-compress
Even in thin JAR
1 parent 875987c commit 728a9ac

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

build.mill

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,25 @@ trait SparkModule extends Cross.Module2[String, String] with SbtModule with Sona
101101
Rule.Relocate("org.apache.commons.compress.**", "shadeio.commons.compress.@1")
102102
)
103103

104+
def thinJarAssembly: T[PathRef] = Task {
105+
106+
val bundledJars = defaultResolver().classpath(alwaysBundledDeps)
107+
108+
val assembled = Assembly.create(
109+
destJar = Task.dest / "thin.jar",
110+
inputPaths = Seq(jar().path) ++ bundledJars.map(_.path),
111+
manifest = manifest(),
112+
prependShellScript = None,
113+
base = None,
114+
assemblyRules = assemblyRules,
115+
shader = mill.javalib.AssemblyModule.jarjarabramsWorker()
116+
)
117+
assembled.pathRef
118+
}
119+
104120
override def extraPublish = Seq(
105121
PublishInfo(assembly(), classifier = None, ivyConfig = "compile"),
106-
PublishInfo(jar(), classifier = Some("thin"), ivyConfig = "compile")
122+
PublishInfo(thinJarAssembly(), classifier = Some("thin"), ivyConfig = "compile")
107123
)
108124

109125
override def sonatypeCentralReadTimeout: T[Int] = 600000
@@ -122,17 +138,21 @@ trait SparkModule extends Cross.Module2[String, String] with SbtModule with Sona
122138
}
123139

124140
val poiVersion = "5.4.1"
141+
val alwaysBundledDeps = Seq(
142+
mvn"commons-io:commons-io:2.20.0",
143+
mvn"org.apache.commons:commons-compress:1.27.1",
144+
// POI needs to be bundled so that its bytecode can be rewritten
145+
// to use the shaded version of commons-compress.
146+
mvn"org.apache.poi:poi:$poiVersion",
147+
mvn"org.apache.poi:poi-ooxml:$poiVersion",
148+
mvn"org.apache.poi:poi-ooxml-lite:$poiVersion"
149+
)
125150

126151
override def mvnDeps = {
127152
val base = Seq(
128-
mvn"org.apache.poi:poi:$poiVersion",
129-
mvn"org.apache.poi:poi-ooxml:$poiVersion",
130-
mvn"org.apache.poi:poi-ooxml-lite:$poiVersion",
131153
mvn"org.apache.xmlbeans:xmlbeans:5.3.0",
132154
mvn"com.norbitltd::spoiwo:2.2.1",
133155
mvn"com.github.pjfanning:excel-streaming-reader:5.1.1",
134-
mvn"commons-io:commons-io:2.20.0",
135-
mvn"org.apache.commons:commons-compress:1.27.1",
136156
mvn"org.apache.logging.log4j:log4j-api:2.24.3",
137157
mvn"com.zaxxer:SparseBitSet:1.3",
138158
mvn"org.apache.commons:commons-collections4:4.5.0",
@@ -141,7 +161,7 @@ trait SparkModule extends Cross.Module2[String, String] with SbtModule with Sona
141161
mvn"org.apache.commons:commons-math3:3.6.1",
142162
mvn"org.scala-lang.modules::scala-collection-compat:2.13.0",
143163
mvn"com.eed3si9n.ifdef::ifdef-annotation:0.4.1"
144-
)
164+
) ++ alwaysBundledDeps
145165
if (sparkVersion >= "3.3.0") {
146166
base ++ Seq(mvn"org.apache.logging.log4j:log4j-core:2.24.3")
147167
} else {

0 commit comments

Comments
 (0)