These are chat archives for sbt/sbt

9th
May 2017
Cause Chung
@cuzfrog
May 09 02:19
I made a plugin that automatically manages to link/mount tmpfs dirs in project.
https://github.com/cuzfrog/sbt-tmpfs
I hope someone could give it some review and advice. And there are two help requests that might make it better, see in the repo doc.Thanks.
Dale Wijnand
@dwijnand
May 09 07:29
@acjay Yes it would be, thank you. You've very right in pointing out it's tragic that our docs aren't enforced to be working code.
Dale Wijnand
@dwijnand
May 09 07:58
@dispalt looks like there's no better way to pass values to macros currently other than sys.props. If I were you I'd upvote (or create) a ticket making a request for it as an official feature.
Jorge
@jvican
May 09 09:15
for those that don't know, the Scala Center is contributing a better offline mode support in sbt 1.0 sbt/librarymanagement#92
Justin Kaeser
@jastice
May 09 09:46
nice, jorge!
Justin Kaeser
@jastice
May 09 10:09
if I want to deliver jars to the user without having them go through a resolver/online repo, would it work to put them into the local preloaded repo?
or define my own and add that to the boot properties somehow
Alessandro Vermeulen
@spockz
May 09 18:48
adding them and start sbt in offline mode should do for resolving I think
sbt "set offline := true” run
or hand out your project with that setting already turned o
Dan Di Spaltro
@dispalt
May 09 18:52
@dwijnand thanks for taking a look
Alessandro Vermeulen
@spockz
May 09 19:04
@jastice ^^
Simon Hafner
@reactormonk
May 09 21:59
Is there a way to write sbt code without the value macros and monadic code instead?
I feel like that would be easier to understand :-/
Jorge
@jvican
May 09 22:00
You can use map and flatMap
But eventually you'll need to ask for the value of the Initialize[_] instance
Simon Hafner
@reactormonk
May 09 22:00
Hmm
Jorge
@jvican
May 09 22:01
Doesn't resourceGenerators need a taskValue instead of value?
Yes, it does (I've just double-checked).
i think that the reason why your SO thread is failing is because of the desugaring of string interpolators
it creates code that sbt understands as if file is the value necessary to run the input task.
have you tried val input = s"api.swagger.SwaggerDump $file" and then (runMain in (proj, Compile)).toTask(input).value?
Simon Hafner
@reactormonk
May 09 22:10
wtf, not even source code is RT with sbt? :-(
Jorge
@jvican
May 09 22:10
what does RT mean?
Simon Hafner
@reactormonk
May 09 22:10
@jvican I'll give it a go tomorrow, thanks.
@jvican referentially transparent. Aka you can replace the function call with its output. Very useful for abstraction & refactoring.
Jorge
@jvican
May 09 22:11
Yeah, I know what referential transparency is. Didn't know the acronym though
It's understandable that sbt macros are not perfect wrt string interpolation. String interpolation is far from trivial and understanding its code output is difficult. There are definitely bugs with "illegal cyclic reference" errors -- I've filed a bunch IIRC.
If this is really bothering you, I can help you out fixing them at the root of the problem.
A contribution on this would be very much appreciated, I feel
OlegYch
@OlegYch
May 09 22:26
i doubt this is related to string interpolation
Jorge
@jvican
May 09 22:27
It may not be the case, I proposed a potential issue.
What do you think it's the culprit?
Jorge
@jvican
May 09 22:32
the implementation is here:
  /**
   * collects all definitions in the tree for use in checkreferences.
   * this excludes definitions in wrapped expressions because checkreferences won't allow nested dereferencing anyway.
   */
  def collectdefs(tree: tree, iswrapper: (string, type, tree) => boolean): collection.set[symbol] =
    {
      val defs = new collection.mutable.hashset[symbol]
      // adds the symbols for all non-ident subtrees to `defs`.
      val process = new traverser {
        override def traverse(t: tree) = t match {
          case _: ident => ()
          case applytree(typeapply(select(_, nme), tpe :: nil), qual :: nil) if iswrapper(nme.decodedname.tostring, tpe.tpe, qual) => ()
          case tree =>
            if (tree.symbol ne null) defs += tree.symbol;
            super.traverse(tree)
        }
      }
      process.traverse(tree)
      defs
    }

  /**
   * a reference is illegal if it is to an m instance defined within the scope of the macro call.
   * as an approximation, disallow referenced to any local definitions `defs`.
   */
  def illegalreference(defs: collection.set[symbol], sym: symbol): boolean =
    sym != null && sym != nosymbol && defs.contains(sym)

  /**
   * a function that checks the provided tree for illegal references to m instances defined in the
   *  expression passed to the macro and for illegal dereferencing of m instances.
   */
  def checkreferences(defs: collection.set[symbol], iswrapper: (string, type, tree) => boolean): tree => unit = {
    case s @ applytree(typeapply(select(_, nme), tpe :: nil), qual :: nil) =>
      if (iswrapper(nme.decodedname.tostring, tpe.tpe, qual)) ctx.error(s.pos, dynamicdependencyerror)
    case id @ ident(name) if illegalreference(defs, id.symbol) => ctx.error(id.pos, dynamicreferenceerror + ": " + name)
    case _ => ()
  }
To simplify, anything that it's not an ident is marked as an illegal dynamic reference. The implementation is far from being perfect, there is lots of code that disobeys that code structure, not only string interpolation but things like Project.foo(...).
certainly not related to string interpolationn
Jorge
@jvican
May 09 22:35
no, it's related to the code that is generated by scalac when it sees an string interpolator.
OlegYch
@OlegYch
May 09 22:36
refer to the case above, there is no string interpolator
Jorge
@jvican
May 09 22:36
of course it's related to string interpolation. the fact that there is a super set of things affected by it does not neglect the subset.
i repeat what i said at the beginning of this thread: "i think that the reason why your SO thread is failing is because of the desugaring of string interpolators".
OlegYch
@OlegYch
May 09 22:37
well try it without string interpolators
http://scastie.org/31027 tried it for you
don't forget that scalac is happy to discard values
it looks like toTask is somehow special, but i wouldn't now, never had much luck with inputtasks
*know
G. Richard Bellamy
@rbellamy
May 09 22:56
@dwijnand & @jvican - I'm frankly still stuck, if you wouldn't mind reviewing my comment on the PR that Jorge posted?