I thought I'd post this here for anyone in the future looking to use
GeoTools with SBT, and finds themselves trying to make an executable jar
using sbt-assembly, similar to what is mentioned in the FAQ here:
http://docs.geotools.org/latest/userguide/faq.html#how-do-i-create-an-executable-jar-for-my-geotools-app
To get everything to merge properly, you need to add the following to your
build.sbt file:
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) =>
xs map {_.toLowerCase} match {
case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies"
:: Nil) =>
MergeStrategy.discard
case ps @ (_ :: _) if ps.last.endsWith(".sf") ||
ps.last.endsWith(".dsa") || ps.last.endsWith(".rsa") =>
MergeStrategy.discard
case "plexus" :: _ =>
MergeStrategy.discard
case ("services" :: _ :: Nil) =>
MergeStrategy.concat
case ("javax.media.jai.registryfile.jai" :: Nil) |
("registryfile.jai" :: Nil) | ("registryfile.jaiext" :: Nil) =>
MergeStrategy.concat
case _ => MergeStrategy.deduplicate
}
case _ => MergeStrategy.deduplicate
}
I derived this from a combination of Georg Heiler's post on Stack Overflow (
https://stackoverflow.com/questions/43910006/geotools-jai-fatjar-causing-problems-in-native-dependencies),
but modified it slightly to fix some of the cases that are covered by the
default merge strategy mentioned in the sbt-assembly docs (
https://github.com/sbt/sbt-assembly#merge-strategy).
Separately, because jai-tools is using jts-1.12, whose classes conflict
with the newer jts-core and jts-example packages, SBT will automatically
remove it entirely by default. This causes others things in GeoTools to
break. To fix this, you need to shade that version using:
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("com.vividsolutions.**" -> "shadeio.@1")
.inLibrary("com.vividsolutions" % "jts" % "1.12")
.inProject
)
Hope this helps!
Ryan Brideau
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel