@@ -88,18 +88,9 @@ class RelocatorRemapper(relocators: List[Relocator]) extends Remapper {
8888 * should be relocated are moved to a new location, and all classes are passed through the
8989 * remapper so that references to relocated classes are fixed.
9090 *
91- * Note about `preferLocal`: this is a hack to make sure that we always ship the Spark-compiled
92- * version of Guava's `Optional` class. Unlike maven, sbt-assembly doesn't seem to allow filtering
93- * of specific entries in dependencies. It also does not provide information about where does
94- * a particular file come from. The only hint is that the temp path for the file ends with a "_dir"
95- * when it comes from a directory, and with a hash when it comes from a jar file. So for classes
96- * that match a regex in the `preferLocal` list, we choose the first class file in a local
97- * directory.
98- *
9991 * @param relocators List of relocators to apply to classes being shaded.
100- * @param preferLocal List of regexes that match classes for which a local version is preferred.
10192 */
102- class ShadeStrategy (relocators : List [Relocator ], preferLocal : List [ Regex ] ) extends MergeStrategy {
93+ class ShadeStrategy (relocators : List [Relocator ]) extends MergeStrategy {
10394
10495 private val remapper = new RelocatorRemapper (relocators)
10596
@@ -111,7 +102,7 @@ class ShadeStrategy(relocators: List[Relocator], preferLocal: List[Regex]) exten
111102 (files.head, path)
112103 } else {
113104 val className = path.substring(0 , path.length() - " .class" .length())
114- (remap(chooseFile(path, files) , tempDir), remapper.rename(className) + " .class" )
105+ (remap(files.head , tempDir), remapper.rename(className) + " .class" )
115106 }
116107 Right (Seq (file -> newPath))
117108 }
@@ -139,18 +130,4 @@ class ShadeStrategy(relocators: List[Relocator], preferLocal: List[Regex]) exten
139130 }
140131 }
141132
142- private def chooseFile (path : String , files : Seq [File ]): File = {
143- if (! preferLocal.filter { r => r.pattern.matcher(path).matches() }.isEmpty) {
144- def isLocal (f : File ) = {
145- val abs = f.getAbsolutePath()
146- val dir = abs.substring(0 , abs.length() - path.length())
147- dir.endsWith(" _dir" )
148- }
149-
150- files.filter(isLocal).orElse(files)(0 )
151- } else {
152- files.head
153- }
154- }
155-
156133}
0 commit comments