@@ -124,7 +124,8 @@ object Assembly {
124
124
125
125
def loadShadedClasspath (
126
126
inputPaths : Agg [os.Path ],
127
- assemblyRules : Seq [Assembly .Rule ]
127
+ assemblyRules : Seq [Assembly .Rule ],
128
+ runtimeVersion : Option [Runtime .Version ]
128
129
): (Generator [(String , UnopenedInputStream )], ResourceCloser ) = {
129
130
val shadeRules = assemblyRules.collect {
130
131
case Rule .Relocate (from, to) => ShadePattern .Rename (List (from -> to)).inAll
@@ -148,13 +149,20 @@ object Assembly {
148
149
}
149
150
150
151
val pathsWithResources = inputPaths.filter(os.exists).map { path =>
151
- if (os.isFile(path)) path -> Some (new JarFile (path.toIO))
152
+ if (os.isFile(path)) path -> {
153
+ val file = path.toIO
154
+ val jarFile = runtimeVersion match {
155
+ case Some (version) => new JarFile (file, true , java.util.zip.ZipFile .OPEN_READ , version)
156
+ case None => new JarFile (file)
157
+ }
158
+ Some (jarFile)
159
+ }
152
160
else path -> None
153
161
}
154
162
155
163
val generators = Generator .from(pathsWithResources).flatMap {
156
164
case (path, Some (jarFile)) =>
157
- Generator .from(jarFile.entries ().asScala.filterNot(_.isDirectory))
165
+ Generator .from(jarFile.versionedStream().iterator ().asScala.filterNot(_.isDirectory))
158
166
.flatMap(entry => shader(entry.getName, () => jarFile.getInputStream(entry)))
159
167
case (path, None ) =>
160
168
os.walk
@@ -193,7 +201,8 @@ object Assembly {
193
201
manifest : mill.api.JarManifest = mill.api.JarManifest .MillDefault ,
194
202
prependShellScript : String = " " ,
195
203
base : Option [os.Path ] = None ,
196
- assemblyRules : Seq [Assembly .Rule ] = Assembly .defaultRules
204
+ assemblyRules : Seq [Assembly .Rule ] = Assembly .defaultRules,
205
+ runtimeVersion : Option [Runtime .Version ]
197
206
)(implicit ctx : Ctx .Dest with Ctx .Log ): PathRef = {
198
207
val tmp = ctx.dest / " out-tmp.jar"
199
208
@@ -213,7 +222,8 @@ object Assembly {
213
222
manifest.build.write(manifestOut)
214
223
manifestOut.close()
215
224
216
- val (mappings, resourceCleaner) = Assembly .loadShadedClasspath(inputPaths, assemblyRules)
225
+ val (mappings, resourceCleaner) =
226
+ Assembly .loadShadedClasspath(inputPaths, assemblyRules, runtimeVersion)
217
227
try {
218
228
Assembly .groupAssemblyEntries(mappings, assemblyRules).foreach {
219
229
case (mapping, entry) =>
0 commit comments