我需要在我的SBT构建中包含git的依赖项。我已经关注了我在stackoverflow上找到的其他一些例子并且做到了这一点:
lazy val commonSettings = Seq(
version := "0.1.0",
scalaVersion := "2.10.5"
)
lazy val elastic = ProjectRef(uri("git://github.com/elastic/elasticsearch-hadoop.git"), "elasticsearch-hadoop")
// Library dependencies
lazy val indexer = (project in file("."))
.settings(commonSettings: _*)
.dependsOn(elastic)
.settings(
projectDependencies := {
Seq(
(projectID in elastic).value.
exclude("commons-beanutils", "commons-beanutils-core").
exclude("commons-collections", "commons-collections").
exclude("commons-logging", "commons-logging").
exclude("com.esotericsoftware.minlog", "minlog").
exclude("org.apache.hadoop", "hadoop-yarn-common-2.2.0").
exclude("org.apache.spark", "spark-network-common_2.10").
exclude("org.apache.spark", "spark-sql_2.10"))
})
.settings(
libraryDependencies ++=Seq(
"org.apache.spark" %% "spark-core" % "1.6.1" % "provided",
"org.apache.spark" %% "spark-sql" % "1.6.1" % "provided"
))
运行程序集时出现以下错误:
[error] /Users/nandanrao/Documents/Relink/indexer/indexer.scala:4: object elasticsearch is not a member of package org
[error] import org.elasticsearch.spark.sql._
在我发现的其他示例中,我跟随的模式,我相信依赖项也是SBT项目。 elasticsearch-hadoop库是一个用gradle构建的java项目,其中嵌入了scala项目,Spark部分,显然整个事件不是用SBT构建的。
所以我不确定我是否已经导入了该项目,尽管我可能已经进入该项目,而且我也不确定这些课程排除是否有效。我希望有人可以解释一下吗?
答案 0 :(得分:1)
AFAIK,这是不允许的:SBT只能通过Git导入依赖项,这些依赖项本身是用SBT构建的。你可以publish it to your local repository照常使用libraryDependencies
依赖它。唯一的问题是,如果你在依赖项中进行了更改,则必须重新发布它。