2012-01-24 23 views
8

मुझे मेवेन या एक्लिप्स के साथ कुछ स्कैला संकलित करने में समस्याएं आ रही हैं जहां मैं जावा जार से कक्षा आयात करने का प्रयास करता हूं जिसमें नामस्थान और समान नाम दोनों वर्ग शामिल हैं।
हालांकि, मैं scalac के साथ संकलित कर सकता हूं।पैकेज में एक ही नाम के साथ ऑब्जेक्ट और पैकेज

उदा। जावा परियोजना (जार) शामिल हैं: स्काला 2.9.0.1 (और maven-scala-plugin) के साथ Maven 3.0.03/ग्रहण 3.7.1 का उपयोग

package foo contains object and package with same name: bar 
one of them needs to be removed from classpath 

:

src/foo/bar.java 

src/foo/bar/some_resource.txt 

-> foobar.jar 

Scala project references foobar.jar 

Foobartest.scala: 

import foo.bar 

class foobartest { 

} 

संकलक के साथ शिकायत।

जिस जार में मुझे समस्या है, वह jenkins-core-1.399.jar है - इसमें निश्चित रूप से कई उदाहरण हैं जहां नामस्थान और एक ही नाम का ऑब्जेक्ट है।
मैं स्कैला में जेनकिंस प्लगइन लिखने का प्रयास कर रहा हूं (मैं इसे जावा में कर सकता हूं लेकिन स्कैला पसंद करूंगा क्योंकि हमारी सभी पुस्तकालय स्केल में हैं), जो मेवेन -
https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial का उपयोग करने पर निर्भर है।

+0

अरे क्या आपको कभी स्कैला में लिखा गया जेनकिंस प्लगइन मिला है? मैं वही – KeepCalmAndCarryOn

+0

हाँ कोशिश कर रहा हूं, यह मेरे गिटूब पर है। मैंने इसे प्रकाशित करने की कोशिश की लेकिन मुझे जेनकींस लोगों से ईमानदार होने का बहुत अच्छा समर्थन नहीं मिला। https://github.com/Chemmo/scala_plugin – David

+0

मैंने एक भी लिखा और इसे प्रकाशित किया, लेकिन प्लगइन प्रबंधक से डाउनलोड करने योग्य नहीं है https://github.com/jenkinsci/hello-world-scala-plugin – KeepCalmAndCarryOn

उत्तर

5

उस तरह की सीमा SI-4695: package object misbehaves in the presence of classfiles में उल्लिखित थी। पैकेज और वस्तु के बीच नाम स्थान टकराव को हल करने

जोड़ा एक -Y विकल्प:

रूप SI-2089 (naming restriction makes some jars unusable) में सुझाव दिया है, तो आप की कोशिश कर सकते हैं और "resolve-term-conflict" का उपयोग, changeset 25145 में लागू किया।
यह एक ब्लंट वाद्य यंत्र है: यदि लोगों में इन बहुत से संघर्ष हैं तो उन्हें अलग-अलग फैशन में हल करने की आवश्यकता है, वे शायद भाग्य से बाहर रहेंगे। रणनीति या तो पैकेज, वस्तु, त्रुटि है जहां:

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. 
4

वास्तविक संकलक विकल्प "रणनीति -Yresolve अवधि-संघर्ष" है।

संबंधित मुद्दे