Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attach sources to SBT managed dependencies in Scala IDE?

I'm using Scala IDE 2.0.1 and SBT 0.11.2 to start with Akka 2.0.1. My build.sbt looks like this:

name := "akka"  version := "0.1"  scalaVersion := "2.9.2"  resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"  libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0.1" 

As you can see, there's nothing spectacular.

Now how can I tell Eclipse to use the artifact with the sources classifier for the akka-actor library?

In SBT, I can use update-classifiers to download sources and Javadocs to the Ivy repository, but even if I do this before running the eclipse command from the sbteclipse plugin then Eclipse still does not know the sources. Of course, I could do this manually, but this doesn't scale well for more libraries.

I have also tried to use the IvyDE plugin with the deliver-local command. While this integrates the dependency management, it doesn't seem to help with the sources.

Any clues?

Edit: This is the ivy.xml generated from deliver-local:

<?xml version="1.0" encoding="UTF-8"?> <ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra"> <info organisation="default" module="akka_2.9.2" revision="0.1" status="release" publication="20120506225613">     <description>     akka     </description> </info> <configurations>     <conf name="compile" visibility="public" description=""/>     <conf name="runtime" visibility="public" description="" extends="compile"/>     <conf name="test" visibility="public" description="" extends="runtime"/>     <conf name="provided" visibility="public" description=""/>     <conf name="optional" visibility="public" description=""/>     <conf name="sources" visibility="public" description=""/>     <conf name="docs" visibility="public" description=""/>     <conf name="pom" visibility="public" description=""/> </configurations> <publications>     <artifact name="akka_2.9.2" type="pom" ext="pom" conf="pom"/>     <artifact name="akka_2.9.2" type="jar" ext="jar" conf="compile"/>     <artifact name="akka_2.9.2" type="src" ext="jar" conf="sources" e:classifier="sources"/>     <artifact name="akka_2.9.2" type="doc" ext="jar" conf="docs" e:classifier="javadoc"/> </publications> <dependencies>     <dependency org="org.scala-lang" name="scala-library" rev="2.9.2" conf="compile->default(compile)"/>     <dependency org="com.typesafe.akka" name="akka-actor" rev="2.0.1" conf="compile->default(compile)"/>     <exclude org="org.scala-lang" module="scala-library" artifact="*" type="jar" ext="*" matcher="exact"/>     <exclude org="org.scala-lang" module="scala-compiler" artifact="*" type="jar" ext="*" matcher="exact"/>     <override org="org.scala-lang" module="scala-library" matcher="exact" rev="2.9.2"/>     <override org="org.scala-lang" module="scala-compiler" matcher="exact" rev="2.9.2"/> </dependencies> </ivy-module> 

I'm new to Ivy, so this doesn't tell me much. I just figure that it mentions sources and javadocs, but somehow the IvyDE doesn't pick it up.

like image 667
Christian Schlichtherle Avatar asked May 06 '12 17:05

Christian Schlichtherle


1 Answers

You can put

EclipseKeys.withSource := true 

to your build.sbt, which lets sbteclipse download all sources and makes them accessible within Eclipse. Note, this will download all sources from all configured dependencies. I have no idea how to tell sbt to download only the sources for single dependencies.

like image 192
kiritsuku Avatar answered Sep 22 '22 16:09

kiritsuku