mirror of https://github.com/sbt/sbt.git
Merge pull request #118 from alexarchambault/shaded-jar-check
Check that lmcoursier is the only remaining namespace in lm-coursier-shaded JAR
This commit is contained in:
commit
7bc0078cb9
12
build.sbt
12
build.sbt
|
|
@ -51,14 +51,22 @@ lazy val `lm-coursier-shaded` = project
|
|||
shadeNamespaces ++= Set(
|
||||
"coursier",
|
||||
"shapeless",
|
||||
"argonaut"
|
||||
"argonaut",
|
||||
"org.fusesource",
|
||||
"org.jline"
|
||||
),
|
||||
libraryDependencies ++= Seq(
|
||||
"io.get-coursier" %% "coursier" % coursierVersion0 % "shaded",
|
||||
"org.scala-lang.modules" %% "scala-xml" % "1.2.0", // depending on that one so that it doesn't get shaded
|
||||
"org.scala-sbt" %% "librarymanagement-ivy" % "1.2.4",
|
||||
"org.scalatest" %% "scalatest" % "3.0.8" % Test
|
||||
)
|
||||
),
|
||||
packageBin.in(Shading) := {
|
||||
val jar = packageBin.in(Shading).value
|
||||
// ignoreFiles is there temporarily, until https://github.com/coursier/coursier/pull/1317 is merged
|
||||
Check.onlyNamespace("lmcoursier", jar, ignoreFiles = Set("coursier.properties"))
|
||||
jar
|
||||
}
|
||||
)
|
||||
|
||||
lazy val `sbt-coursier-shared` = project
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
import java.io.File
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object Check {
|
||||
|
||||
def onlyNamespace(ns: String, jar: File, ignoreFiles: Set[String] = Set.empty): Unit = {
|
||||
val zf = new ZipFile(jar)
|
||||
val unrecognized = zf.entries()
|
||||
.asScala
|
||||
.map(_.getName)
|
||||
.filter { n =>
|
||||
!n.startsWith("META-INF/") && !n.startsWith(ns + "/") &&
|
||||
n != "reflect.properties" && // scala-reflect adds that
|
||||
!ignoreFiles(n)
|
||||
}
|
||||
.toVector
|
||||
.sorted
|
||||
for (u <- unrecognized)
|
||||
System.err.println(s"Unrecognized: $u")
|
||||
assert(unrecognized.isEmpty)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue