Open mkneissl opened 13 years ago
Currently I consider this out of scope, but will keep it around as a feature request.
This would be a really nice tool to have...
I've been using gen-idea for intellij idea and it do just that, then when I'm back on eclipse+sbteclipse I really miss that feature, so bad that I ended up simulating it by hand... creating a new eclipse project inside
Of course a couple of things must be thought, idea is great for nesting "modules", so you just "mount" the "project" dir as a new module, in eclipse I guess a new project named "
Out of Scope ?? .. Heiko!!! Think!! ;)
I actually found it quite stupid editing a .scala source file in scalaIDE without any IDE support. Its even worse, scalaIDE detects this Build.scala as a scala source file and consequently shows errors within the editor. Quite annoying. Idea adds the sbt libraries to a specific scope, done. Yeah, as plalloni says, its a question how to implement this in Eclipse. One way is to not create another project but just add "build" folder to the sources and add sbt libraries. One could think of an option to generate this special "sbt" support, so you simple to disable (or not enable by default). The major drawback is that you pollute the eclipse build path with dependencies you usually would not have. What i would not like: another project in eclipse for each SBT build. Since those build projects can be nested, god knows what you'll get on an average sized project with many (regular) submodules.
Another thing could be "native" support by the scalaIDE plugin. So not just generating "stupid" .classpath files but ClasspathContainers that add much more flexibility. Basically just like its done in m2eclipse for maven.
But i'm sure typesafe is working on this.. ;) On the other hand i would like to know how you (Heiko) actually work with this tool chain we currently have. Simply use VI for editing Build.scala ?
You wrote: "Its even worse, scalaIDE detects this Build.scala as a scala source file and consequently shows errors within the editor"
That does not happen for me. Build.scala is in the project directory which by default should not be an Eclipse source folder.
mmhh.. just found this https://scala-ide-portfolio.assembla.com/spaces/sbt-builder-for-eclipse .. is this what i think it is ?
heh.. somehow eclipse gets hold of it and does. I understand this is a glitch in eclipse. But it would be cool anyhow to get IDE support of the build file written in scala. Thinking more about it, it definitely would make sense if scalaIDE itself (as an eclipse plugin ) would get hold of it and provide fill support for editing this file.
On Wed, Nov 2, 2011 at 7:57 PM, Heiko Seeberger < reply@reply.github.com>wrote:
You wrote: "Its even worse, scalaIDE detects this Build.scala as a scala source file and consequently shows errors within the editor"
That does not happen for me. Build.scala is in the project directory which by default should not be an Eclipse source folder.
Reply to this email directly or view it on GitHub: https://github.com/typesafehub/sbteclipse/issues/26#issuecomment-2607843
Toni Menzel Source http://tonimenzel.com
This feature would be highly useful. Editing the Build.scala file is just a pain right now, granted that it would make most sense for Scala IDE to provide edit support just like any scala source file, but making the eclipse sbt plugin generate a project would be very, very usefull.
This would be an awesome feature.
Struggling with exactly this right now. The obvious path of just "sbt eclipse"-ing the project folder does not work. I've added Build.scala to the classpath but this pops up lots of errors as it is missing the sbt library. The next step is adding the sbt library manually to eclipse...
@cos My plugin, unrelated to this one, SBT Console for Scala IDE, actually does that for you, when you edit a SBT build file in the project folder and enable the relevant feature in the options. It's a bit experimental, though (the feature - the console itself works great, imho). :)
+2 for supporting eclipse on sbt. Circular link back to one recipe for accomplishing this: https://groups.google.com/d/msg/simple-build-tool/zA27U9AoNSU/dikm32YWKQUJ
Here's how you can accomplish this:
1) Install sbteclipse as a global plugin ( ~/.sbt/plugins/eclipse.sbt
)
2) Do this in SBT
sbt> reload plugins
sbt> eclipse
sbt>
3) Go into Eclipse and modify the "Build Path". Remove src/main/*
and add the root directory.
4) clean and rebuild. VIOLA, eclipse support and boy is it good.
Heiko - Can we add this to the documentation, and if so, where?
Cool trick!
Already added: https://github.com/typesafehub/sbteclipse/wiki/Using-sbteclipse
Nice! Note that if you are using Paul Phillips' script, it would go into ~/.sbt/0.11.3/plugins for example.
+1
I did some further tweaking of the generated classpath:
Could this functionality (not that ugly code of course) be added to the plugin itself?
import sbt. import Keys. import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
object LpfBuildBuild extends Build { private def createT() = { import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseTransformerFactory import com.typesafe.sbteclipse.core._ import scala.xml.transform.RewriteRule import scala.xml.Node import scala.xml.Elem
EclipseKeys.classpathTransformerFactories := Seq(new EclipseTransformerFactory[RewriteRule] {
override def createTransformer(project: sbt.ProjectRef, state: sbt.State): Validation[RewriteRule] = {
scalaz.Success(new RewriteRule {
var rootEmitted = false
override def transform(n: Node): Seq[Node] = {
//println(n)
val result = n match {
case e:Elem if(e.label == "classpathentry") =>
if ((n \ "@kind" text) == "src") {
if ((n \ "@path" text).startsWith("src/"))
Seq()
else
Seq(n)
} else
Seq(n)
case e:Elem if(e.label == "classpath") =>
<classpath>
{ e.child}
<classpathentry including="*.scala" kind="src" path=""/>
</classpath>
}
//println("=> "+result)
result
}
})
}
})
}
lazy val lpfBuild = Project( id = "lpf-build", base = file(".") , settings = Defaults.defaultSettings ++ Seq(createT()) ) }
Nice fix! I'd love to get this more "default" out of thofbox friendly...
Cool, this glitch/feature actually works, it's vital. @hseeberger Would it make sense to mention about the directory structure https://github.com/typesafehub/sbteclipse/wiki/Using-sbteclipse#eclipse-support-for-build-definition ?
To be able to edit the SBT build definition from within Eclipse with full support, it would be useful to have a project generated for the project and project/plugins directories, too.