3

If I want to include a plugin for sbt I use addSbtPlugin() in plugins.sbt. So to add the gen-idea plugin I would use the following line:

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.0")

Alas, I've to explicitly specify the version 1.5.0. What if I want to use the latest available version when it becomes available?

When I omit the third parameter I'm getting the following error:

C:\Users\JDearing\Documents\deleteme\LearningScala>sbt gen-idea
C:\Users\JDearing\.sbt\0.13\plugins\build.sbt:1: error: type mismatch;
 found   : sbt.impl.GroupArtifactID
 required: sbt.ModuleID
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" )
                                ^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q

Is it possible to avoid specifying the version in addSbtPlugin()?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Justin Dearing
  • 14,270
  • 22
  • 88
  • 161

2 Answers2

3

sbt plugin is just another library for your build https://github.com/sbt/sbt/blob/0.13/main/src/main/scala/sbt/Defaults.scala#L1513

And for a library you have Ivy resolution rules

Ivy revisions
The revision in groupID % artifactID % revision does not have to be a single fixed version. Ivy can select the latest revision of a module according to constraints you specify. Instead of a fixed revision like "1.6.1", you specify "latest.integration", "2.9.+", or "[1.0,)". See the Ivy revisions documentation for details.

from http://www.scala-sbt.org/release/docs/Getting-Started/Library-Dependencies.html#ivy-revisions

Eugene Platonov
  • 3,145
  • 3
  • 26
  • 20
2

tl;dr No. There's no way to leave the version off. It's part of sbt.ModuleID.

You can however use latest.integration or latest.milestone to avoid specifying the version explicitly. Ivy and hence SBT will take care of "selecting the latest version being either a milestone or a release".

You may also consult my answer to a similar question about the sbt-idea plugin.

Community
  • 1
  • 1
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420