试图使用sbt汇编

时间:2016-03-13 19:58:51

标签: sbt sbt-assembly

sbt版本是0.13.9和scala 2.11.7 /我知道以前版本的sbt依赖于scala 2.10 - 是不是仍然如此?我有一个Java项目,我在项目目录中添加了一个assembly.sbt文件(根据此版本的sbt程序集的sbt程序集说明):

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.2")

我运行了sbt reload / clean以及编译。但是,当我尝试运行程序集时,我得到以下异常:

> assembly
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: assembly
[error] assembly
[error]         ^

在使用sbt为我的java项目创建可运行的jar之前,我缺少了哪些步骤?

如果需要,我可以设置合并策略,但是当我尝试使用它时,我收到了一个不同的异常。任何有用的建议都会非常受欢迎。

更新

我在错误的位置创建了assemly.sbt文件。当我将assembly.sbt文件放在与build.sbt相同的目录中,并运行reload / compile时,我收到以下错误:

    [trace] Stack trace suppressed: run last *:update for the full output.
    [error] (*:update) sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.14.2: not found
    [error] Total time: 2 s, completed Mar 13, 2016 3:20:02 PM

**running with last *:update**
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.eed3si9n:sbt-assembly:0.14.2 (scalaVersion=2.11, sbtVersion=0.13)
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      com.eed3si9n:sbt-assembly:0.14.2 (scalaVersion=2.11, sbtVersion=0.13) (/home/me/test-server/assembly.sbt#L1-2)
[warn]        +- com.test:test-server_2.11:1.0.0
sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.14.2: not found
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:294)
    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:155)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:132)
    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: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:65)
    at sbt.IvySbt.withIvy(Ivy.scala:127)
    at sbt.IvySbt.withIvy(Ivy.scala:124)
    at sbt.IvySbt$Module.withModule(Ivy.scala:155)
    at sbt.IvyActions$.updateEither(IvyActions.scala:168)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1392)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1388)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1422)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$90.apply(Defaults.scala:1420)
    at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1425)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1419)
    at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
    at sbt.Classpaths$.cachedUpdate(Defaults.scala:1442)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1371)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1325)
    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:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    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:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.14.2: not found

项目结构 我稍后会添加截图。现在,请耐心等待。

我尝试在project子目录中创建assembly.sbt文件 - 它不起作用。然后我将它添加到同一项目子目录中的plugins.sbt。当它不起作用时,我将assembly.sbt和plugin.sbt复制到项目的根目录中,但它没有解决问题。

项目目录:test-server 我在/ test-server中添加了assembly.sbt和build.sbt 我也尝试过添加ti / test-server / project

都没有奏效。我有理由相信我在做错了或在我的配置中遗漏了一些东西。请分享您对解决问题需要采取的措施的看法。

assembly.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.2")

1 个答案:

答案 0 :(得分:1)

问题是由于我的assembly.sbt文件中的拼写错误。 assembly.sbt文件需要位于项目子目录中,即如果项目根目录是test-server,则需要将assembly.sbt文件放在test-server / project子目录中。

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.2")