scalamavensbtivydependency-resolution

SBT transitive dependency resolution conflict


I have a problem in SBT resolving transitive dependencies.

The error is:

java.lang.NoSuchMethodError: com.vividsolutions.jts.index.strtree.STRtree.queryBoundary()Ljava/util/List

Geospark is using jts2geojson https://github.com/bjornharrtell/jts2geojson/blob/master/pom.xml which references jts in version 1.14, but this is excluded and they use a custom artifact as a replacement. It is called JTSPlus which still lives in the com.vividsolutions namespace and provides some additional methods, i.e. the one which is missing above.

The latest geotools 17 is using jts in version 1.13 https://github.com/geotools/geotools/blob/master/pom.xml#L752-L754

I need to replace com.vividsolution.jts from geotools with org.datasyslab.jtsplus which offers additional but required functionality how can I achieve this?

In maven:

<dependency>
            <groupId>org. geotools </groupId>
            <artifactId> geotools </artifactId>
            <version>YOURVERSION</version>
            <exclusions>
                <exclusion>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
                </exclusion>
            </exclusions>
</dependency>

should work, but for SBT using

libraryDependencies ++= Seq(
  "org.geotools" % "gt-main" % geotools,
  "org.geotools" % "gt-arcgrid" % geotools,
  "org.geotools" % "gt-process-raster" % geotools)
  .map(_.excludeAll(
    ExclusionRule(organization = "com.vividsolution", artifact = "jts")
  ))

did not fix it. Actually, whe using the dependencyGraph, I can see SBT is still applying the regular jts in version 1.13 to the whole project.

How can I fix the dependencies to properly exclude the original JTS version?

My build.sbt looks like

lazy val geotools = "17.0"

resolvers += "osgeo" at "http://download.osgeo.org/webdav/geotools"
resolvers += "boundless" at "http://repo.boundlessgeo.com/main"
resolvers += "imageio" at "http://maven.geo-solutions.it"
resolvers += Resolver.mavenLocal

libraryDependencies ++= Seq(
  "org.geotools" % "gt-main" % geotools,
  "org.geotools" % "gt-arcgrid" % geotools,
  "org.geotools" % "gt-process-raster" % geotools)
  .map(_.excludeAll(
    ExclusionRule(organization = "com.vividsolution", artifact = "jts")
  ))

libraryDependencies ++= Seq(
  "org.datasyslab" % "geospark" % "0.6.1-snapshot"
)

Solution

  • Why is SBT NOT excluding these libraries despite using excludes? mentioned in the comments that allDependencies instead of libraryDependencies needs to be used. I think this is required due to the transitive problems.