Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I share my lib folder in subprojects of Simple Build Tool

Tags:

scala

sbt

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.

like image 306
Arne Avatar asked Oct 25 '22 03:10

Arne


1 Answers

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.

like image 112
Moritz Avatar answered Nov 15 '22 07:11

Moritz