Search code examples
sbtsbt-pluginsbteclipse

sbteclipse: create build.sbt and plugins.sbt


I have downloaded sbt and to resolve the proxy maven repository errors, I have created repositories files with my-maven-proxy-releases: under ~/.sbt

When I do a sbt about, I get the below details:

"~\.sbt\preloaded\org.scala-sbt\sbt\"1.0.4"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[warn] No sbt.version set in project/build.properties, base directory: C:\
[info] Set current project to root (in build file:/C:/)
[info] This is sbt 1.0.4
[info] The current project is {file:/C:/}root 0.1-SNAPSHOT
[info] The current project is built against Scala 2.12.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.12.4   

Now, I wanted to import a project in eclipse and I googled. This is the details I found.

1. ~/.sbt/<sbt-version>/plugins/plugins.sbt
   addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
  sbteclipse 

2. ~/.sbt/<sbt-version>/plugins/build.sbt
   for scala versions and dependencies.

But I am confused on where to create the build.sbt and plugins.sbt as my folder structure is like this:

~/.sbt/1.0
~/.sbt/1.3

and I do not see ~/.sbt/1.0.4 which is displayed in sbt about.

Please guide if my understanding wrong.


Solution

  • First, you need to understand sbt project structure and the difference between project-local and global plugins.

    As you would usually use eclipse plugin globally you should put it in

    ~/.sbt/<sbt-version>/plugins/plugins.sbt
    

    (as you wrote correctly), where <sbt-version> is

    • 0.13 for any sbt 0.13.*
    • 1.0 for any sbt 1.*.* (this may seem unintuitive, but it's okay)

    I guess, ~/.sbt/1.3 is just a typo and is meant to be ~/.sbt/0.13.

    Also you normally don't put anything in ~/.sbt/<sbt-version>/plugins/build.sbt. If you need to have some global settings (including those for the global plugins), you should put them in

    ~/.sbt/<sbt-version>/global.sbt
    

    Read about global settings here.


    With non-global plugins and settings it's all the same minus the ~/.sbt/<sbt-version>/ part:

    • use <your-project>/plugins/plugins.sbt for plugins
    • and <your-project>/build.sbt for project settings