Monday, December 27, 2010

Maven, SBT, and "Impossible to load parent"

I have a multi-module Scala project with Maven as the primary build tool. Lately I've been trying to run SBT beside it. The model seems good: SBT examines existing pom.xml files for dependency info, but gives you all the other good SBT stuff. It should be possible for the two systems to co-exist, even in large, multi-module systems (see Lift, or Scalate, for example.)

In my project, I ran into " Impossible to load parent ..." when running sbt update for the first time. The issue is that the parent (aggregator) pom.xml for my project was not in any repository that SBT was checking. Maven pom.xml files support the relativePath tag to deal with this, but SBT uses Ivy to get the dependencies out of the pom files, and Ivy has a bug with finding parents via relativePath. So my conclusion is there's no "good" way to handle this right now.

The ugly work-around:

  • Add val mavenLocal = "Local Maven Repository" at "file://" + (Path.userHome / ".m2" / "repository").absolutePath to the SBT project definition. This causes SBT to check the local Maven repo for dependencies.
  • Run mvn install once before using SBT. This will ensure the parent pom.xml files are put in the local repository for SBT to see.


No comments:

Post a Comment