本文介绍了如何参考外部本地sbt项目设置多模块构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚开始使用Scala和Play,并且尝试使用sbt 0.13.5设置多版本我的项目结构如下:
I just started with Scala and Play and I'm trying to set up a multi build with sbt 0.13.5My project structure is the following:
/AnormCypher
-> /src
->/main
->/scala
->org.anormcypher[package]
->[Some classes]
-> [other dirs/files]
-> build.sbt
/sample
-> /src
->/main
->/scala
->/controllers[package]
->Application.scala
->[Some classes]
-> [other dirs/files]
-> build.sbt
该示例项目取决于AnormCypher项目.我尝试在这篇SO帖子.我的示例中的build.sbt看起来像这样:
The sample project depends on the AnormCypher project. I tried to set up the dependency following this SO post. My build.sbt in sample looks like this:
name := """sample"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
ws
)
lazy val core = ProjectRef(file("../AnormCypher"), "anormcypher")
val main = root.dependsOn(core)
当我进入控制台并键入
activator
sbt能够加载项目.但是,当我尝试编译源代码并尝试使用org.anormcypher包中的类时,无法解决它们:
sbt is able to load the project. But when I try to compile the sources and try to use classes from the org.anormcypher package, they can't be resolved:
object anormcypher is not a member of package org
[error] import org.anormcypher._
[error] ^
运行clean compile
也没有结果.
推荐答案
更改
lazy val root = (project in file(".")).enablePlugins(PlayScala)
到
lazy val root = (project in file(".")).enablePlugins(PlayScala).dependsOn(core)
然后删除
val main = root.dependsOn(core)
reload
,该项目应该可以正常运行.
reload
and the project should work fine.
这篇关于如何参考外部本地sbt项目设置多模块构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!