如何在 Simple Build Tool 的子项目中共享我的 lib 文件夹

发布于 2024-09-29 23:58:37 字数 679 浏览 5 评论 0原文

我有一个项目运行简单的构建工具作为构建工具。我的所有子项目都共享相同的依赖项,因此我希望它们使用相同的 lib 文件夹。我可以通过创建指向我的共享 lib 文件夹的符号链接来做到这一点,但我希望在 sbt 中找到一个配置,让我可以更改我的库的路径。

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

不起作用,路径中不允许“..”不起作用

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
    }
}

,dependencyPath是项目相对路径

dependencyPath.absolutePath

也不起作用,因为absolutePath创建带斜杠的字符串,并且不能从带斜杠的字符串创建路径。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪了杯 2024-10-06 23:58:37

如果您只想将父项目的非托管类路径(即 lib 目录)添加到子项目中,您可以执行以下操作:

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(_))
}

在 ParentProject 类中定义路径(例如使用 val dirJars = Descendents("dir", "*.jar")) 并将它们添加到 SubProject 中,方法与上面相同也可以。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文