scala sbt项目解决依赖关系非常慢

iyzzxitl  于 2023-10-18  发布在  Scala
关注(0)|答案(2)|浏览(161)

我的sbt项目需要超过15分钟,当我这样做

sbt clean compile

我在AWS上的一台健壮的机器上。我相当肯定这不是CPU或互联网带宽的资源问题。另外,我已经运行了几次这个命令,因此Ivy缓存被填充了。
这是我所有的构建相关文件
/build.sbt

name := "ProjectX"

version := "1.0"

scalaVersion := "2.10.5"

libraryDependencies += ("org.apache.spark" %% "spark-streaming" % "1.4.1")
  .exclude("org.slf4j", "slf4j-log4j12")
  .exclude("log4j", "log4j")
  .exclude("commons-logging", "commons-logging")
  .%("provided")

libraryDependencies += ("org.apache.spark" %% "spark-streaming-kinesis-asl" % "1.4.1")
  .exclude("org.slf4j", "slf4j-log4j12")
  .exclude("log4j", "log4j")
  .exclude("commons-logging", "commons-logging")

libraryDependencies += "org.mongodb" %% "casbah" % "2.8.1"

//test
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.4" % "test"

//logging
libraryDependencies ++= Seq(
  //facade
  "org.slf4j" % "slf4j-api" % "1.7.12",
  "org.clapper" %% "grizzled-slf4j" % "1.0.2",
  //jcl (used by aws sdks)
  "org.slf4j" % "jcl-over-slf4j" % "1.7.12",
  //log4j1 (spark)
  "org.slf4j" % "log4j-over-slf4j" % "1.7.12",
  //log4j2
  "org.apache.logging.log4j" % "log4j-api" % "2.3",
  "org.apache.logging.log4j" % "log4j-core" % "2.3",
  "org.apache.logging.log4j" % "log4j-slf4j-impl" % "2.3"
  //alternative to log4j2
  //"org.slf4j" % "slf4j-simple" % "1.7.5"
)

/project/build.properties

sbt.version = 0.13.8

/project/plugins.sbt

logLevel := Level.Warn

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.7.0")

resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"

/project/assembly.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
wrrgggsh

wrrgggsh1#

在日志中,您是否看到以下条目:

[info]  [SUCCESSFUL ] org.apache.spark#spark-streaming-kinesis-asl_2.10;1.4.1!spark-streaming-kinesis-asl_2.10.jar (239ms)

这是你在下载这些艺术品的信号换句话说,您正在启动的AMI没有填充Ivy缓存。
使用sbt 0.13.12在我的笔记本电脑与固态硬盘,我得到约5秒的clean,然后update

so-31956971> update
[info] Updating {file:/xxx/so-31956971/}app...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[success] Total time: 5 s, completed Aug 25, 2016 4:00:00 AM
8aqjt8rx

8aqjt8rx2#

更新到当前的sbt(在撰写本文时为1.9)应该会改善这一点。在1.x系列中,依赖关系解析开始使用一个新的后端,它的速度大大提高。

相关问题