-->

Build maven project as a part of SBT build

2020-08-21 06:24发布

问题:

I have a sbt project that depends on a maven project.
Is it possible to make that maven project into a sub-module of sbt project, and build that maven project together as a part of SBT build?

回答1:

Try to add to your maven project build.sbt:

name := "mavenDep"

scalaVersion in Global := "2.10.2"

externalPom()

See Sbt documentation: Maven pom (dependencies only) externalPom does not add maven repositories - just dependencies.

So you have to add manually other repositories:

resolvers in Global ++= Seq( "snapshots" at "http://oss.sonatype.org/content/repositories/snapshots", "releases" at "http://oss.sonatype.org/content/repositories/releases")



回答2:

You could also try this:

https://github.com/sbt/sbt-pom-reader

For limited sets of maven projects (i.e. ones that don't use plugins) it can pull in information from maven into sbt in a slightly better way. However, mapping maven plugins into sbt is practically a failed task.