如何使用sbt

时间:2018-03-08 13:54:59

标签: scala sbt

我正在尝试从mac上的终端编译scala项目。 该项目于2013年启动

我已经安装了java sdk 7和sbt 1.1.1 with homebrew

当我运行命令

sbt
从项目根文件夹

我得到以下错误和警告。

[info] Loading project definition from /Users/Sarfaraz/work/projects/git_repos/abc/scala_project/project/project
[info] Loading project definition from /Users/Sarfaraz/work/projects/git_repos/abc/scala_project/project
[info] Updating {file:/Users/Sarfaraz/work/projects/git_repos/abc/scala_project/project/}default-085b3b...
[info] Resolving com.typesafe.sbt#sbt-scalariform;1.0.0 ...
[warn] Host www.saraframework.com not found. url=http://www.saraframework.com/artifactory/ivy/com.typesafe.sbt/sbt-scalariform/scala_2.9.2/sbt_0.12/1.0.0/ivys/ivy.xml
[info] You probably access the destination server through a proxy server that is not well configured.
[warn]  module not found: com.typesafe.sbt#sbt-scalariform;1.0.0
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbt/sbt-scalariform/scala_2.9.2/sbt_0.12/1.0.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/com.typesafe.sbt/sbt-scalariform/scala_2.9.2/sbt_0.12/1.0.0/ivys/ivy.xml
[warn] ==== local: tried
[warn]   /Users/Sarfaraz/.ivy2/local/com.typesafe.sbt/sbt-scalariform/scala_2.9.2/sbt_0.12/1.0.0/ivys/ivy.xml
[warn] ==== sbt-plugin-snapshots: tried
[warn]   http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots/com.typesafe.sbt/sbt-scalariform/scala_2.9.2/sbt_0.12/1.0.0/ivys/ivy.xml
[warn] ==== Sara Ivy: tried
[warn]   http://www.saraframework.com/artifactory/ivy/com.typesafe.sbt/sbt-scalariform/scala_2.9.2/sbt_0.12/1.0.0/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/typesafe/sbt/sbt-scalariform_2.9.2_0.12/1.0.0/sbt-scalariform-1.0.0.pom
[info] Resolving com.sara.sbt#web-service;1.0.4 ...
[warn] Host www.saraframework.com not found. url=http://www.saraframework.com/artifactory/ivy/com.sara.sbt/web-service/scala_2.9.2/sbt_0.12/1.0.4/ivys/ivy.xml
[info] You probably access the destination server through a proxy server that is not well configured.
[warn]  module not found: com.sara.sbt#web-service;1.0.4
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/com.sara.sbt/web-service/scala_2.9.2/sbt_0.12/1.0.4/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/com.sara.sbt/web-service/scala_2.9.2/sbt_0.12/1.0.4/ivys/ivy.xml
[warn] ==== local: tried
[warn]   /Users/Sarfaraz/.ivy2/local/com.sara.sbt/web-service/scala_2.9.2/sbt_0.12/1.0.4/ivys/ivy.xml
[warn] ==== sbt-plugin-snapshots: tried
[warn]   http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots/com.sara.sbt/web-service/scala_2.9.2/sbt_0.12/1.0.4/ivys/ivy.xml
[warn] ==== Sara Ivy: tried
[warn]   http://www.saraframework.com/artifactory/ivy/com.sara.sbt/web-service/scala_2.9.2/sbt_0.12/1.0.4/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/sara/sbt/web-service_2.9.2_0.12/1.0.4/web-service-1.0.4.pom
[info] Resolving org.scala-sbt#precompiled-2_10_1;0.12.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.sbt#sbt-scalariform;1.0.0: not found
[warn]  :: com.sara.sbt#web-service;1.0.4: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.typesafe.sbt:sbt-scalariform:1.0.0 (sbtVersion=0.12, scalaVersion=2.9.2)
[warn]      com.sara.sbt:web-service:1.0.4 (sbtVersion=0.12, scalaVersion=2.9.2)
[warn] 
sbt.ResolveException: unresolved dependency: com.typesafe.sbt#sbt-scalariform;1.0.0: not found
unresolved dependency: com.sara.sbt#web-service;1.0.4: not found
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:117)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:117)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:105)
    at sbt.IvySbt.liftedTree1$1(Ivy.scala:52)
    at sbt.IvySbt.action$1(Ivy.scala:52)
    at sbt.IvySbt$$anon$3.call(Ivy.scala:61)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
    at xsbt.boot.Using$.withResource(Using.scala:10)
    at xsbt.boot.Using$.apply(Using.scala:9)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at sbt.IvySbt.withDefaultLogger(Ivy.scala:61)
    at sbt.IvySbt.withIvy(Ivy.scala:102)
    at sbt.IvySbt.withIvy(Ivy.scala:98)
    at sbt.IvySbt$Module.withModule(Ivy.scala:117)
    at sbt.IvyActions$.update(IvyActions.scala:121)
    at sbt.Classpaths$$anonfun$work$1$1.apply(Defaults.scala:955)
    at sbt.Classpaths$$anonfun$work$1$1.apply(Defaults.scala:953)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$58.apply(Defaults.scala:976)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$58.apply(Defaults.scala:974)
    at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:35)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:978)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:973)
    at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:45)
    at sbt.Classpaths$.cachedUpdate(Defaults.scala:981)
    at sbt.Classpaths$$anonfun$47.apply(Defaults.scala:858)
    at sbt.Classpaths$$anonfun$47.apply(Defaults.scala:855)
    at sbt.Scoped$$anonfun$hf10$1.apply(Structure.scala:586)
    at sbt.Scoped$$anonfun$hf10$1.apply(Structure.scala:586)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:41)
    at sbt.std.Transform$$anon$5.work(System.scala:71)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:238)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
    at java.lang.Thread.run(Thread.java:748)
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.sbt#sbt-scalariform;1.0.0: not found
[error] unresolved dependency: com.sara.sbt#web-service;1.0.4: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q

plugin.sbt文件就像这样

scalacOptions += "-deprecation"

credentials ++= Seq(
    Credentials("Sara Server", "www.saraframework.com", "saradeveloper", "teamkp"))

resolvers += Resolver.url("sbt-plugin-snapshots",
  new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots/"))(
    Resolver.ivyStylePatterns)

resolvers += Resolver.url("Sara Ivy", url("http://www.saraframework.com/artifactory/ivy"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.0")

addSbtPlugin("com.sara.sbt" % "web-service" % "1.0.4")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.2")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.3")

和build.sbt文件是

import com.typesafe.sbt.SbtScalariform.{ScalariformKeys, scalariformSettings}
import scalariform.formatter.preferences._
import com.sara.sbt.common.Dependencies._
import net.virtualvoid.sbt.graph.Plugin.graphSettings

webServiceSettings

net.virtualvoid.sbt.graph.Plugin.graphSettings

name := "project"

version := "0.0.1-SNAPSHOT"

scalaVersion := "2.12.4"

scalacOptions += "-language:postfixOps"

ivyXML := <dependencies>
  <exclude module="slf4j-log4j12"/>
  <exclude module="grizzled-slf4j_2.9.1"/>
  <exclude module="jsr311-api" />
</dependencies>

scalariformSettings

libraryDependencies += "ch.qos.logback" % "logback-classic" % "0.9.24"

libraryDependencies += "com.sara" % "social-data_2.10" % "0.0.7"

libraryDependencies += "com.sara" % "aws-utils_2.10" % "0.0.2"

libraryDependencies += "com.sara" % "messaging_2.10" % "0.0.4"

libraryDependencies += "com.sara" % "persistence_2.10" % "0.0.3"

libraryDependencies += "org.scalastic" %% "scalastic" % "0.90.10.1"

libraryDependencies += "org.elasticsearch" % "elasticsearch" % "1.1.1"

libraryDependencies += "com.paypal.sdk" % "rest-api-sdk" % "0.7.1"

libraryDependencies += "com.novocode" % "junit-interface" % "0.9" % "test"

libraryDependencies += "org.apache.httpcomponents" % "fluent-hc" % "4.3.5"


ScalariformKeys.preferences :=
  (FormattingPreferences()
    setPreference(IndentSpaces, 2)
    setPreference(AlignParameters, false)
    setPreference(AlignSingleLineCaseStatements, true)
    setPreference(DoubleIndentClassDeclaration, true)
    setPreference(RewriteArrowSymbols, true)
    setPreference(PreserveSpaceBeforeArguments, true)
    setPreference(IndentWithTabs, false))

(excludeFilter in ScalariformKeys.format) <<= excludeFilter(_ || "*Spec.scala" || "*Test.scala" || "*Specification.scala")

// port in container.Configuration := 8080

这个构建设置是在2013年编写的,所以我猜www.saraframework.com已关闭,不再工作了。我在网上搜索了备用网址,但无法理解为什么网上没有这个内容。

我不太了解在这个阶段我应该尝试什么,所以如果有人可以指出我正确的方向或在评论中提出问题可以更好地了解情况,那就太棒了

1 个答案:

答案 0 :(得分:2)

  • 检查代理您的设置。您的sbt[info] You probably access the destination server through a proxy server that is not well configured.

  • 检查是否构建了一个简单的项目。尝试添加一个和一个依赖项,构建直到失败。调查这种特定的依赖性。

  • 检查所有依赖项。例如,Maven Central上托管的依赖项应列在https://search.maven.org/

  • 如果可以的话,主持一个有错误的最小项目(例如在GitHub上)。