尝试使用 sbt 程序集 [英] trying to use sbt assembly

查看:49
本文介绍了尝试使用 sbt 程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

sbt version is 0.13.9 and scala 2.11.7/ I know previous versions of sbt relied on scala 2.10 - is that still the case? I have a Java project for which I added an assembly.sbt file in the project directory (as per the sbt assembly instructions for this version of sbt assembly):

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

我运行 sbt reload/clean 以及编译.但是,当我尝试运行程序集时,出现以下异常:

I ran sbt reload/clean as well as compile. However, when I try to run assembly, I get the following exception:

> 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 之前,我错过了什么步骤?

what step(s) a I missing before I can create a runnable jar for my java project using sbt?

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

I can setup a merge strategy if one is needed but I received a different exception when I tried using that. Any helpful suggestions would be quite welcome.

更新

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

I had created the assemly.sbt file in the wrong location. When I placed the assembly.sbt file in the same directory as the build.sbt, and ran reload/compile, I got the following error:

    [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 structure I will add screenshots later. For now, please bear with me.

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

I tried creating the assembly.sbt file inside the project subdirectory - it did not work. Then I added it to the plugins.sbt inside the same project subdirectory. When it did not work, I copied the assembly.sbt and plugin.sbt into the root directory of the project but it did not solve the issue.

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

Project directory: test-server I have added assembly.sbt and build.sbt inside /test-server I have also tried adding it ti /test-server/project

都没有用.我有理由确定我做错了什么或在我的配置中遗漏了一些东西.请分享您对解决问题所需要做的事情的想法.

Neither worked. I am reasonably sure I am doing something wrong or missing something in my config. Kindly share your thoughts as to what needs to be done to resolve the issue.

assembly.sbt

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

推荐答案

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

The issue was due to a typo in my assembly.sbt file. The assembly.sbt file needs to be inside the project subdirectory i.e. if your project root directory is test-server, one needs to place the assembly.sbt file inside the test-server/project subdirectory.

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

这篇关于尝试使用 sbt 程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆