Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

accomodating windows style file separator in default MergeStrategy #51

Closed
wants to merge 3 commits into
from
@@ -241,19 +241,31 @@ object Plugin extends sbt.Plugin {
(key.? zipWith rhs)( (x,y) => (x :^: y :^: KNil) map Scoped.hf2( _ getOrElse _ ))
}
- private val LicenseFile = """(.*/)?(license|licence|notice|copying)([.]\w+)?$""".r
+ private val LicenseFile = ("""(license|licence|notice|copying)([.]\w+)?$""").r
+
private def isLicenseFile(fileName: String): Boolean =
fileName.toLowerCase match {
- case LicenseFile(_, _, ext) if ext != ".class" => true // DISLIKE
+ case LicenseFile(_, ext) if ext != ".class" => true // DISLIKE
case _ => false
}
- private val ReadMe = """(.*/)?(readme)([.]\w+)?$""".r
+ private val ReadMe = """(readme)([.]\w+)?$""".r
+
private def isReadme(fileName: String): Boolean =
fileName.toLowerCase match {
- case ReadMe(x, y, z) => true
+ case ReadMe(_, _) => true
case _ => false
}
+ private object PathExtractor {
+ private val sysFileSep = System.getProperty("file.separator")
+ def unapply(path: String) = {
+ val split = path.toLowerCase.split(if (sysFileSep.equals( """\""")) """\\""" else sysFileSep)
+ if (split.isEmpty)
+ None
+ else
+ new Some((split.head, split.tail.headOption.getOrElse(""), split.last))
+ }
+ }
lazy val baseAssemblySettings: Seq[sbt.Project.Setting[_]] = Seq(
assembly <<= (test in assembly, outputPath in assembly, packageOptions in assembly,
@@ -264,26 +276,15 @@ object Plugin extends sbt.Plugin {
assembledMappings in assembly <<= (assemblyOption in assembly, fullClasspath in assembly, dependencyClasspath in assembly,
excludedJars in assembly, streams) map {
(ao, cp, deps, ej, s) => (tempDir: File) => assemblyAssembledMappings(tempDir, cp, deps, ao, ej, s.log) },
-
- mergeStrategy in assembly := {
- case "reference.conf" =>
- MergeStrategy.concat
- case n if isReadme(n) || isLicenseFile(n) =>
- MergeStrategy.rename
- case inf if inf.startsWith("META-INF/") =>
- inf.slice("META-INF/".size, inf.size).toLowerCase match {
- case "manifest.mf" | "index.list" | "dependencies" =>
- MergeStrategy.discard
- case n if n.endsWith(".sf") || n.endsWith(".dsa") =>
- MergeStrategy.discard
- case n if n startsWith "plexus/" =>
- MergeStrategy.discard
- case n if n startsWith "services/" =>
- MergeStrategy.filterDistinctLines
- case "spring.schemas" | "spring.handlers" =>
- MergeStrategy.filterDistinctLines
- case _ => MergeStrategy.deduplicate
- }
+
+ mergeStrategy in assembly := {
+ case "reference.conf" => MergeStrategy.concat
+ case PathExtractor(_, _, filename) if isReadme(filename) || isLicenseFile(filename) => MergeStrategy.rename
+ case PathExtractor("meta-inf", "plexus", _) => MergeStrategy.discard
+ case PathExtractor("meta-inf", "services", _) => MergeStrategy.filterDistinctLines
+ case PathExtractor("meta-inf", _, "manifest.mf" | "index.list" | "dependencies") => MergeStrategy.discard
+ case PathExtractor("meta-inf", _, "spring.schemas" | "spring.handlers") => MergeStrategy.filterDistinctLines
+ case PathExtractor("meta-inf", _, filename) if filename.endsWith(".sf") || filename.endsWith(".dsa")=> MergeStrategy.discard
case _ => MergeStrategy.deduplicate
},