These are chat archives for sbt/sbt

22nd
Jun 2017
Brian Topping
@briantopping
Jun 22 00:00
hmm, I suppose I should explore, thanks
scalasolist
@scalasolist
Jun 22 00:00
unmanaged* - is what you fill with your file manager. And managed* is what you generate with a code
Brian Topping
@briantopping
Jun 22 00:01
gotcha ok
Sam Halliday
@fommil
Jun 22 00:11
@scalasolist I bet you're using a hand rolled sbt script instead of the official one, aren't you?
That doc page with the 2 line sbt launcher should be taken out the back and put out of its misery.
scalasolist
@scalasolist
Jun 22 00:20
I use official one. But hadn't updated it since 2013. Now as you pointed, I believe it is too old
but nevertheless -J-X works fine
ykycxzsv
@ykycxzsv
Jun 22 11:16
at the sbt prompt, i can type "project/task" to run a task in a specific project. "project/command" doesn't work however. how can i run a command in a specific project?
Sam Halliday
@fommil
Jun 22 11:17
project <name>
then the command
Commands suck
ykycxzsv
@ykycxzsv
Jun 22 11:29
there's no way to do it without changing the current project?
Dale Wijnand
@dwijnand
Jun 22 12:12
no, but here's the feature request for it sbt/sbt#2900
ykycxzsv
@ykycxzsv
Jun 22 12:16
ok. i think i'll try to convert it to a task, but problem is the implementation has to call other existing commands. i understand that i can read state.value and pass to the command's state parameter, but i should also update state based on result of the command. i tried state := command(state.value), but now the task doesn't do anything!
Dale Wijnand
@dwijnand
Jun 22 12:18
yeah you can't call commands from tasks
as a workaround to that feature missing you could take the project name as a first argument
ykycxzsv
@ykycxzsv
Jun 22 12:21
i don't need the project name, i need to fit in a framework which attempts to do "sbt project/mycommand". since commands don't support that syntax, i have to use a task, but since tasks can't call commands, i'm screwed. guess it's time for some ugly kludge
Sam Halliday
@fommil
Jun 22 12:41
if it's your command, you could take the project name as an input
but then you'd want to rewrite your Command as a Task anyway...
ykycxzsv
@ykycxzsv
Jun 22 13:13
like i said, i DON'T need the project name. and i can't rewrite my command to a task if a task can't call other commands
Dale Wijnand
@dwijnand
Jun 22 13:17
You need to run the command in a specific project, though, right?
Michael Pollmeier
@mpollmeier
Jun 22 15:11

How can I refer to a scoped key programmatically? I.e. what is the programmatic equivalent of e.g. scalafmt::test?

Context: neo-sbt-scalafmt defines a TaskKey scalafmt that formats your sources, but it also defines a scope called test (https://github.com/lucidsoftware/neo-sbt-scalafmt/blob/master/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtCorePlugin.scala#L143) that only checks if the sources are in line with the expected format. Depending on a SettingKey the TaskKey scalaFmt is invoked before compile. I want to introduce a new SettingKey that invokes scalafmt::test instead. The below compiles, but always runs scalafmt, not scalafmt::test.

    if (scalafmtOnCompile.value) scalafmt in resolvedScoped.value.scope
    else if (scalafmtTestOnCompile.value) (test in scalafmt) in resolvedScoped.value.scope

https://github.com/lucidsoftware/neo-sbt-scalafmt/blob/master/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtCorePlugin.scala#L170

Dale Wijnand
@dwijnand
Jun 22 15:15
Try test in (resolvedScoped.value.scope in scalafmt)
which basically means: "take the existing scope, but make it in scalafmt task scope, that's the scope of test that I want to use"
Michael Pollmeier
@mpollmeier
Jun 22 15:25
hmm, that doesn't compile, because scalafmt is a TaskKey, and in takes one of AttributeKey, ConfigKey or Reference. Not sure what those are, will have a look if it's possible to convert a TaskKey into one of them..
Dale Wijnand
@dwijnand
Jun 22 15:29
test in (resolvedScoped.value.scope in scalafmt.key) should compile
Michael Pollmeier
@mpollmeier
Jun 22 15:31
yes, just found that as well. it compiles, but it still acts like scalafmt, not scalafmt::test. Can you have a quick look at this line and tell me if my understanding is correct, that it's a scoped key? This is what I want to refer to:
https://github.com/lucidsoftware/neo-sbt-scalafmt/blob/master/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtCorePlugin.scala#L143
Dale Wijnand
@dwijnand
Jun 22 15:33
so it's defined unscoped, then it passed through inTask, which scopes it
Michael Pollmeier
@mpollmeier
Jun 22 15:38
so, it should work right? for context, here's my commit: mpollmeier/neo-sbt-scalafmt@4a113d7
I'm using that in a project where inspect scalafmtTestOnCompile tells me [info] Setting: Boolean = true
but when I run compile it runs scalafmt, not scalafmt::test
should I open a stackoverflow question instead?
Dale Wijnand
@dwijnand
Jun 22 15:52
just to sanity check: scalafmtOnCompile is false, right?
Michael Pollmeier
@mpollmeier
Jun 22 16:34
Correct
Michael Pollmeier
@mpollmeier
Jun 22 16:39
actually, no! I just inspected the value of scalafmtOnCompile and it was set to true in a different file. sorry!
so, yes, your suggested test in (resolvedScoped.value.scope in scalafmt.key) does the job. thank you!
would you like me to add this to the docs, or create a stackoverflow question with answer?
I'll wrap up a PR for neo-sbt-scalafmt shortly
Dale Wijnand
@dwijnand
Jun 22 21:51
resolvedScoped is a pretty advanced topic. But a stackoverflow question and answer can't hurt, can it.