简体   繁体   English

如何将SBT类附加到Intellij Idea?

[英]How to attach SBT classes to Intellij Idea?

I have probably a silly problem. 我可能有一个愚蠢的问题。 I would like to write SBT build script (Build.scala) in IntelliJ Idea but IDE does not recognize SBT classes (Build, Project, etc.). 我想在IntelliJ Idea中编写SBT构建脚本(Build.scala),但IDE不识别SBT类(Build,Project等)。 I attached sbt-launch.jar to the project but it didn't change anything since sbt-launch.jar does not contain these classes. 我将sbt-launch.jar附加到项目中,但由于sbt-launch.jar不包含这些类,所以它没有改变任何内容。 What should I do to make this work? 我应该怎么做才能使这项工作?

Ok, on a Linux system with ZSH installed, I've been using the following to elucidate class file locations.... nasty, but better than nothing 好的,在安装了ZSH的Linux系统上,我一直在使用以下内容来阐明类文件位置....讨厌,但总比没有好

zsh

setopt extendedglob

for i ( /home/work/.sbt/boot/scala-2.9.2/org.scala-sbt/sbt/0.12.0/*(.) ); do for j ( $(zipinfo -1 $i) ) ; do echo $i $j ; done ; done | grep Task

Using the above, I discovered that Task is defined in: 使用上面的内容,我发现Task的定义如下:

/home/work/.sbt/boot/scala-2.9.2/org.scala-sbt/sbt/0.12.0/task-system-0.12.0.jar

I guess we will need to do this for ever referenced class. 我想我们需要为所引用的类做这个。

What you need to attach is the SBT libraries which is downloaded not the sbt launcher. 您需要附加的是SBT库,它不是sbt启动器下载的。 SBT launcher jar downloads SBT and Scala into a different directory. SBT启动程序jar将SBT和Scala下载到不同的目录中。

I would also suggest using sbt-idea plugin instead of trying to setup the project yourself. 我还建议使用sbt-idea插件而不是尝试自己设置项目。 But If you still want to do it by yourself then add the following jar files to your intellij module: 但是如果你仍然想自己做,那么将以下jar文件添加到你的intellij模块:

<boot dir>/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.2/*.jar
<boot dir>/scala-2.9.1/lib/*.jar

The boot dir is different depending on how you installed sbt. 启动目录根据您安装sbt的方式而有所不同。 If you installed from yum or some other standard way your boot directory will be ~/.sbt/boot. 如果你从yum或其他标准方式安装,你的启动目录将是〜/ .sbt / boot。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM