I am writing a plugin that requires a specific setting: configUrl
If I specify that setting in my build.conf
it would look like this:
If the setting has a default value, that default should be set in the plugin. If it does not, the type should probably be Option[...]
with a default of None
. Typically, a build should not require a parameter to be passed from the command line just to be loaded.
Finally, if it is primarily the set
syntax you dislike, you can use system properties and read the system property from your setting. However, this is restricted to Strings and so you lose type safety.
System properties can be set by -Dkey=value
on the command line (either directly or in your startup script):
sbt -Dconfig.url=http://...
(quoting as needed by your shell). To pull this value into the setting:
MyPlugin.configUrl :=
url(System.getProperty("config.url", "<default>"))
where "<default>"
is the value to use if the system property is not set. If you take the Option
approach,
MyPlugin.configUrl :=
for(u <- Option(System.getProperty("config.url"))) yield
url(u)