These are chat archives for sbt/sbt

16th
Nov 2016
Hendi Santika
@hendisantika
Nov 16 2016 02:28
Hi All,
I want to ask when SBT final Version to be 1.0 ?
Hehehee
Petro Verkhogliad
@vpetro
Nov 16 2016 03:30
@vvlevykin what is the command that that you're using?
Jules Ivanic
@guizmaii
Nov 16 2016 08:52
@hendisantika it will be available when it will be ready IMHO ;)
Hendi Santika
@hendisantika
Nov 16 2016 09:25
I've been waiting for so long. Hiks... Hiks... Hiks...
Michal Bigos
@teliatko
Nov 16 2016 09:42
Hi all,
how can I enable configuration in plugin conditionally.
Let’s say I have 2 configurations Xy and XyIt. I want to enable XyIt in plugin only when IntergrationTest is enabled. I need to construct override def projectConfigurations = Seq(Xy, XyIt) but only put XyIt conditionaly. How can ask if IntegrationTest is enabled?
r457r2
@r457r2
Nov 16 2016 09:49
if (IntegrationTest.value == true) {} ?
Michal Bigos
@teliatko
Nov 16 2016 10:05
@r457r2 it doesn’t work (even compile) :worried:
RomanIakovlev
@RomanIakovlev
Nov 16 2016 10:59
@teliatko what do you mean by “only when IntegrationTest is enabled”? You enable integration tests by adding configuration to the project.
Or do you have some custom setting in your plugin for that?
Michal Bigos
@teliatko
Nov 16 2016 11:04
I want to enable specific configuration in my plugin when IntegrationTest configuration is enabled in project. E.g when you use my plugin and say in your project .configs(IntegrationTest) specific configuration from plug-in (from above XyIt) will be enabled too. If you do not have IntegrationIt in your project, only basic configuration will be enabled (from above Xy).
Is it clear? Does anybody know if this is possible?
RomanIakovlev
@RomanIakovlev
Nov 16 2016 11:05
Oh I see
I don’t know if it’s possible to test if a certain configuration is enabled or not. But I think you can just provide a setting and let users enable it if they want your config.
Michal Bigos
@teliatko
Nov 16 2016 12:30
@RomanIakovlev not sure I understand
You still have to enable .configs(…), isn’t it?
RomanIakovlev
@RomanIakovlev
Nov 16 2016 12:53
No, sorry, my idea won’t work, because you can only access setting value in a := or similar macros.
Now when I think about it, it seems that this won’t work in general, because when the plugins are loaded, projects are not fully resolved yet, and SBT probably can’t say anything about which configs are enabled for them.
Michal Bigos
@teliatko
Nov 16 2016 13:00
@RomanIakovlev That’s what I was thinging about too, but by SBT nobody never ever knows. It’s systematic magic all the way down, thus I hoped and wanted a confirmation for that :smile:
RomanIakovlev
@RomanIakovlev
Nov 16 2016 13:04
@dwijnand Right till this moment I hoped SBT’s not magic at least for you… :)
Dale Wijnand
@dwijnand
Nov 16 2016 13:05
Depends what you mean by magic :) To me large, large parts of sbt I've simply not learnt how it works yet.
RomanIakovlev
@RomanIakovlev
Nov 16 2016 13:06
By magic I mean a sufficiently sophisticated technology :)
Sophisticated to an extent when one doesn’t want to touch it. :)
Dale Wijnand
@dwijnand
Nov 16 2016 13:07
Then lots of things are magic. sbt is magic, scalac is magic, scala-library is magic, javac is magic, the JVM is magic..
Michal Bigos
@teliatko
Nov 16 2016 13:08
I mean white magic :smile: and I’m on same page. It’s magic until I don’t know how it works, hence need to learn.
Yes all those are magical in some sense.
Michal Bigos
@teliatko
Nov 16 2016 13:16
Btw. is IntegrationTest extensible configuration? I mean, can one write:lazy val XyIt = config(“xy-it") extend IntegrationTest? It seems to be woirking in some strange way. When I define: lazy val xyItSettings = inConfig(XyIt)( Defaults.itSettings ) I do not have xy-it:test task at all, even when Defaults.itSettings is defined as inConfig(IntegrationTest)(testSettings) and testSettings = configSettings ++ testTasks. Even xy-it:compile is undefined. Is it how it should work?
Vasiliy Levykin
@vvlevykin
Nov 16 2016 13:22
:point_up: November 16, 2016 6:30 AM
@vpetro I run sbt new codio/codio-scala-service.g8 which is a private github repo.
RomanIakovlev
@RomanIakovlev
Nov 16 2016 13:34
@teliatko I think you need to add Defaults.itSettings into your project settings directly, not under some configuration.
So if you do it via an auto-plugin, it will be something like override def projectSettings: Seq[Def.Setting[_]] = Defaults.itSettings
Michal Bigos
@teliatko
Nov 16 2016 13:39
@RomanIakovlev Why I need to add the settings directly? They are scoped, and I want to scope mine for my XyIt configuration.
RomanIakovlev
@RomanIakovlev
Nov 16 2016 13:42
I mean, itSettings are defined like this: lazy val itSettings: Seq[Setting[_]] = inConfig(IntegrationTest)(testSettings), i.e. just add the standard testSettings under IntegrationTest config. So if you scope them even further under your XyIt config, it’s probably not going to work.
But maybe I misunderstand your intention, sorry if so.
Michal Bigos
@teliatko
Nov 16 2016 13:47
Ah I hopefully understand you now. Thus I should add Defaults.testSettings as lazy val xyItSettings = inConfig(XyIt)( Defaults.testSettings ). They are defined only as lazy val testSettings: Seq[Setting[_]] = configSettings ++ testTasks withoput any scoping. Am I right?
RomanIakovlev
@RomanIakovlev
Nov 16 2016 13:47
Yep, I think that should work
Michal Bigos
@teliatko
Nov 16 2016 14:24
@RomanIakovlev thanks I will investigate in th evening
Sam Smoot
@sam
Nov 16 2016 15:50
Hi. I’m trying to duplicate the Play run task, and set javaOptions := “-Dconfig.resource=alternative.config” in my copy. The goal is to have a task that runs the project with an alternative config file (two deployments run from the same code-base with minor config file differences).
I know I could set the option when starting sbt. I just wanted to wrap it up in a task so I could run run or runOtherSite depending on what I’m working on at the moment.
Any tips?
Derek Wickern
@dwickern
Nov 16 2016 18:31
what's the best way to have some different config in development vs production?
i would like to also have some compile-time switches to remove some code in production
Sam Smoot
@sam
Nov 16 2016 18:32
@dwickern In production I’m generally using an assembly (if spray/akka-http) or a dist.zip (if Play) with a start script. So I’d just specify -Dconfig.resource=production.conf when starting.
Which typesafe-config will then pick up and use where ConfigFactory.load() is called (which both projects do for you under the covers).
Derek Wickern
@dwickern
Nov 16 2016 18:34
right, i could do something like sbt -Denvironment=production build
i guess i could use a source generator to stick a boolean into my code, and set it true in production
Sam Smoot
@sam
Nov 16 2016 18:37
@dwickern For the compile-time switches I think it depends on what you want to do. If you want to filter mappings for example, that can be done during packaging. If you want to re-write code (like remove any line matching /\s*log.debug(.*$/) then I think you might need to write an sbt plugin (or macro).
@dwickern spray-json for example uses sbt-boilerplate for code generation (see projects/plugins.sbt and src/main/boilerplate): https://github.com/spray/spray-json
(which demonstrates the sbt plugin approach)
So you could have a plugin that exports a scope for your production build. So you’d have production:compile, production:run, etc.
Derek Wickern
@dwickern
Nov 16 2016 18:44
let's say i write two source-compatible versions of an object, and i want to include a specific one in production
would i use the mappings for that?
Sam Smoot
@sam
Nov 16 2016 18:46
@dwickern That definitely seems easiest yeah. I generally use mappings to filter out a private.conf file (that’s included by application.conf) from packaging for example. But I feel like I’ve seen examples for filtering build files/folders during compilation.
Derek Wickern
@dwickern
Nov 16 2016 18:47
i suppose i could use resources instead of sources if it's easier
Derek Wickern
@dwickern
Nov 16 2016 19:22
does anyone else get these errors like build.sbt:54: error: value value is not a member of sbt.SettingKey?
i've seen it on multiple versions of SBT, multiple machines, multiple OS's
blowing up target/ and reloading the project always fixes it
Owen Healy
@ellbur
Nov 16 2016 21:05
with this new .value way of defining settings, what's the right way to branch?
With <<= we could do a <<= if (x) b else c and a would end up depending on only one of b or c... how do you get that behavior with .value?