为什么 sbt 无法解决 gradle 可以找到的 spongeapi 依赖项?

Why does sbt fail to resolve spongeapi dependency that gradle can find fine?

我在尝试构建一个之前构建良好的项目时遇到以下错误。

Error:Error while importing SBT project:
...
    at scala.Function1$$anonfun$compose.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$$anonfun.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon.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:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] sbt.ResolveException: unresolved dependency: org.spongepowered#spongeapi;2.1-SNAPSHOT: not found
[error] Use 'last' for the full log.
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0

See complete log in C:\Users\Ryan\.IntelliJIdea14\system\log\sbt.last.log

build.sbt

name := "MemoryStones"

version := "1.0"

scalaVersion := "2.11.7"

resolvers += "sponge-repo1" at "http://repo.spongepowered.org/maven"

resolvers += Resolver.sonatypeRepo("snapshots")

resolvers += "sonatypeReleases" at "http://oss.sonatype.org/content/repositories/releases/"

libraryDependencies += "org.spongepowered" % "spongeapi" % "2.1-SNAPSHOT"

libraryDependencies += "com.typesafe" % "config" % "1.2.1"

libraryDependencies += "org.scala-lang.modules" % "scala-java8-compat_2.11" % "0.7.0"

libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"

assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)

但是,在 java/gradle 项目上使用相同的依赖项工作正常,没有错误,并且依赖项解析得很好。

build.gradle

group 'au.id.rleach'
version '0.1-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8


dependencies {

    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT'
}

repositories {
    mavenCentral()
    maven {
        name = 'sponge'
        url = 'http://repo.spongepowered.org/maven'
    }
}

我无法使用 sbt 0.13.9 重现此问题。

$ sbt
MemoryStones> update
[info] Updating {file:/Users/eugene/work/quick-test/so-34368203/}so-34368203...
[info] Resolving jline#jline;2.12.1 ...
[info] downloading http://repo.spongepowered.org/maven/org/spongepowered/spongeapi/2.1-SNAPSHOT/spongeapi-2.1-20151219.052344-209.jar ...
[info]  [SUCCESSFUL ] org.spongepowered#spongeapi;2.1-SNAPSHOT!spongeapi.jar (1545ms)
[info] downloading https://jcenter.bintray.com/org/scala-lang/modules/scala-java8-compat_2.11/0.7.0/scala-java8-compat_2.11-0.7.0.jar ...
[info]  [SUCCESSFUL ] org.scala-lang.modules#scala-java8-compat_2.11;0.7.0!scala-java8-compat_2.11.jar(bundle) (2043ms)
[info] downloading https://jcenter.bintray.com/com/flowpowered/flow-math/1.0.1/flow-math-1.0.1.jar ...
[info]  [SUCCESSFUL ] com.flowpowered#flow-math;1.0.1!flow-math.jar (671ms)
[info] downloading https://jcenter.bintray.com/ninja/leaping/configurate/configurate-yaml/3.1/configurate-yaml-3.1.jar ...
[info]  [SUCCESSFUL ] ninja.leaping.configurate#configurate-yaml;3.1!configurate-yaml.jar (399ms)
[info] downloading https://jcenter.bintray.com/ninja/leaping/configurate/configurate-gson/3.1/configurate-gson-3.1.jar ...
[info]  [SUCCESSFUL ] ninja.leaping.configurate#configurate-gson;3.1!configurate-gson.jar (403ms)
[info] downloading https://jcenter.bintray.com/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar ...
[info]  [SUCCESSFUL ] org.slf4j#slf4j-api;1.7.13!slf4j-api.jar (381ms)
[info] downloading http://repo.spongepowered.org/maven/com/flowpowered/flow-noise/1.0.1-SNAPSHOT/flow-noise-1.0.1-20150609.030116-1.jar ...
[info]  [SUCCESSFUL ] com.flowpowered#flow-noise;1.0.1-SNAPSHOT!flow-noise.jar (325ms)
[info] downloading http://repo.spongepowered.org/maven/org/spongepowered/event-gen-core/0.10-SNAPSHOT/event-gen-core-0.10-20151125.161414-1.jar ...
[info]  [SUCCESSFUL ] org.spongepowered#event-gen-core;0.10-SNAPSHOT!event-gen-core.jar (316ms)
[info] downloading https://jcenter.bintray.com/ninja/leaping/configurate/configurate-hocon/3.1/configurate-hocon-3.1.jar ...
[info]  [SUCCESSFUL ] ninja.leaping.configurate#configurate-hocon;3.1!configurate-hocon.jar (409ms)
[info] downloading https://jcenter.bintray.com/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar ...
[info]  [SUCCESSFUL ] org.yaml#snakeyaml;1.16!snakeyaml.jar(bundle) (1447ms)
[info] downloading https://jcenter.bintray.com/ninja/leaping/configurate/configurate-core/3.1/configurate-core-3.1.jar ...
[info]  [SUCCESSFUL ] ninja.leaping.configurate#configurate-core;3.1!configurate-core.jar (597ms)
[info] Done updating.
[success] Total time: 40 s, completed Dec 19, 2015 2:10:36 AM

我对您的构建文件所做的唯一更改是注释掉最后一行,因为您没有指定使用 sbt-assembly。