These are chat archives for sbt/sbt

19th
Oct 2016
Miles Sabin
@milessabin
Oct 19 2016 09:42
I'm seeing deprecations for sourceGenerators in Compile <+= (sourceManaged in Compile).map(Boilerplate.gen) ... how does that work in the new .value world?
Julien Richard-Foy
@julienrf
Oct 19 2016 09:43
I would say: sourceGenerators in Compile += (sourceManaged in Compile).map(Boilerplate.gen).value
Miles Sabin
@milessabin
Oct 19 2016 09:43
Also for this,
def runAllIn(config: Configuration) = {
  runAll in config <<= (discoveredMainClasses in config, runner in run, fullClasspath in config, streams) map {
    (classes, runner, cp, s) => classes.foreach(c => runner.run(c, Attributed.data(cp), Seq(), s.log))
  }
}
Julien Richard-Foy
@julienrf
Oct 19 2016 09:43
What’s the type of Boilerplate.gen?
Miles Sabin
@milessabin
Oct 19 2016 09:44
def gen(dir : File): Seq[File]
Julien Richard-Foy
@julienrf
Oct 19 2016 09:47
So, you could even write this: Boilerplate.gen((sourceManaged in Compile).value)
Julien Richard-Foy
@julienrf
Oct 19 2016 09:52

For the second one:

runAll in config := {
  val classes = (discoveredMainClasses in config).value
  val runner = (runner in run).value
  val cp = (fullClasspath in config).value
  val s = streams.value
  classes.foreach(c => runner.run(c, Attributed.data(cp), Seq(), s.log))
}

But I’m not sure of this one, maybe you’ll get an “Illegal dynamic reference” at runtime :(

Miles Sabin
@milessabin
Oct 19 2016 09:53
Both of those get me,
/home/miles/projects/shapeless/build.sbt:138: error: No implicit for Append.Value[Seq[sbt.Task[Seq[java.io.File]]], Seq[java.io.File]] found,
  so Seq[java.io.File] cannot be appended to Seq[sbt.Task[Seq[java.io.File]]]
    sourceGenerators in Compile += (sourceManaged in Compile).map(Boilerplate.gen).value
Julien Richard-Foy
@julienrf
Oct 19 2016 09:58

Ah OK, for the first one I forgot the type of sourceGenerators. So, you should go with the following:

sourceGenerators in Compile += Def.task(Boilerplate.gen((sourceManaged in Compile).value))

Is it better?

What’s the type of runAll?
Miles Sabin
@milessabin
Oct 19 2016 10:05
Unfortunately that still doesn't fix the sourceGenerators,
/home/miles/projects/shapeless/build.sbt:137: error: No implicit for Append.Value[Seq[sbt.Task[Seq[java.io.File]]], sbt.std.FullInstance.M[Seq[java.io.File]]] found,                                                                                                                   
  so sbt.std.FullInstance.M[Seq[java.io.File]] cannot be appended to Seq[sbt.Task[Seq[java.io.File]]]                                       
    sourceGenerators in Compile += Def.task(Boilerplate.gen((sourceManaged in Compile).value))                                              
                                ^                                                                                                           
sbt.compiler.EvalException: Type error in expression
Miles Sabin
@milessabin
Oct 19 2016 10:16
That runAll suggestion looks good :-)
Dale Wijnand
@dwijnand
Oct 19 2016 10:27
@milessabin Julien's last one with .taskValue at the end
Matt Hicks
@darkfrog26
Oct 19 2016 13:59
how do I add a addCommandAlias to a multi-project Build.scala?
nevermind, I just added an "alias.sbt" to deal with it
Matt Hicks
@darkfrog26
Oct 19 2016 14:12
how do I define a command to aggregate?
Matt Hicks
@darkfrog26
Oct 19 2016 14:31
okay, I've switched to a Task but still running into problems. My Task looks like:
lazy val publishAll = publishAllKey := {
  publishTo in Compile := Some(Resolver.sftp(...))
  publish.value
  publishTo in Compile := Some(Resolver.sftp(...))
  publish.value
}
However, when I run it on my multi-project build I get a bunch of (core/*:publishConfiguration) Repository for publishing is not specified.
all I'm trying to do is an aggregated publish that publishes to two machines
Matt Hicks
@darkfrog26
Oct 19 2016 14:43
it's crap like this that really frustrates me about SBT
OlegYch
@OlegYch
Oct 19 2016 15:17
sbt has no global mutable state
Matt Hicks
@darkfrog26
Oct 19 2016 15:18
@OlegYch can you point me in the right direction to accomplish what I'm trying to do?
Dale Wijnand
@dwijnand
Oct 19 2016 15:24
No don't
just provide a minimised case of what you're trying to accomplish
Matt Hicks
@darkfrog26
Oct 19 2016 15:27
@dwijnand I'm simply trying to do an aggregated publish to two different Resolvers
@OlegYch I already tried the examples in that StackOverflow post and the command works, but it doesn't aggregate
the alias never would actually work at all
OlegYch
@OlegYch
Oct 19 2016 15:29
i imagine you have to change publishTo in all aggregated projects
Dale Wijnand
@dwijnand
Oct 19 2016 15:30
Ah I see. sbt is built on the convention that a project is only published to one repository, so that's why you're struggling
Matt Hicks
@darkfrog26
Oct 19 2016 15:30
@dwijnand exactly
Dale Wijnand
@dwijnand
Oct 19 2016 15:33
Using commands is generally discouraged, a lot of sbt's benefit comes from the settings/tasks graph. So the best way to do what you're trying to do involves rewiring how publish is defined, but in terms of a new publishToMultiple key.. but that'll be difficult, because of that built-in convention
Matt Hicks
@darkfrog26
Oct 19 2016 15:33
if my Task could run the Command then it would aggregate though, right?
@dwijnand if I just use the Command defined in the StackOverflow answer couldn't I just call it from the Task?
Dale Wijnand
@dwijnand
Oct 19 2016 15:35
I've never seen anyone try to call a command from a task, so that's really unchartered waters :)
try runAggregated
Matt Hicks
@darkfrog26
Oct 19 2016 15:40
well....calling Command.process("publishToServers", state.value) compiled and ran, but it just set the current project to the root project several times.
@OlegYch runAggregated on the Command?
OlegYch
@OlegYch
Oct 19 2016 15:41
on publish
Matt Hicks
@darkfrog26
Oct 19 2016 15:41
I don't follow
OlegYch
@OlegYch
Oct 19 2016 15:42
instead of Project.runTask
Matt Hicks
@darkfrog26
Oct 19 2016 15:43
there isn't a runAggregated on Project
ah, on extracted
nope
just says "[success]" twice
no publishing occurs
OlegYch
@OlegYch
Oct 19 2016 15:47
welp
post your codez
i swear i did it a couple of times, but the api surface area so large and full of similar yet subtly different functions it is impossible to remember
Matt Hicks
@darkfrog26
Oct 19 2016 16:09
@OlegYch I was going to create a simple project representing this, but the StackOverflow example is exactly what I'm doing.
I have a multi-project and I'm just trying to publish each of the sub-projects to two places
perhaps that will do what I need, but it's three years old
for SBT 0.12.0
Matt Hicks
@darkfrog26
Oct 19 2016 16:16
yeah, I just noticed that
I'm away from my office and on my laptop so I'll have to wait until I get back to test it
thanks for your help though
Dale Wijnand
@dwijnand
Oct 19 2016 16:17
no worries
Dale Wijnand
@dwijnand
Oct 19 2016 16:24
Out of curiosity why do you want to publish to two repositories?
Perry
@pfn
Oct 19 2016 16:56
hmm, is there any way to make updateSbtClassifiers ignore provided dependencies?
Matt Hicks
@darkfrog26
Oct 19 2016 17:48
@dwijnand I wrote a server infrastructure that runs the server from dependencies and there are two instances of the server. I could alternately just create a private repository but preferred this route.
Dale Wijnand
@dwijnand
Oct 19 2016 17:49
I see, so you're publishing is effectively deploying the code.
Matt Hicks
@darkfrog26
Oct 19 2016 18:16
yes
@dwijnand the project is https://github.com/outr/jefe if you're interested. It manages server instances, proxies, routing logs, and allows me easy management of the running version via Coursier's Maven / Ivy dependencies instead of a massive WAR or JAR to be run (although it also supports that as well).
I primarily use it in production servers to provide fallback / maintenance mode if I need to take the server down as well as much faster ability to do releases.
Dale Wijnand
@dwijnand
Oct 19 2016 18:19
interesting, thanks
Matt Hicks
@darkfrog26
Oct 19 2016 21:44
multiPublish was a failure