gpt4 book ai didi

java - Gradle应用程序插件和Scala

转载 作者:行者123 更新时间:2023-12-03 06:23:08 25 4
gpt4 key购买 nike

我有一个gradle项目,其中有一个scala子项目,例如scalamodule。我希望能够将scala子项目作为应用程序运行(这是构建/发布过程的一部分,但现在不相关)。现在,如果我使用Gradle应用程序插件,然后运行gradle :scalamodule:run,则执行的命令与此类似:

java -cp /home/giovanni/Projects/someproject/classes/main:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.wordnik/swagger-codegen_2.10/2.0.11/77ee00b1d13b23c4cb24cb43f8bb23b2ad9a492b/swagger-codegen_2.10-2.0.11.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-jackson_2.10/3.2.5/8d8839d9ea00caa5aab522c53f3bacbd7189cd7c/json4s-jackson_2.10-3.2.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/io.backchat.inflector/scala-inflector_2.10/1.3.5/7a6c4ca65263cfae1a841332df88f1f526d337b5/scala-inflector_2.10-1.3.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.3/cd8d6ffc833cc63c30d712a180f4663d8f55799b/commons-io-2.3.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.rogach/scallop_2.10/0.9.4/f262bb88c9f981413d19b295c4aa6e050da0b202/scallop_2.10-0.9.4.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.fusesource.scalate/scalate-core_2.10/1.6.1/202cab825c15fabf941ecbdfa49973c691462213/scalate-core_2.10-1.6.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-core_2.10/3.2.5/715bc4e4502a60baa9de6098f17143168e93c49f/json4s-core_2.10-3.2.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.2.2/3c8f6018eaa72d43b261181e801e6f8676c16ef6/jackson-databind-2.2.2.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.10.1/2c96f085955741faeb4f8da709e88d6feb91194e/scala-reflect-2.10.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.fusesource.scalate/scalate-util_2.10/1.6.1/1f566e429a343310858ce261565e25e9376587d0/scalate-util_2.10-1.6.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.6.1/6f3b8a24bf970f17289b234284c94f43eb42f0e4/slf4j-api-1.6.1.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-compiler/2.10.0/fec8066cd2b4f8dc7ff7ba7a8e0a792939d9f9a/scala-compiler-2.10.0.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.json4s/json4s-ast_2.10/3.2.5/f5b836a6c06e47d4dbf65f030bd9369aba07d774/json4s-ast_2.10-3.2.5.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.thoughtworks.paranamer/paranamer/2.5.6/87947002ff07ea3ba6110320f64cf021f16ddf49/paranamer-2.5.6.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scalap/2.10.0/ab42ae21d1fd7311b367fe3d7f33343f2e4bff6b/scalap-2.10.0.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.2.2/285cb9c666f0f0f3dd8a1be04e1f457eb7b15113/jackson-annotations-2.2.2.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.2/d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b/jackson-core-2.2.2.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.9.0/d13863fbd7c0bc32845c9d8a261d03b61bf28194/mockito-all-1.9.0.jar:/home/giovanni/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.10.1/ed3e1a6b0615dea666a7eaf753b03030f3f889/scala-library-2.10.1.jar com.mypack.MyClass

由于某些无法解释的原因,使用 java命令运行时,作为我的依赖项之一的scalate库抛出以下异常:
Exception in thread "main" org.fusesource.scalate.TemplateException: scala.reflect.internal.TreeInfo.firstArgument(Lscala/reflect/internal/Trees$Tree;)Lscala/reflect/internal/Trees$Tree;
at org.fusesource.scalate.TemplateEngine.compileAndLoad(TemplateEngine.scala:732)
at org.fusesource.scalate.TemplateEngine.compile(TemplateEngine.scala:346)
...
Caused by: java.lang.NoSuchMethodError: scala.reflect.internal.TreeInfo.firstArgument(Lscala/reflect/internal/Trees$Tree;)Lscala/reflect/internal/Trees$Tree;
at scala.tools.nsc.typechecker.Typers$Typer.parentTypes(Typers.scala:1550)
at scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:861)
at scala.tools.nsc.typechecker.Namers$Namer.getSig$1(Namers.scala:1300)
at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1347)
...

但是,如果我只是将 java替换为 scala,该错误就会神奇消失。

除了这个事实的怪异之处,我正在尝试实现一种解决方法,以使要执行的命令是 scala而不是 java,但我不知道该怎么做。

有人吗

最佳答案

事实证明,scala-reflect库不是问题。标量编译器是。使用的正确版本应为2.10.1,而应为2.10.0。我不确定那个图书馆是哪里来的。将深入探讨。

编辑:我应该补充一点,就是我通过让Gradle在依赖版本冲突时失败来解决了这一问题。

关于java - Gradle应用程序插件和Scala,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21194081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com