Re: [sbt] [sbteclipse] Eclipse support for build definition

358 views
Skip to first unread message

Heiko Seeberger

unread,
Nov 6, 2012, 8:24:30 AM11/6/12
to simple-b...@googlegroups.com
Either the documentation is misleading or you did it wrong. Could you please provide your build definition, then I can investigate.

Thanks
Heiko

--

Heiko Seeberger
Twitter: @hseeberger
Company: Typesafe - The software stack for applications that scale
Author of "Durchstarten mit Scala, a tutorial-style Scala book"

On Nov 5, 2012, at 11:47 PM, Matthew <mne...@gmail.com> wrote:

I followed the instructions described on the sbt eclipse wiki (https://github.com/typesafehub/sbteclipse/wiki/Using-sbteclipse) for getting eclipse support for the sbt build definition itself.  Unfortunately, the generated eclipse project does not have sbt itself added to the library dependencies, so eclipse is unable to compile anything cleanly.  Should this work?  Is there something else I need to do to be able to work on my build definition in eclipse?

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/TxRZuMgzLcIJ.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Matthew

unread,
Nov 6, 2012, 12:54:15 PM11/6/12
to simple-b...@googlegroups.com
Here's a very simple Build.scala:

import sbt._
import Keys._

object TestBuild extends Build {

  lazy val testProject = Project(
    id = "test",
    base = file("."),
    settings = Project.defaultSettings ++ Seq(
      organization := "org.example",
      version := "0.1.0-SNAPSHOT",
      scalaVersion := "2.9.2"
    )
  )
}

I put this in project/Build.scala, then in sbt reload the plugins project, set a name, and run eclipse (I have sbt eclipse plugin 2.1.0 in my .sbt/plugins/plugins.sbt).  After importing the resulting project into eclipse and adding the root directory so it picks up Build.scala itself as a source file, there is a build error right at the first line: "not found: object sbt".  I can add the sbt jars manually to the classpath and this particular error goes away, but the project shows a build error with the helpful message "Error in Scala compiler: null".  Other relevant information: I have sbt.version=0.11.3 in build.properties and I'm using the scala ide 2.1.0 Milestone 2 in eclipse 3.7.

-Matthew

Heiko Seeberger

unread,
Nov 6, 2012, 4:55:47 PM11/6/12
to simple-b...@googlegroups.com
On Nov 6, 2012, at 6:54 PM, Matthew <mne...@gmail.com> wrote:

> Here's a very simple Build.scala:
>
> import sbt._
> import Keys._
>
> object TestBuild extends Build {
>
> lazy val testProject = Project(
> id = "test",
> base = file("."),
> settings = Project.defaultSettings ++ Seq(
> organization := "org.example",
> version := "0.1.0-SNAPSHOT",
> scalaVersion := "2.9.2"
> )
> )
> }
>
> I put this in project/Build.scala, then in sbt reload the plugins project, set a name, and run eclipse (I have sbt eclipse plugin 2.1.0 in my .sbt/plugins/plugins.sbt). After importing the resulting project into eclipse and adding the root directory so it picks up Build.scala itself as a source file, there is a build error right at the first line: "not found: object sbt". I can add the sbt jars manually to the classpath and this particular error goes away, but the project shows a build error with the helpful message "Error in Scala compiler: null". Other relevant information: I have sbt.version=0.11.3 in build.properties and I'm using the scala ide 2.1.0 Milestone 2 in eclipse 3.7.

How does your .classpath in <project-dir>/project/.classpath look like? And what Scala version is your Scala IDE for?

Thanks
Heiko

Matthew Neeley

unread,
Nov 6, 2012, 5:50:40 PM11/6/12
to simple-b...@googlegroups.com
here's the class path:

<classpath>
<classpathentry output="target/scala-2.9.1/classes"
path="src/main/scala" kind="src"></classpathentry>
<classpathentry output="target/scala-2.9.1/classes"
path="src/main/java" kind="src"></classpathentry>
<classpathentry output="target/scala-2.9.1/test-classes"
path="src/test/scala" kind="src"></classpathentry>
<classpathentry output="target/scala-2.9.1/test-classes"
path="src/test/java" kind="src"></classpathentry>
<classpathentry kind="con"
path="org.scala-ide.sdt.launching.SCALA_CONTAINER"></classpathentry>
<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER"
kind="con"></classpathentry>
<classpathentry path="bin" kind="output"></classpathentry>
</classpath>

The IDE is the latest milestone version for 2.9. The scala library
version is reported as 2.9.3-20120906-004703-4c11a6593c.

-Matthew
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.

Heiko Seeberger

unread,
Nov 7, 2012, 1:08:20 AM11/7/12
to simple-b...@googlegroups.com
On Nov 6, 2012, at 11:50 PM, Matthew Neeley <mne...@gmail.com> wrote:

> here's the class path:
>
> <classpath>
> <classpathentry output="target/scala-2.9.1/classes"
> path="src/main/scala" kind="src"></classpathentry>
> <classpathentry output="target/scala-2.9.1/classes"
> path="src/main/java" kind="src"></classpathentry>
> <classpathentry output="target/scala-2.9.1/test-classes"
> path="src/test/scala" kind="src"></classpathentry>
> <classpathentry output="target/scala-2.9.1/test-classes"
> path="src/test/java" kind="src"></classpathentry>
> <classpathentry kind="con"
> path="org.scala-ide.sdt.launching.SCALA_CONTAINER"></classpathentry>
> <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER"
> kind="con"></classpathentry>
> <classpathentry path="bin" kind="output"></classpathentry>
> </classpath>
>
> The IDE is the latest milestone version for 2.9. The scala library
> version is reported as 2.9.3-20120906-004703-4c11a6593c.

Indeed, there are no source entries for the library dependencies (sbt). Weird.

Could you please give sbt 0.12.1 a try? That's the only significant difference from my setup.

If that doesn't help, please start sbt, execute "reload plugins" and then "show dependency-classpath". That should show a large list including artifacts with group id "org.scala-sbt".

Thanks
Heiko

Josh Suereth

unread,
Nov 7, 2012, 7:37:30 AM11/7/12
to simple-b...@googlegroups.com

skip-parents=false is mandatory when running eclipse on the sbt plugins project.

Very unsure of why, but that may help?

Heiko Seeberger

unread,
Nov 7, 2012, 11:07:04 AM11/7/12
to simple-b...@googlegroups.com
On Nov 7, 2012, at 1:37 PM, Josh Suereth <joshua....@gmail.com> wrote:

skip-parents=false is mandatory when running eclipse on the sbt plugins project.

It works for me without setting skipParents to false.

Heiko

Josh Suereth

unread,
Nov 7, 2012, 12:15:02 PM11/7/12
to simple-b...@googlegroups.com

Huh, I'm on 2.0.0, wonder if it was an issue back then?

Matthew

unread,
Nov 7, 2012, 1:10:45 PM11/7/12
to simple-b...@googlegroups.com
Trying with sbt 0.12.1 worked.  Thanks for the help!

Kevin Esler

unread,
Nov 12, 2012, 10:54:30 AM11/12/12
to simple-b...@googlegroups.com
As an Eclipse IDE user I'm glad I can now view my SBT build from Eclipse. Thanks for that.

What is the recommended way to achieve the next step of allowing convenient navigation into SBT source code from the Eclipse editor containing my Build.scala? For example here is the immediate problem I see:

I load my Build.scala into the Eclipse editor and "Open Declaration" over the "Build" in my "extends Build". I'm taken to the Eclipse class file editor with a button to "Change Attached Source". Clicking on that and trying to add an "External Location" of ....myGithubRepos/xsbt/main/ fails with "The source attachment does not contain the source for the file Build.class" no matter what variations I try.

Heiko Seeberger

unread,
Nov 12, 2012, 11:41:06 AM11/12/12
to simple-b...@googlegroups.com
On Nov 12, 2012, at 4:54 PM, Kevin Esler <kevin...@gmail.com> wrote:

> As an Eclipse IDE user I'm glad I can now view my SBT build from Eclipse. Thanks for that.

Very welcome.

> What is the recommended way to achieve the next step of allowing convenient navigation into SBT source code from the Eclipse editor containing my Build.scala? For example here is the immediate problem I see:
>
> I load my Build.scala into the Eclipse editor and "Open Declaration" over the "Build" in my "extends Build". I'm taken to the Eclipse class file editor with a button to "Change Attached Source". Clicking on that and trying to add an "External Location" of ....myGithubRepos/xsbt/main/ fails with "The source attachment does not contain the source for the file Build.class" no matter what variations I try.

That's not supported by sbteclipse yet. Please open a ticket, but I doubt it will be fixed very quickly. The reason is that sbt treats the sources for "arbitrary" library dependencies and those for sbt dependencies differently (update and update-classifiers).

Heiko

Reply all
Reply to author
Forward
0 new messages