sbt-idea for SBT 0.10.0

461 views
Skip to first unread message

ijuma

unread,
Jun 6, 2011, 2:39:56 AM6/6/11
to simple-b...@googlegroups.com
Hey all,

I've made a few improvements (including a critical fix) to Scott Royston's port of sbt-idea and it works pretty well now. You can find the pull request here:


And my branch here:


There are two things that still don't work:

1. The source for the Scala library doesn't get associated with the library (the source for other libraries does get associated though).
2. If the scala-compiler is a classpath dependency, it doesn't get added as an IDEA dependency.

Regarding 1, I am probably doing something wrong. I used a similar approach to the one used for normal libraries, but with UpdateSbtClassifiers:


By the way, it seems like update classifiers and update sbt classifiers are quite naive at the moment. In a multi-module build, they try to download the same dependency source or javadoc jar multiple times if many modules depend on then. It would be much faster if they remembered failures. Is it worth filing an enhancement request for this?

Regarding 2, it's a bit odd, I thought that it would work similarly to the scala-library, but I need to investigate a bit more what's going on. If you have any advice, that would be appreciated, of course.

Best,
Ismael

ijuma

unread,
Jun 6, 2011, 9:03:04 AM6/6/11
to simple-b...@googlegroups.com
I investigated this a bit more and it seems to me that Scott's approach doesn't add transitive dependencies to IDEA's classpath. Keys.libraryDependencies is used in combination with Keys.update, but the former doesn't include transitive dependencies. It would seem that using Keys.externalDependencyClasspath would solve this, but that only returns Files instead of ModuleIDs. Is there an easy way to get the module ids for externalDependencyClasspath?

Best,
Ismael

Mark Harrah

unread,
Jun 6, 2011, 10:20:20 AM6/6/11
to simple-b...@googlegroups.com

Yes, you probably do want externalDependencyClasspath for transitive dependencies, not including the output directory and inter-project dependencies.

Scott intentionally excluded transitive dependencies by only including dependencies list in libraryDependencies. There was a somewhat recent discussion on this mailing list about it.

The UpdateReport from 'update' has the ModuleIDs for all managed dependencies.

Can you follow up with what from the original email is/isn't resolved?

-Mark

royston

unread,
Jun 6, 2011, 10:47:41 AM6/6/11
to simple-b...@googlegroups.com
As Mark noted, I did this on purpose -- is there something that doesn't work correctly without listing the transitive libs?

I find not including them helps in keeping track of what a module (sub project) actually depends on....

Btw, HUGE thanks for the help!

ijuma

unread,
Jun 6, 2011, 10:51:57 AM6/6/11
to simple-b...@googlegroups.com
On Monday, 6 June 2011 15:47:41 UTC+1, royston wrote:
As Mark noted, I did this on purpose -- is there something that doesn't work correctly without listing the transitive libs?

I believe you will potentially get NoClassDefFoundErrors when running or debugging tests or classes from within IDEA, unless I am missing something.
 
Btw, HUGE thanks for the help!

No problem, it was much easier than starting from scratch, so thank you. :)

Best,
Ismael

ijuma

unread,
Jun 6, 2011, 11:07:46 AM6/6/11
to simple-b...@googlegroups.com
On Monday, 6 June 2011 15:20:20 UTC+1, Mark Harrah wrote:

The UpdateReport from 'update' has the ModuleIDs for all managed dependencies.

Right, but they also include project dependencies. I wanted to remove those. Because externalDependencyClasspath only returns the File and not the actual ModuleID, it wasn't as easy as I'd hoped. I guess I could iterate through the artifacts for each ModuleID and then match them against the Files returned via externalDependencyClasspath. Or is there a better way?

To give some context, the current code uses the ModuleID information to create an IDEA library and then the IDEA library is referenced via the name. That's why it's preferable to have a ModuleID than just the File. Also, the ModuleID is again used when matching the classifiers.

Can you follow up with what from the original email is/isn't resolved?

1. The source for the Scala library doesn't get associated with the library (the source for other libraries does get associated though).

I think this is still unresolved, but I'll investigate the artifacts returned via update-sbt-classifiers and maybe that will clarify things.

2. If the scala-compiler is a classpath dependency, it doesn't get added as an IDEA dependency.

I believe this will be resolved once transitive dependencies are included as I get it via lift-json in my project.

Best,
Ismael

Mark Harrah

unread,
Jun 6, 2011, 11:45:37 AM6/6/11
to simple-b...@googlegroups.com
On Mon, 6 Jun 2011 08:07:46 -0700 (PDT)
ijuma <ism...@juma.me.uk> wrote:

> On Monday, 6 June 2011 15:20:20 UTC+1, Mark Harrah wrote:
> >
> > The UpdateReport from 'update' has the ModuleIDs for all managed
> > dependencies.
> >
> Right, but they also include project dependencies. I wanted to remove
> those. Because externalDependencyClasspath only returns the File and not the
> actual ModuleID, it wasn't as easy as I'd hoped. I guess I could iterate
> through the artifacts for each ModuleID and then match them against the
> Files returned via externalDependencyClasspath. Or is there a better way?

Hmm, yes that could be added to sbt. As you probably know by now, a classpath is Seq[Attributed[File]]. Attributed is a typesafe heterogeneous map. It is currently only used to track the Analysis instance for an entry, but could probably be extended to associate the ModuleID and Artifact with the entry. Please open a ticket if this sounds good.

> To give some context, the current code uses the ModuleID information to
> create an IDEA library and then the IDEA library is referenced via the name.
> That's why it's preferable to have a ModuleID than just the File. Also, the
> ModuleID is again used when matching the classifiers.
>
> > Can you follow up with what from the original email is/isn't resolved?
> >
> 1. The source for the Scala library doesn't get associated with the library
> (the source for other libraries does get associated though).
>
> I think this is still unresolved, but I'll investigate the artifacts
> returned via update-sbt-classifiers and maybe that will clarify things.

Ok. If you still see an issue with sources/javadocs being checked multiple times, mention that as well. I would guess that if it happens, it is only for ones that don't exist.

> 2. If the scala-compiler is a classpath dependency, it doesn't get added as
> an IDEA dependency.
>
> I believe this will be resolved once transitive dependencies are included as
> I get it via lift-json in my project.

I agree. I initially thought that you meant a direct dependency wasn't included, but this makes sense.

ijuma

unread,
Jun 6, 2011, 12:58:03 PM6/6/11
to simple-b...@googlegroups.com
On Monday, 6 June 2011 16:45:37 UTC+1, Mark Harrah wrote:

Hmm, yes that could be added to sbt.  As you probably know by now, a classpath is Seq[Attributed[File]].  Attributed is a typesafe heterogeneous map.  It is currently only used to track the Analysis instance for an entry, but could probably be extended to associate the ModuleID and Artifact with the entry.  Please open a ticket if this sounds good.

Yes, sounds great. Filed https://github.com/harrah/xsbt/issues/41 . 

Ok.  If you still see an issue with sources/javadocs being checked multiple times, mention that as well.  I would guess that if it happens, it is only for ones that don't exist.

Yes, I got the impression that it only happened for the ones that didn't exist. I'll save a log when I try this again.

Best,
Ismael

ijuma

unread,
Jun 6, 2011, 7:54:29 PM6/6/11
to simple-b...@googlegroups.com
Hey Mark,

I've managed to get transitive dependencies to work by matching the Artifacts in the ModuleID and the Files returned by externalDependencyClasspath. One thing I noticed is that the same dependency would appear in many ConfigurationReports. Because externalDependencyClasspath doesn't include the configuration for each of the dependencies, I had to manually selecting the configuration with the highest priority (e.g. if a dependency appeared in "compile" configuration, I'd ignore all the other ones and so on). This matters because one can specify 4 scopes in the IDEA configuration ("compile", "runtime", "test", "provided"). By the way, the scala-compiler.jar did indeed appear with this fix.

In relation to sbt-update-classifiers, the result of EvaluateTask.evaluateTask(buildStruct, Keys.updateSbtClassifiers, state, projectRef, false, EvaluateTask.SystemProcessors) is:

Some(Inc(Incomplete(node=Some(ScopedKey(Scope(Select(ProjectRef(file:/media/internal0/home/ijuma/idea-workspace/foo/,common)),Global,Global,Global),update-sbt-classifiers)), tpe=init$default$2, msg=None, causes=List(), directCause=Some(sbt.ResolveException: unresolved dependency: org.scala-tools.sbt#sbt_2.9.0-1;0.10.0: not found))))

So, it never even reached the point where the report is processed. I have no idea why it's looking for sbt_2.9.0-1. Is updateSbtClassifiers special and can only be invoked from certain projects?

In relation to repeated failed download attempts during update-classifiers:

[ijuma@localhost]~% cat sbt-output| grep "NOT FOUND" | grep xerces 
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (359ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (359ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (122ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (122ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (121ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (121ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (123ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (123ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (121ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (121ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (122ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (122ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (374ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (374ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (130ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (130ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (129ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (129ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (132ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (132ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (130ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (130ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (129ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (129ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (130ms)
[warn] [NOT FOUND  ] xerces#xercesImpl;2.9.1!xercesImpl.jar (130ms)

It does look like it's trying to download the same source jar multiple times. Let me know if you'd like me to file any issues.

Best,
Ismael

Erik Post

unread,
Jun 7, 2011, 8:47:20 AM6/7/11
to simple-build-tool
On Jun 6, 8:39 am, ijuma <ism...@juma.me.uk> wrote:
> I've made a few improvements (including a critical fix) to Scott Royston's
> port of sbt-idea and it works pretty well now. You can find the pull request
> here:
>
> https://github.com/scroyston/sbt-idea/pull/1
>
> And my branch here:
>
> https://github.com/ijuma/sbt-idea/commits/sbt-0.10

Hi Ismael,

Great! Sorry if this is the wrong place to ask, but is there any
documentation available on how to tie this into a build? I've had the
sbt 0.7.x version working like a charm, but I'm a bit lost as to
0.1.0.

Cheers,
Erik

Graham Tackley

unread,
Jun 7, 2011, 9:45:00 AM6/7/11
to simple-b...@googlegroups.com
At the moment there's no binary published for sbt-idea (I don't think), but here's what I did to install it globally in sbt (similar to installing as a "processor" in sbt 0.7):

1. clone and build Ismael's sbt-idea:
     cd sbt-idea
     git checkout sbt-0.10
     ./sbt package

2. create an sbt plugin lib directory if you don't have one already
     mkdir -p  ~/.sbt/plugins/lib

3. copy the jar built in step one into here
     cp sbt-idea/target/scala-2.8.1.final/*.jar ~/.sbt/plugins/lib

Restart or reload sbt, then you can run "gen-idea" (or "gen-idea with-classifiers" if you want sources and javadoc in intelliJ too)  

Rgds
g

Erik Post

unread,
Jun 7, 2011, 10:03:01 AM6/7/11
to simple-b...@googlegroups.com

Hi Graham,

That's awesome, thanks a million!

Cheers,
Erik

ijuma

unread,
Jun 7, 2011, 10:55:00 AM6/7/11
to simple-b...@googlegroups.com
On Tuesday, 7 June 2011 14:45:00 UTC+1, Graham Tackley wrote:
1. clone and build Ismael's sbt-idea:
     cd sbt-idea
     git checkout sbt-0.10
     ./sbt package

You can use ./sbt publish-local instead of package and then you can refer to it as a dependency without having to manually copy the jar.

Best,
Ismael

Erik Post

unread,
Jun 7, 2011, 11:38:33 AM6/7/11
to simple-b...@googlegroups.com

Hmm I'm getting the following errors at the moment, so it looks like
some of the Maven repos are down (right)?

Cheers,
Erik


[erik@dixie:/tmp/sbt-idea ]$./sbt publish-local
Getting Scala 2.7.7 ...
:: retrieving :: org.scala-tools.sbt#boot-scala
confs: [default]
2 artifacts copied, 0 already retrieved (9911kB/142ms)
Getting org.scala-tools.sbt sbt_2.7.7 0.7.4 ...
:: retrieving :: org.scala-tools.sbt#boot-app
confs: [default]
15 artifacts copied, 0 already retrieved (4096kB/99ms)
[info] Recompiling plugin definition...
[info] Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info]
[info] Updating plugins...
[error] Server access Error: Connection timed out
url=http://tristanhunt.com:8081/content/groups/public/org/scala-tools/sbt/process/0.1/process-0.1.pom
[error] Server access Error: Connection timed out
url=http://tristanhunt.com:8081/content/groups/public/org/scala-tools/sbt/process/0.1/process-0.1.jar
[error] Server access Error: Connection timed out
url=http://www2.ph.ed.ac.uk/maven2/org/scala-tools/sbt/process/0.1/process-0.1.jar

ijuma

unread,
Jun 7, 2011, 11:45:02 AM6/7/11
to simple-b...@googlegroups.com, er...@shinsetsu.nl
That message seems to indicate that you're using SBT 0.7.x. Are you sure you're using SBT 0.10.0?

Ismael

Erik Post

unread,
Jun 7, 2011, 11:59:01 AM6/7/11
to simple-b...@googlegroups.com

No, I was using the one provided in your git repo. When I use 0.10.0
it wants to pull in 0.7.4. I'm guessing this is due to
project/build.properties containing sbt.version=0.7.4? I don't see any
build.sbt file for 0.10.0 either so I'm a bit lost as to what's going
on here I'm afraid...

Cheers,
Erik

--------

[erik@dixie:/tmp/x/sbt-idea ]$ java -Xmx512M -jar /opt/sbt/sbt-launch-0.10.0.jar
Getting org.scala-tools.sbt sbt_2.8.1 0.7.4 ...

:: problems summary ::
:::: WARNINGS
module not found: org.scala-tools.sbt#sbt_2.8.1;0.7.4

==== local: tried

/home/erik/.ivy2/local/org.scala-tools.sbt/sbt_2.8.1/0.7.4/ivys/ivy.xml

-- artifact org.scala-tools.sbt#sbt_2.8.1;0.7.4!sbt_2.8.1.jar:

/home/erik/.ivy2/local/org.scala-tools.sbt/sbt_2.8.1/0.7.4/jars/sbt_2.8.1.jar

==== Maven2 Local: tried

file:///home/erik/.m2/repository/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.pom

-- artifact org.scala-tools.sbt#sbt_2.8.1;0.7.4!sbt_2.8.1.jar:

file:///home/erik/.m2/repository/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.jar

==== typesafe-ivy-releases: tried

http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.8.1/0.7.4/ivys/ivy.xml

-- artifact org.scala-tools.sbt#sbt_2.8.1;0.7.4!sbt_2.8.1.jar:

http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.8.1/0.7.4/jars/sbt_2.8.1.jar

==== Maven Central: tried

http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.pom

-- artifact org.scala-tools.sbt#sbt_2.8.1;0.7.4!sbt_2.8.1.jar:

http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.jar

==== Scala-Tools Maven2 Repository: tried

http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.pom

-- artifact org.scala-tools.sbt#sbt_2.8.1;0.7.4!sbt_2.8.1.jar:

http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.jar

==== Scala-Tools Maven2 Snapshots Repository: tried

http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.pom

-- artifact org.scala-tools.sbt#sbt_2.8.1;0.7.4!sbt_2.8.1.jar:

http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.8.1/0.7.4/sbt_2.8.1-0.7.4.jar

::::::::::::::::::::::::::::::::::::::::::::::

:: UNRESOLVED DEPENDENCIES ::

::::::::::::::::::::::::::::::::::::::::::::::

:: org.scala-tools.sbt#sbt_2.8.1;0.7.4: not found

::::::::::::::::::::::::::::::::::::::::::::::

:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-tools.sbt#sbt_2.8.1;0.7.4: not found
Error during sbt execution: Error retrieving required libraries
(see /tmp/x/sbt-idea/project/boot/update.log for complete log)
Error: Could not retrieve sbt 0.7.4

ijuma

unread,
Jun 7, 2011, 12:03:39 PM6/7/11
to simple-b...@googlegroups.com
On Tuesday, 7 June 2011 16:59:01 UTC+1, Erik Post wrote:

No, I was using the one provided in your git repo.

You're in the wrong branch. Probably because there was a mistake in Graham's instructions:

> git checkout sbt-0.10 

This should be git checkout -t origin/sbt-0.10 (as there is no local branch named sbt-0.10 at that point).

Best,
Ismael

Stuart Roebuck

unread,
Jun 7, 2011, 12:41:27 PM6/7/11
to simple-b...@googlegroups.com
It would be great if a short summary of these instructions could be added as a readme.md to https://github.com/ijuma/sbt-idea/tree/sbt-0.10.

The easiest summary of commands I've found so far would be:

     cd sbt-idea
     git checkout sbt-0.10
     ./sbt publish-local

Then create a file: ~/.sbt/plugins/build.sbt like this:

    libraryDependencies ++= Seq (
        "org.sbtidea" %% "xsbt-idea" % "0.1"
    )

That should be everything ready.

Just go into an existing sbt 0.10 project and enter the command
    gen-idea

ijuma

unread,
Jun 7, 2011, 1:53:45 PM6/7/11
to simple-b...@googlegroups.com
On Tuesday, 7 June 2011 17:03:39 UTC+1, ijuma wrote:
You're in the wrong branch. Probably because there was a mistake in Graham's instructions:

> git checkout sbt-0.10 

This should be git checkout -t origin/sbt-0.10 (as there is no local branch named sbt-0.10 at that point).

Actually Graham's instructions work with a recent Git. But I think this was added not too long ago. And you were definitely in the wrong branch given the output you pasted.

Best,
Ismael

Mark Harrah

unread,
Jun 7, 2011, 9:48:49 PM6/7/11
to simple-b...@googlegroups.com
On Mon, 6 Jun 2011 16:54:29 -0700 (PDT)
ijuma <ism...@juma.me.uk> wrote:

> Hey Mark,
>
> I've managed to get transitive dependencies to work by matching the
> Artifacts in the ModuleID and the Files returned
> by externalDependencyClasspath. One thing I noticed is that the same
> dependency would appear in many ConfigurationReports. Because
> externalDependencyClasspath doesn't include the configuration for each of
> the dependencies, I had to manually selecting the configuration with the
> highest priority (e.g. if a dependency appeared in "compile" configuration,
> I'd ignore all the other ones and so on). This matters because one can
> specify 4 scopes in the IDEA configuration ("compile", "runtime", "test",
> "provided"). By the way, the scala-compiler.jar did indeed appear with this
> fix.
>
> In relation to sbt-update-classifiers, the result
> of EvaluateTask.evaluateTask(buildStruct, Keys.updateSbtClassifiers, state,
> projectRef, false, EvaluateTask.SystemProcessors) is:
>
> Some(Inc(Incomplete(node=Some(ScopedKey(Scope(Select(ProjectRef(file:/media/internal0/home/ijuma/idea-workspace/foo/,common)),Global,Global,Global),update-sbt-classifiers)),
> tpe=init$default$2, msg=None, causes=List(),
> directCause=Some(sbt.ResolveException: unresolved dependency:
> org.scala-tools.sbt#sbt_2.9.0-1;0.10.0: not found))))

That is probably a bug in update-sbt-classifiers. It probably needs to fix the scala version used for sbt's cross version.

Yeah, that's a bit unreasonable and merits a bug report. I don't have any immediate solutions, so it might not get addressed right away.

-Mark

Mark Harrah

unread,
Jun 7, 2011, 10:04:53 PM6/7/11
to simple-b...@googlegroups.com

You should also be able to create a ~/.sbt/plugins/project/Build.scala that contains an external project dependency. Something like:

lazy val root = Project("root", file(".")) dependsOn( uri("https://github.com/ijuma/sbt-idea.git"))

(with the usual additional structure). If you specify the commit or a tag as the fragment of the URI, you can use it to update to a new commit as well.

(I didn't try this out, so hopefully I'm not making this feature up.)

-Mark

ijuma

unread,
Jun 8, 2011, 4:11:54 AM6/8/11
to simple-b...@googlegroups.com
On Wednesday, 8 June 2011 02:48:49 UTC+1, Mark Harrah wrote:

That is probably a bug in update-sbt-classifiers.  It probably needs to fix the scala version used for sbt's cross version.

Yeah, that's a bit unreasonable and merits a bug report.  I don't have any immediate solutions, so it might not get addressed right away.


This makes update-classifiers much slower than withSources and I initially thought that it was a regression over SBT 0.7.x. However, it turns out that withSources still works and I've reinstanted that in my build file (along with a blacklist of modules that don't have sources in the repository).

So that will do for now as the source gets found via sbt-idea for dependencies that have withSources (the gen-idea command doesn't run update-classifiers by default, only if the 'with-classifiers' argument is passed to it). One thing I noticed is that withSources causes the source jars to be downloaded to lib_managed/src while update-classifiers causes them to be downloaded to lib_managed/jar (with retrieveManaged := true). Is this intentional? It's a minor issue as it all still works, but seems like unnecessary duplication and inconsistency.

Best,
Ismael

ijuma

unread,
Jun 8, 2011, 4:13:19 AM6/8/11
to simple-b...@googlegroups.com
On Tuesday, 7 June 2011 17:41:27 UTC+1, Stuart Roebuck wrote:
It would be great if a short summary of these instructions could be added as a readme.md to https://github.com/ijuma/sbt-idea/tree/sbt-0.10.

If you send me a pull request, I'll merge it. It would be nice to test if Mark's suggestion works and use that instead.

Best,
Ismael

Graham Tackley

unread,
Jun 8, 2011, 9:24:41 AM6/8/11
to simple-b...@googlegroups.com
On Wednesday, 8 June 2011 03:04:53 UTC+1, Mark Harrah wrote:

You should also be able to create a ~/.sbt/plugins/project/Build.scala that contains an external project dependency.  Something like:

  lazy val root = Project("root", file(".")) dependsOn( uri("https://github.com/ijuma/sbt-idea.git"))

(with the usual additional structure).  If you specify the commit or a tag as the fragment of the URI, you can use it to update to a new commit as well.

(I didn't try this out, so hopefully I'm not making this feature up.)


You're not :) The full ~/.sbt/plugins/project/Build.scala that works for me is:

import sbt._

object MyPlugins extends Build {
  lazy val root = Project("root", file(".")) dependsOn (uri("git://github.com/ijuma/sbt-idea.git#sbt-0.10"))
}

("https:" uri didn't work for me, had to change it to "git:")

This is very awesome.

Will sbt ever do a pull/fetch on this git url, or do I have to delete the .sbt/staging directory to force an update?

g


 

Mark Harrah

unread,
Jun 9, 2011, 8:08:26 AM6/9/11
to simple-b...@googlegroups.com
On Wed, 8 Jun 2011 06:24:41 -0700 (PDT)
Graham Tackley <gra...@tackley.net> wrote:

> On Wednesday, 8 June 2011 03:04:53 UTC+1, Mark Harrah wrote:
> >
> > You should also be able to create a ~/.sbt/plugins/project/Build.scala that
> > contains an external project dependency. Something like:
> >
> > lazy val root = Project("root", file(".")) dependsOn( uri("
> > https://github.com/ijuma/sbt-idea.git"))
> >
> > (with the usual additional structure). If you specify the commit or a tag
> > as the fragment of the URI, you can use it to update to a new commit as
> > well.
> >
> > (I didn't try this out, so hopefully I'm not making this feature up.)
> >
> >
> > You're not :) The full ~/.sbt/plugins/project/Build.scala that works for me
> is:

Ok, that's good.

> import sbt._
>
> object MyPlugins extends Build {
> lazy val root = Project("root", file(".")) dependsOn
> (uri("git://github.com/ijuma/sbt-idea.git#sbt-0.10"))
> }
>
> ("https:" uri didn't work for me, had to change it to "git:")
>
> This is very awesome.
>
> Will sbt ever do a pull/fetch on this git url, or do I have to delete the
> .sbt/staging directory to force an update?

It does not currently. You don't have do delete it, but you do have to change to the directory and do a 'git pull'. I don't think it would be too hard to write a command to auto-update all external projects.

-Mark

ijuma

unread,
Jun 9, 2011, 9:02:47 PM6/9/11
to simple-b...@googlegroups.com
On Wednesday, 8 June 2011 14:24:41 UTC+1, Graham Tackley wrote:
You're not :) The full ~/.sbt/plugins/project/Build.scala that works for me is:

import sbt._

object MyPlugins extends Build {
  lazy val root = Project("root", file(".")) dependsOn (uri("git://github.com/ijuma/sbt-idea.git#sbt-0.10"))
}

Great, I added that to the README and also fixed an issue where project dependencies weren't exported in IDEA. That meant that if you relied on transitive project dependencies, you could end up with a NoClassDefError when running/debugging tests or objects from within IDEA.

I should mention that Mikko Peltonen pulled from my branch recently:


Once he pulls the latest commits, I'll update SBT's wiki to refer to his branch only and remove the existing 3 plugins that are mentioned. Does anyone have any objections?

Best,
Ismael 

Stuart Roebuck

unread,
Jun 10, 2011, 4:57:37 AM6/10/11
to simple-b...@googlegroups.com
That all sounds great.  Thank you!

Stuart Roebuck

unread,
Jun 10, 2011, 5:01:37 AM6/10/11
to simple-b...@googlegroups.com
Mark,

How would you apply this pattern to installing multiple plugins from git sources?

Stuart

greekscala

unread,
Jun 10, 2011, 8:12:25 AM6/10/11
to simple-build-tool
I tried out the sbt-idea instructions for 0.10.
I setup a ~/.sbt/plugins/project/Build.scala and after starting sbt
in my
project dir, it downloads the git repo. But I get an error that a
dependecy is not found:
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn] http://scala-tools.org/repo-releases/org/scala-tools/sbt/testing_2.8.1/0.10.0/testing_2.8.1-0.10.0.pom
[warn] -- artifact org.scala-tools.sbt#testing_2.8.1;0.10.0!
testing_2.8.1.jar:
[warn] http://scala-tools.org/repo-releases/org/scala-tools/sbt/testing_2.8.1/0.10.0/testing_2.8.1-0.10.0.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-tools.sbt#testing_2.8.1;0.10.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::

This jar does not exist. Do I have to provide some other repository?

best regards

Stephen Wells

unread,
Jun 10, 2011, 9:19:48 AM6/10/11
to simple-b...@googlegroups.com
Stuart,

The dependsOn method can take any number of arguments, just comma separate them.

for example:

import sbt._

object MyPlugins extends Build {
  lazy val root = Project("root", file(".")) dependsOn(
  )
}

    Stephen Wells

--
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/-/-a6sNNfikvkJ.

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.

Stuart Roebuck

unread,
Jun 10, 2011, 9:37:32 AM6/10/11
to simple-b...@googlegroups.com
Stephen,

That's really simple.

Many thanks.

Erik Post

unread,
Jun 10, 2011, 9:47:48 AM6/10/11
to simple-b...@googlegroups.com
Hi, 

I just wanted to let you guys know I got it all working like a charm thanks to all your help, so thanks!!

Cheers,
Erik

greekscala

unread,
Jun 10, 2011, 12:56:46 PM6/10/11
to simple-build-tool
Hello Erik,

can you provide a little summary of what you did?
That would be helpfull.

best regards

Stuart Roebuck

unread,
Jun 10, 2011, 1:03:43 PM6/10/11
to simple-b...@googlegroups.com
Ismael,

It looks like there may be an issue if the user has set the `sbt.boot.directory` to a shared directory location as the resulting IDEA configuration is still looking for Scala in the default location: project/boot/….

Stuart.

Erik Post

unread,
Jun 10, 2011, 4:54:27 PM6/10/11
to simple-b...@googlegroups.com
Hi,

I was referring to Stuart's instructions on manually checking out and building the sbt-0.10.0 branch. I'm struggling a bit with google groups atm, and I see I failed to quote the posts I was referring to, so here are the instructions again:

> The easiest summary of commands I've found so far would be:
>
>      cd sbt-idea
>      git checkout sbt-0.10
>      ./sbt publish-local
>
> Then create a file: ~/.sbt/plugins/build.sbt like this:
>
>     libraryDependencies ++= Seq (
>         "org.sbtidea" %% "xsbt-idea" % "0.1"
>     )
>
> Just go into an existing sbt 0.10 project and enter the command
>     gen-idea

Cheers,
Erik


Op vrijdag 10 juni 2011 18:56:46 UTC+2 schreef greekscala het volgende:
Hello Erik,

can you provide a little summary of what you did?
That would be helpfull.

best regards

Stuart Roebuck

unread,
Jun 10, 2011, 5:06:11 PM6/10/11
to simple-b...@googlegroups.com
greekscala,

Please note that Ismael's later post provides an even easier method and it is now documented on his clone of the sbt-idea plugin here:

Best,

Stuart.

Mark Harrah

unread,
Jun 10, 2011, 9:40:18 PM6/10/11
to simple-b...@googlegroups.com

> project/boot/�.

I don't know the details of sbt-idea, but from a quick look, it doesn't appear to hardcode project/boot. If you change anything about your build configuration, including sbt.boot.directory, you have to rerun gen-idea.

-Mark

santi

unread,
Jun 13, 2011, 3:57:37 AM6/13/11
to simple-build-tool
Is there any simple way to automatically add the unmanaged library
jars (for example, those in the libs dir) to the generated project
files?

Thanks,
Santi

On Jun 6, 8:39 am, ijuma <ism...@juma.me.uk> wrote:
> Hey all,
>
> I've made a few improvements (including a critical fix) to Scott Royston's
> port of sbt-idea and it works pretty well now. You can find the pull request
> here:
>
> https://github.com/scroyston/sbt-idea/pull/1
>
> And my branch here:
>
> https://github.com/ijuma/sbt-idea/commits/sbt-0.10
>
> There are two things that still don't work:
>
> 1. The source for the Scala library doesn't get associated with the library
> (the source for other libraries does get associated though).
> 2. If the scala-compiler is a classpath dependency, it doesn't get added as
> an IDEA dependency.
>
> Regarding 1, I am probably doing something wrong. I used a similar approach
> to the one used for normal libraries, but with UpdateSbtClassifiers:
>
> https://github.com/ijuma/sbt-idea/blob/sbt-0.10/src/main/scala/org/sb...
>
> By the way, it seems like update classifiers and update sbt classifiers are
> quite naive at the moment. In a multi-module build, they try to download the
> same dependency source or javadoc jar multiple times if many modules depend
> on then. It would be much faster if they remembered failures. Is it worth
> filing an enhancement request for this?
>
> Regarding 2, it's a bit odd, I thought that it would work similarly to the
> scala-library, but I need to investigate a bit more what's going on. If you
> have any advice, that would be appreciated, of course.
>
> Best,
> Ismael

Stuart Roebuck

unread,
Jun 13, 2011, 9:30:55 AM6/13/11
to simple-b...@googlegroups.com
I was having a problem that I thought might be associated with sharing a "sbt.boot.directory" but seems to be to do with depending on another project like this:

object MyBuild extends Build {
    lazy val myWebApp = Project("my-web-app", file(".")) dependsOn(myWebLibrary)
    lazy val myWebLibrary = RootProject(file("../my-web-library"))
}

If I do this then the library "my-web-library" doesn't get included in the dependencies that are exported to IDEA.

I'm not sure if there could be an ivy component to this issue as if I then revert to removing this "dependsOn" and locally publishing the other project and explicitly adding it as a library dependency for the first, the problem persists until I cleared the local ivy cache and publish-local again.

Stuart.

ijuma

unread,
Jun 19, 2011, 4:27:01 PM6/19/11
to simple-b...@googlegroups.com
Stuart,

Please file an issue here and mention that it's related to the sbt-0.10 branch:


Then one of the people that contribute to the project will look at it.

Best,
Ismael

ijuma

unread,
Jun 19, 2011, 4:27:50 PM6/19/11
to simple-b...@googlegroups.com
On Monday, 13 June 2011 08:57:37 UTC+1, santi wrote:
Is there any simple way to automatically add the unmanaged library
jars (for example, those in the libs dir) to the generated project
files?

Looks like this is not done yet:


I'll probably need this at some point and will look into it if no-one else beats me to it.

Best,
Ismael

Stuart Roebuck

unread,
Jun 19, 2011, 5:05:49 PM6/19/11
to simple-b...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages