当前位置: 首页 > 知识库问答 >
问题:

如何申报sbt项目中的烫伤依赖?

堵德曜
2023-03-14

我正在试图弄清楚如何为我自己的基于Scalding的项目创建build.sbt文件。

滚烫源结构没有build.sbt文件。相反,它具有project/build.scala构建定义。

将我自己的sbt项目与Scalding集成的正确方法是什么,这样我也可以稍后在Eclipse中用sbt-eclipse插件导入它?

import cascading.tuple.Fields
import com.twitter.scalding._

class Scan(args: Args) extends Job(args) {
  val output = TextLine("tmp/out.txt")

  val wordsList = List(
    ("john"),
    ("liza"),
    ("nina"),
    ("x"))

  val orderedPipe =
    IterableSource[(String)](wordsList, ('word))
      .debug
      .write(output)
}
name := "Scan"

version := "1.0"

libraryDependencies := Seq("com.twitter" %% "scalding" % "0.11.1")

我得到错误:

$ sbt
[info] Loading global plugins from /home/test/.sbt/0.13/plugins
[info] Set current project to Scan (in build file:/home/test/Cascading/Scala/Scan/)
> compile
[info] Updating {file:/home/test/Cascading/Scala/Scan/}scan...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading http://repo1.maven.org/maven2/com/twitter/scalding_2.10/0.11.1/scalding_2.10-0.11.1.jar ...
[info]  [SUCCESSFUL ] com.twitter#scalding_2.10;0.11.1!scalding_2.10.jar (641ms)
[info] Done updating.
[info] Compiling 1 Scala source to /home/test/Cascading/Scala/Scan/target/scala-2.10/classes...
[error] /home/test/Cascading/Scala/Scan/src/main/scala/Scan.scala:1: not found: object cascading
[error] import cascading.tuple.Fields
[error]        ^
[error] /home/test/Cascading/Scala/Scan/src/main/scala/Scan.scala:2: object twitter is not a member of package com
[error] import com.twitter.scalding._
[error]            ^
[error] /home/test/Cascading/Scala/Scan/src/main/scala/Scan.scala:5: not found: type Job
[error] class Scan(args: Args) extends Job(args) {
[error]                                ^
[error] /home/test/Cascading/Scala/Scan/src/main/scala/Scan.scala:5: not found: type Args
[error] class Scan(args: Args) extends Job(args) {
[error]                  ^
[error] /home/test/Cascading/Scala/Scan/src/main/scala/Scan.scala:5: too many arguments for constructor Object: ()Object
[error] class Scan(args: Args) extends Job(args) {
[error]           ^
[error] /home/test/Cascading/Scala/Scan/src/main/scala/Scan.scala:6: not found: value TextLine
[error]   val output = TextLine("tmp/out.txt")
[error]                ^
[error] /home/test/Cascading/Scala/Scan/src/main/scala/Scan.scala:15: not found: value IterableSource
[error]     IterableSource[(String)](wordsList, ('word))
[error]     ^
[error] 7 errors found
[error] (compile:compile) Compilation failed

更新2

在执行git clone git@github.com:twitter/scalding.git them repositorysbt publishlocal之后,我仍然有相同的编译错误。

name := "BlockScan"

version := "1.0"

libraryDependencies := Seq("com.twitter" %% "scalding" % "0.11.1")

lazy val scaldingCore = ProjectRef(uri("https://github.com/twitter/scalding.git"), "scalding-core")

lazy val myProject = project in file(".") dependsOn scaldingCore

'sbt Eclipse'创建未在Eclipse下编译的Eclipse项目,并报告以下错误:

Project 'Scan' is missing required Java project: 'scalding-core'
More than one scala library found in the build path (/home/test/usr/eclipse-scala-3.0.3/configuration/org.eclipse.osgi/bundles/290/1/.cp/lib/scala-library.jar, /home/test/wks/Cascading/Scala/scalding/target/scala-2.9.3/scalding-assembly-0.10.0.jar).At least one has an incompatible version. Please update the project build path so it contains only compatible scala libraries. 

scalacheck_2.9.3-1.10.0.jar is cross-compiled with an incompatible version of Scala (2.9.3). 

specs_2.9.3-1.6.9.jar is cross-compiled with an incompatible version of Scala (2.9.3). 

共有1个答案

郑嘉年
2023-03-14

由于它们似乎不会将它们的库发布到远程存储库中,在远程存储库中您可以删除必要的依赖项,因此您必须声明项目对GitHub存储库的源依赖项。

lazy val scaldingCore = ProjectRef(uri("https://github.com/twitter/scalding.git"), "scalding-core")

lazy val myProject = project in file(".") dependsOn scaldingCore

使用上述构建定义,sbt将Git克隆RootProject并加载构建。

➜  scalding  xsbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
Cloning into '/Users/jacek/.sbt/0.13/staging/e1da2accb95841ffb1df/scalding'...
[info] Loading project definition from /Users/jacek/.sbt/0.13/staging/e1da2accb95841ffb1df/scalding/project
[info] Updating {file:/Users/jacek/.sbt/0.13/staging/e1da2accb95841ffb1df/scalding/project/}scalding-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/scala_2.10/sbt_0.13/0.10.2/jars/sbt-assembly.jar ...
[info]  [SUCCESSFUL ] com.eed3si9n#sbt-assembly;0.10.2!sbt-assembly.jar (3600ms)
[info] Done updating.
[info] Compiling 3 Scala sources to /Users/jacek/.sbt/0.13/staging/e1da2accb95841ffb1df/scalding/project/target/scala-2.10/sbt-0.13/classes...
[warn] there were 8 deprecation warning(s); re-run with -deprecation for details
[warn] there were 2 feature warning(s); re-run with -feature for details
[warn] two warnings found
[info] Set current project to myProject (in build file:/Users/jacek/sandbox/scalding/)
> projects
[info] In file:/Users/jacek/sandbox/scalding/
[info]   * myProject
[info] In https://github.com/twitter/scalding.git
[info]     maple
[info]     scalding
[info]     scalding-args
[info]     scalding-avro
[info]     scalding-commons
[info]     scalding-core
[info]     scalding-date
[info]     scalding-hadoop-test
[info]     scalding-jdbc
[info]     scalding-json
[info]     scalding-parquet
[info]     scalding-repl

构建设置应该允许您访问scalding类。

> console
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_60).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import com.twitter.scalding._
import com.twitter.scalding._

scan类编译很好--它位于src/main/scala目录中。

> show sources
[info] ArrayBuffer(/Users/jacek/sandbox/scalding/src/main/scala/Scan.scala)
[success] Total time: 0 s, completed Jul 15, 2014 12:21:14 AM
> compile
[info] Updating {file:/Users/jacek/sandbox/scalding/}myProject...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/jacek/sandbox/scalding/target/scala-2.10/classes...
[success] Total time: 4 s, completed Jul 15, 2014 12:21:20 AM

您还可以Git克隆git@github.com:twitter/scalding.git它们的存储库和sbt publishlocal以便能够在build.sbt中声明二进制依赖关系,如下所示:

libraryDependencies := Seq("com.twitter" %% "scalding" % "0.11.1")

使用依赖项(无论哪种方式),执行sbt eclipse并完成它!

 类似资料:
  • 我得到了这个错误为什么在我的项目build.sbt中导入scalding sbt(参考:如何在sbt项目中声明对scalding的依赖?)。帮帮我吧。 错误:导入SBT项目时出错: ... [warn]====public:尝试了[warn] https://repo1.maven.org/maven2/com/twitter/scalding-core_2.10/0.16.0-Snapshot/

  • 在OSX上安装java,scala scalding之后,当我尝试运行WordCountJob文件时,出现以下错误 编译wordcountjob.scala scalac-classpath/users/me/.sbt/boot/scala--2.9.3/lib/scala-library.jar:/drive/me/coding/scalding/scalding-core/target/sca

  • 我有一个sbt插件项目,使用多项目构建。我想使用这个插件作为其他sbt项目的依赖项。我已经创建了一个插件,但是当我把这个插件添加到project中时,我似乎不能正确地连接依赖项。 我在这里漏掉了什么?

  • 我正在使用IntelliJ开发Spark应用程序。我正在遵循这个关于如何使intellij与SBT项目良好地工作的指导。 但这样我就无法在IntelliJ内部运行应用程序,因为类路径中不会包含spark依赖项。

  • 但是,在编译ApplicationA时,SBT抱怨依赖项只能是子目录!!: 这看起来很简单,拥有这个项目依赖项的正确方法是什么?

  • 使用IntelliJ最新的scala插件sbt 13.8和scala 2.11.7的新sbt项目,我尝试添加一个库-akka 2.4.2。在此之后,我简单地添加 [信息]解析org.scala-sbt#testing;0.13.8... [信息]解析org.scala-sbt#test-agent;0.13.8... [信息]解析org.scala-SBT#test-interface;1.0..