包中包含具有相同名称的对象和包

Dav*_*vid 8 java eclipse scala maven-3 jenkins

我在使用Maven或Eclipse编译一些Scala时遇到问题,我尝试从包含命名空间和同名类的Java jar导入类.但是,
我可以编译scalac.

例如,Java项目(jar)包含:

src/foo/bar.java

src/foo/bar/some_resource.txt

-> foobar.jar

Scala project references foobar.jar

Foobartest.scala:

import foo.bar

class foobartest {

}
Run Code Online (Sandbox Code Playgroud)

编译器抱怨:

package foo contains object and package with same name: bar 
one of them needs to be removed from classpath
Run Code Online (Sandbox Code Playgroud)

使用Maven 3.0.03/Eclipse 3.7.1和Scala 2.9.0.1(和maven-scala-plugin).

我遇到问题的jar是jenkins-core-1.399.jar- 它肯定包含几个实例,其中有一个名称空间和同名对象.
我试图在Scala中编写一个Jenkins插件(我可以用Java做这个,但是我更喜欢scala,因为我们所有的库都在scala中),这取决于使用Maven -
https://wiki.jenkins-ci.org/显示/ JENKINS /插件+教程.

Von*_*onC 6

SI-4695中概述了这种限制:包类对象在类文件存在的情况下行为不端.

正如SI-2089中所建议的那样(命名限制使得某些jar无法使用),您可以尝试使用" resolve-term-conflict",如变更集25145中所实现的:

添加了一个-Y选项来解决包和对象之间的命名空间冲突.
这是一个生硬的工具:如果人们有很多这些冲突,他们需要以个别细致的方式解决,他们可能仍然没有运气.

val termConflict  = ChoiceSetting     ("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", 113 List("package", "object", "error"), "error")

// Some jars (often, obfuscated ones) include a package and
// object with the same name. Rather than render them unusable,
// offer a setting to resolve the conflict one way or the other.
// This was motivated by the desire to use YourKit probes, which
// require `yjp.jar` at runtime. See SI-2089.
Run Code Online (Sandbox Code Playgroud)


lia*_*zan 5

实际的编译器选项是“ -Yresolve-term-conflict:strategy ”,其中strategy是包,对象或错误。