IntelliJ Idea sbt 托管源文件 [英] IntelliJ Idea sbt managed source file

查看:23
本文介绍了IntelliJ Idea sbt 托管源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 sbt-buildinfo 插件 从我的构建定义中生成 Scala 源代码,允许我引用项目名称,我的 Scala 代码中的版本等.

I am using sbt-buildinfo plugin that generates Scala source from my build definitions, allowing me to reference project name, version, etc. from my Scala code.

它通过生成具有以下内容的文件 BuiltInfo.scala 来做到这一点:

It does this by generating a file BuiltInfo.scala with the following contents:

package hello

case object BuildInfo {
  val name = "helloworld"
  val version = "0.1-SNAPSHOT"
  val scalaVersion = "2.10.3"
  val sbtVersion = "0.13.2"
}

target/scala-2.10/src_managed/main/sbt-buildinfo/BuildInfo.scala.

一切都可以编译,我可以引用这些 val.

Everything compiles and I can reference those vals.

但是,IntelliJ Idea 不会将 BuildInfo.scala 识别为托管源文件,因此它会停止向我显示错误.知道该怎么做吗?

However, IntelliJ Idea doesn't recognize BuildInfo.scala as a managed source file, so that it would stop showing me errors. Any idea how to do that?

谢谢!

推荐答案

Grega,是您在 Play Framework 项目中工作吗?或者你有任何 SBT 子项目吗?我没有完整的答案,但可能有线索.

Grega, are you working in a Play Framework project? Or do you have any SBT sub-projects? I don't have a complete answer, but may have a lead.

使用 sbt-buildinfo 时,我的 IDEA 项目中也出现了同样的问题 sbt-scalaxb.令人沮丧的是,它的工作时断时续——通常是在经过大量修补之后,但莫名其妙地停止了.

This same problem shows up in my IDEA projects when using sbt-buildinfo and sbt-scalaxb. Frustratingly, it has worked intermittently—usually after lots of tinkering around, but inexplicably stops.

我最终深入挖掘(并最终发布了错误报告 SCL-7182 to JetBrains),并注意到根本原因是有一个子项目.如果存在,IDEA 无法正确识别根项目的 src_managed,但 可以识别 子项目.

I wound up digging a bit deeper (and eventually issued bug report SCL-7182 to JetBrains), and noticed the root cause was having a sub-project. When present, IDEA doesn't correctly identify src_managed for the root project, but does for the sub-project.

目前,一种解决方法是使用项目结构"对话框手动将正确的 src_managed 目录添加到项目的源代码中.

A work-around, for now, is to manually add the correct src_managed directory to your project's sources using the Project Structure dialog.

作为参考,我在 IntelliJ IDEA 13.1.3 上运行 Scala 插件的 0.38.437 版本.

For reference, I'm running version 0.38.437 of the Scala plugin on IntelliJ IDEA 13.1.3.

这篇关于IntelliJ Idea sbt 托管源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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