在sbt的build.sbt文件中添加模块依赖关系信息 [英] Adding module dependency information in sbt's build.sbt file

查看:972
本文介绍了在sbt的build.sbt文件中添加模块依赖关系信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IntelliJ中有一个多模块项目,如此屏幕截图所示,contexProcessor模块依赖于contextSummary模块。

I have a multi module project in IntelliJ, as in this screen capture shows, contexProcessor module depends on contextSummary module.

一旦我在Project Structure中设置了依赖项,IntelliJ就会处理所有事情。

IntelliJ takes care of everything once I setup the dependencies in Project Structure.

但是,当我运行<$ c时$ c> sbt test 在 build.sbt 中进行了以下设置,我收到一条错误,抱怨它在contextSummary模块中找不到包。

However, when I run sbt test with the following setup in build.sbt, I got an error complaining that it can't find the packages in contextSummary module.

name := "contextProcessor"

version := "1.0"

scalaVersion := "2.11.7"

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.2" % "test"

< img src =https://i.stack.imgur.com/PAYwF.pngalt =在此处输入图像说明>

如何教sbt发现缺少的模块?

How to teach sbt that the missing modules are found?

推荐答案

我可以使用 build.sbt 主目录中的文件。

I could use the build.sbt file in the main root directory.

lazy val root = (project in file(".")).aggregate(contextSummary, contextProcessor)
lazy val contextSummary = project
lazy val contextProcessor = project.dependsOn(contextSummary)

参考:< a href =http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Multi-Project.html =nofollow noreferrer> http://www.scala-sbt.org /0.13.5/docs/Getting-Started/Multi-Project.html

仅测试一个项目,我可以使用项目命令在 sbt

For testing only one project, I can use project command in sbt.

> sbt
[info] Set current project to root (in build file:/Users/smcho/Desktop/code/ContextSharingSimulation/)
> project contextProcessor
[info] Set current project to contextProcessor (in build file:/Users/smcho/Desktop/code/ContextSharingSimulation/)
> test

对于批处理模式,如如何在SBT 0.13.1中将命令行参数传递给程序?

sbt "project contextProcessor" test

这篇关于在sbt的build.sbt文件中添加模块依赖关系信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆