在scalaide中构建项目时出现问题

时间:2017-01-09 08:59:50

标签: eclipse scala scala-ide

我正在使用Scala IDE eclipse版本4.4.0和Scala 2.11.8。我可以使用sbt compile从命令行编译项目,并使用sbt eclipse创建eclipse特定的项目文件(使用sbteclipse)。但是,当我在上下文菜单中单击构建项目时,它给出了异常

**Errors occurred during the build.
Errors running builder 'Scala Builder' on project project_name.
org.eclipse.core.internal.resources.File cannot be cast to org.eclipse.core.resources.IContainer**

这里的错误日志相同。

**!ENTRY org.scala-ide.sdt.core 4 0 2017-01-09 14:13:56.020
!MESSAGE Error thrown while initializing the presentation compiler.
!STACK 0
java.lang.ClassCastException: org.eclipse.core.internal.resources.File cannot be cast to org.eclipse.core.resources.IContainer
    at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2$$anonfun$apply$7.apply(ScalaProject.scala:242)
    at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2$$anonfun$apply$7.apply(ScalaProject.scala:232)
    at scala.Option$WithFilter.map(Option.scala:207)
    at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2.apply(ScalaProject.scala:232)
    at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2.apply(ScalaProject.scala:231)
    at scala.collection.TraversableLike$WithFilter$$anonfun$flatMap$2.apply(TraversableLike.scala:714)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.TraversableLike$WithFilter.flatMap(TraversableLike.scala:713)
    at org.scalaide.core.internal.project.ScalaProject.sourceOutputFolders(ScalaProject.scala:231)
    at org.scalaide.core.internal.project.ScalaProject.initializeCompilerSettings(ScalaProject.scala:478)
    at org.scalaide.core.internal.project.ScalaProject.org$scalaide$core$internal$project$ScalaProject$$prepareCompilerSettings(ScalaProject.scala:435)
    at org.scalaide.core.internal.project.ScalaProject$$anonfun$5.apply(ScalaProject.scala:159)
    at org.scalaide.core.internal.project.ScalaProject$$anonfun$5.apply(ScalaProject.scala:159)
    at org.scalaide.core.internal.compiler.PresentationCompilerProxy.liftedTree1$1(PresentationCompilerProxy.scala:152)
    at org.scalaide.core.internal.compiler.PresentationCompilerProxy.create(PresentationCompilerProxy.scala:151)
    at org.scalaide.core.internal.compiler.PresentationCompilerProxy.initialize(PresentationCompilerProxy.scala:116)
    at org.scalaide.core.internal.compiler.PresentationCompilerProxy.obtainPc$1(PresentationCompilerProxy.scala:78)
    at org.scalaide.core.internal.compiler.PresentationCompilerProxy.internal(PresentationCompilerProxy.scala:98)
    at org.scalaide.core.internal.jdt.model.ScalaCompilationUnit$class.addToIndexer(ScalaCompilationUnit.scala:157)
    at org.scalaide.core.internal.jdt.model.ScalaSourceFile.addToIndexer(ScalaSourceFile.scala:66)
    at org.scalaide.core.internal.jdt.search.ScalaSourceIndexer$$anonfun$indexDocument$2.apply(ScalaSourceIndexer.scala:16)
    at org.scalaide.core.internal.jdt.search.ScalaSourceIndexer$$anonfun$indexDocument$2.apply(ScalaSourceIndexer.scala:16)
    at scala.Option.map(Option.scala:146)
    at org.scalaide.core.internal.jdt.search.ScalaSourceIndexer.indexDocument(ScalaSourceIndexer.scala:16)
    at scala.tools.eclipse.contribution.weaving.jdt.indexerprovider.IndexerProviderAspect.ajc$around$scala_tools_eclipse_contribution_weaving_jdt_indexerprovider_IndexerProviderAspect$1$16276a3c(IndexerProviderAspect.aj:30)
    at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.indexDocument(JavaSearchParticipant.java:71)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexDocument(IndexManager.java:504)
    at org.eclipse.jdt.internal.core.search.indexing.IndexManager$1.execute(IndexManager.java:984)
    at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:405)
    at java.lang.Thread.run(Thread.java:745)**

1 个答案:

答案 0 :(得分:0)

您的Scala IDE Eclipse插件使用内部类而不是Eclipse中的公共API(ClassCastException ... org.eclipse. ... {{1}中的类} ...)。这可能是因为在较新版本的Eclipse中使用旧版本的Scala插件。

使用 EclipseScala IDE plug-in的最新版本,或使用包含Eclipse的 Scala IDE ,Scala和已经测试过的版本的Scala插件。

相关问题