How to define a custom sbt setting in project/{...}.scala? -


using sbt 1.0.1 , scala 2.12.3...

my directory structure:

project/build.properties project/packagedist.scala src/main/scala/{$packagedirs}/myclass.scala build.sbt 

in project/packagedist.scala , i've got:

import sbt._ import keys._ import io.richfile._  import java.io.file  object packagedist {   lazy val distartifactroot = settingkey[file]("the directory distribution artifacts written")   lazy val distdirectoryname = settingkey[string]("the name of root diectory distribution")    def distartifactrootfile : setting[file] =      distartifactroot := target.value / "dist"   def distdirectory : setting[string] =     distdirectoryname := s"${normalizedname.value}-${version.value}" } 

in build.sbt , i've got:

lazy val commonsettings = seq(   organization := "mytestorg",   scalaversion := "2.12.3",   version := "0.1.0-snapshot" )  lazy val root = ( project in file(".") )   .settings(     name := "package-test",     commonsettings   ) 

when run sbt , distartifactroot , distdirectoryname settings not available when run > settings -v.

what doing wrong?

you need make settings visible other sbt files:

object packagedist {   lazy val distartifactroot = settingkey[file](     "the directory distribution artifacts written")   lazy val distdirectoryname =     settingkey[string]("the name of root diectory distribution")    val settings = seq(     distartifactroot := target.value / "dist",     distdirectoryname := s"${normalizedname.value}-${version.value}"   ) } 

then use them in project like

lazy val root = ( project in file(".") )   .settings(packagedist.settings: _*) // <-- add settings project   .settings(     name := "package-test",   ) 

reloading sbt , typing dist + make autocomplete suggest 2 settings added.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -