SBT |如何禁用或避免.sbt / preloaded

时间:2018-12-05 08:50:53

标签: scala sbt lagom

我正在尝试使用lagom将依赖项集成到我的sbt项目中。我为此使用的是:

// The Lagom plugin
addSbtPlugin("com.lightbend.lagom" % "lagom-sbt-plugin" % "1.3.7")
// Needed for importing the project into Eclipse
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")
sbt.version=0.13.16
scala=2.11.7

这是我坚持使用scala 2.11.7的服务要求,尽管我们希望尽快对其进行升级,但这距离我们至少有6个月的时间。

我要集成的依赖项是

"com.example" % "example-models_2.11" % "1.0.0-SNAPSHOT"
val nexus_url = "https://company-repo.example.com/"
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")

resolvers += "Nexus" at s"$nexus_url/repository/example-repo/"

问题

出于某种原因,它没有尝试我的联系回购,而是在尝试:

[info] Resolving com.example#example-models_2.11;1.0.0-SNAPSHOT ...
[warn]  module not found: com.example#example-models_2.11;1.0.0-SNAPSHOT
[warn] ==== local: tried
[warn]   /home/yash/.ivy2/local/com.example/example-models_2.11/1.0.0-SNAPSHOT/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/com/example/example-models_2.11/1.0.0-SNAPSHOT/example-models_2.11-1.0.0-SNAPSHOT.pom
[warn] ==== local-preloaded-ivy: tried
[warn]   /home/yash/.sbt/preloaded/com.example/example-models_2.11/1.0.0-SNAPSHOT/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn]   file:////home/yash/.sbt/preloaded/com/example/example-models_2.11/1.0.0-SNAPSHOT/example-models_2.11-1.0.0-SNAPSHOT.pom
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.example#example-models_2.11;1.0.0-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      com.example:example-models_2.11:1.0.0-SNAPSHOT (/home/yash/development/example/build.sbt#L21)
[warn]        +- com.example:example-impl_2.11:1.0.0-SNAPSHOT
[info] 'compiler-interface' not yet compiled for Scala 2.11.7. Compiling...
[info]   Compilation completed in 8.811 s
sbt.ResolveException: unresolved dependency: com.example#example-models_2.11;1.0.0-SNAPSHOT: not found
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
    at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
    at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
    at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
    at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:95)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:80)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:99)
    at xsbt.boot.Using$.withResource(Using.scala:10)
    at xsbt.boot.Using$.apply(Using.scala:9)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:60)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:50)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
    at sbt.IvySbt.withIvy(Ivy.scala:128)
    at sbt.IvySbt.withIvy(Ivy.scala:125)
    at sbt.IvySbt$Module.withModule(Ivy.scala:156)
    at sbt.IvyActions$.updateEither(IvyActions.scala:168)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1541)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1537)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1572)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1570)
    at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1575)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1569)
    at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
    at sbt.Classpaths$.cachedUpdate(Defaults.scala:1592)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1519)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1471)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
[error] (lms-impl/*:update) sbt.ResolveException: unresolved dependency: com.example#example-models_2.11;1.0.0-SNAPSHOT: not found
[error] Total time: 876 s, completed Dec 5, 2018 1:36:18 PM

https://github.com/sbt/sbt/issues/4015https://github.com/sbt/librarymanagement/issues/224之类的讨论无济于事。

在下面的评论中,Vanya Stanislavciuc提出了一个关于解析器的好问题,谢谢提出。

现在,看来似乎Lagom问题比sbt多,所以我运行了给定的命令:

[info] Loading project definition from /home/yash/development/LF_Repos/loanframe-services/lf-lms/project
[info] Set current project to lf-lms (in build file:/home/yash/development/LF_Repos/loanframe-services/lf-lms/)
[info] lms-api/*:resolvers
[info]  List()
[info] lms-impl/*:resolvers
[info]  List()
[info] lms/*:resolvers
[info]  List()

然后我看到了如何在Lagom中提供解析器,因为它忽略了sbt解析器,因此我将其添加为Lagom方式:

lazy val `example-impl` = (project in file("example-impl"))
  .enablePlugins(LagomScala)
  .settings(
    libraryDependencies ++= Seq(
      lagomScaladslPersistenceCassandra,
      lagomScaladslKafkaBroker,
      lagomScaladslTestKit,
      lagomScaladslPersistenceJdbc,
      "com.softwaremill.macwire"    %%     "macros"               %     "2.3.0"     %     "provided",
      "org.scalatest"               %%     "scalatest"            %     "3.0.1"     %     Test,
      "com.amazonaws"               %      "aws-java-sdk-s3"      %     "1.11.117",
      "com.amazonaws"               %      "aws-java-sdk-sqs"     %     "1.11.456",
      "com.google.code.gson"        %      "gson"                 %     "2.8.1",
      "com.typesafe.slick"          %%     "slick"                %     "3.2.3",
      "com.example"               %      "example-models_2.11"  % "1.0.0-SNAPSHOT"
    ),
    resolvers += "Nexus" at s"$nexus_url/repository/example-repo/"
  )
  .settings(lagomForkedTestSettings: _*)
  .dependsOn(`example-api`)

它出现了:

[info] Loading project definition from /home/yash/development/LF_Repos/loanframe-services/lf-lms/project
[info] Set current project to lf-lms (in build file:/home/yash/development/LF_Repos/loanframe-services/lf-lms/)
[info] lms-api/*:resolvers
[info]  List()
[info] lms-impl/*:resolvers
[info]  List(Nexus: https://staging-repo.loanframe.com//repository/lf-repo/)
[info] lms/*:resolvers
[info]  List(scalaz-bintray: http://dl.bintray.com/scalaz/releases, URLRepository(Typesafe Ivy releases,Patterns(ivyPatterns=List(https://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(https://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), Nexus: https://staging-repo.loanframe.com//repository/lf-repo/)

2 个答案:

答案 0 :(得分:0)

该问题可能与resolvers键的作用域/配置有关。

您可以尝试添加ThisBuild配置,看看是否也有帮助吗?

resolvers in ThisBuild += "Nexus" at s"$nexus_url/repository/example-repo/"

答案 1 :(得分:0)

lazy val `example-impl` = (project in file("example-impl"))
  .enablePlugins(LagomScala)
  .settings(
  resolvers += "Nexus" at s"$nexus_url/repository/example-repo/",
  credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
  )
  .settings(
    libraryDependencies ++= Seq(
      lagomScaladslPersistenceCassandra,
      lagomScaladslKafkaBroker,
      lagomScaladslTestKit,
      lagomScaladslPersistenceJdbc,
    --dependencies--
   )
  )
  .settings(lagomForkedTestSettings: _*)
  .dependsOn(`example-api`)