Search code examples
scalasbtscalariform

sbt-scalariform plugin - can't resolve settings


I wanted to integrate scalariform tool into SBT. Following the https://github.com/sbt/sbt-scalariform/tree/master I created plugins.sbt file with line

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")

then I created scalariform.sbt file with

scalariformSettings

Here I am stuck, when I try to run SBT for my project I am getting

scalariform.sbt:1: error: not found: value scalariformSettings

I also tried

import com.typesafe.sbt.SbtScalariform

SbtScalariform.scalariformSettings

in scalariform.sbt but then I am getting

scalariform.sbt:1: error: object typesafe is not a member of package com
import com.typesafe.sbt.SbtScalariform
           ^
scalariform.sbt:3: error: not found: value SbtScalariform
SbtScalariform.scalariformSettings
^

I saw the thread Sbt can't find SbtScalariform but it suggest changing the version to (1.1.0). Even if this worked (and it does not) I would prefer 1.3.0 version.


Solution

  • Is your plugin file in the correct location? For SBT 0.13.x, I have the following working:

    in build.sbt

    import scalariform.formatter.preferences._
    
    name := "app"
    
    organization := "example"
    
    version := "0.0.0"
    
    libraryDependencies += // ...
    
    scalariformSettings
    
    ScalariformKeys.preferences := ScalariformKeys.preferences.value
      .setPreference(RewriteArrowSymbols, true)
      .setPreference(AlignParameters, true)
      .setPreference(AlignSingleLineCaseStatements, true)
      .setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
      .setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
    

    in project/plugins.sbt:

    addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")