开发者

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

开发者 https://www.devze.com 2023-01-22 08:53 出处:网络
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 lin

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开发者_StackOverflow 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号