Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build maven project as a part of SBT build

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?

like image 645
Yeonho Avatar asked Oct 30 '13 05:10

Yeonho


People also ask

Does sbt use Maven?

Resolvers. Not all packages live on the same server; sbt uses the standard Maven2 repository by default. If your dependency isn't on one of the default repositories, you'll have to add a resolver to help Ivy find it.

Is sbt better than Maven?

Yes, sbt is recommended for people starting out with Scala, it's the tool used in almost every Scala project, so it's good to get familiar with it. Same, I've used projects with both. Using maven feels like stepping in a time machine and going backwards. SBT is way better.

What is the difference between Maven and sbt?

Once you familiarize yourself with how one Maven project builds you automatically know how all Maven projects build saving you immense amounts of time when trying to navigate many projects. On the other hand, SBT is detailed as "An open-source build tool for Scala and Java projects".


1 Answers

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"
)
like image 56
Andrzej Jozwik Avatar answered Oct 06 '22 00:10

Andrzej Jozwik