如何在 Simple Build Tool 的子项目中共享我的 lib 文件夹
我有一个项目运行简单的构建工具作为构建工具。我的所有子项目都共享相同的依赖项,因此我希望它们使用相同的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想将父项目的非托管类路径(即 lib 目录)添加到子项目中,您可以执行以下操作:
在 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:Defining paths in the
ParentProject
class (e.g. usingval dirJars = descendents("dir", "*.jar")
) and adding them toSubProject
the same way as above also works.