tags:

views:

47

answers:

1

I have a project running simple built tool as building tool. All of my sub projects are sharing the same dependencies, so I want them to use the same lib folder. I could do so by creating symbolic links to my shared lib folder, but I hope to find a configuration in sbt that lets me change to path of my libraries.

 override def dependencyPath = ".." / "lib"

does not work, ".." is not allowed in paths

class Top(info:ProjectInfo) extends ParentProject(info){
    lazy val subproject = project("sub","Sub Project",info => SubProject(info,dependencyPath)

    class SubProject extends DefaultProject(info:ProjectInfo,libdir:Path){
        override def dependencyPath = libdir
    }
}

does not work, dependencyPath is a project relative path

dependencyPath.absolutePath

does not work either, because absolutePath creates a String with slashes, and paths may not be created from strings with slashes.

+2  A: 

If you simply want to add the parent project's unmanaged classpath (i.e. lib-directory) to the child projects you can do something like this:

class ParentProject(info: ProjectInfo) extends DefaultProject(info) { parent =>

  class SubProject(info: ProjectInfo) extends DefaultProject(info) {
    override def unmanagedClasspath =
      parent.unmanagedClasspath +++ super.unmanagedClasspath
  }

  val someProject = project("test", "Test", new SubProject(_))
}

Defining paths in the ParentProject class (e.g. using val dirJars = descendents("dir", "*.jar")) and adding them to SubProject the same way as above also works.

Moritz
thanks, but it is not that simple. my lib folder contains some native libraries which I have to set manually into the classpath. This means my programm has to be a Fork run of the Project with an overwritten runJVMOptions. In subprojects is the path not correct anymore, because they rum from a different Folder.
Arne
It works for me. Here is a working project definition that you should be able to adapt to your problem: http://gist.github.com/657060
Moritz