【问题标题】:Accessing classes from non-SBT dependencies included via git in SBT通过 SBT 中的 git 访问来自非 SBT 依赖项的类
【发布时间】:2016-04-08 12:40:48
【问题描述】:

我需要在我的 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 构建的。

所以我不确定我是否已经导入了该项目,尽管我可能已经导入了,而且我也不确定这些类排除是否有效。我希望有人能解释一下吗?

【问题讨论】:

    标签: scala sbt


    【解决方案1】:

    AFAIK,这是不允许的:SBT 只能通过 Git 导入依赖项,这些依赖项本身是用 SBT 构建的。您可以publish it to your local repository 并像往常一样使用libraryDependencies 依赖它。唯一的问题是,如果您对依赖项进行更改,则必须重新发布它。

    【讨论】:

      猜你喜欢
      • 2017-10-17
      • 2013-08-26
      • 2013-12-03
      • 1970-01-01
      • 2016-05-16
      • 2021-10-08
      • 1970-01-01
      • 2018-03-20
      • 2019-04-02
      相关资源
      最近更新 更多