These are chat archives for sbt/sbt

29th
May 2017
Li Haoyi
@lihaoyi
May 29 2017 04:37
Hmm for some reason (allDependencies in Compile) ++= (updateClassifiers in Compile).value.allModules doesn't add stuff to the sbt assembly jar
Li Haoyi
@lihaoyi
May 29 2017 04:42
(allDependencies in Test) ++= (updateClassifiers in Test).value.allModules seems to add stuff to test:run's classpath but (allDependencies in Compile) ++= (updateClassifiers in Compile).value.allModules doesn't add stuff to run
???
and allDependencies ++= updateClassifiers.value.allModules hangs
??? ???
Li Haoyi
@lihaoyi
May 29 2017 04:48
    (fullClasspath in Test) ++= {
      (updateClassifiers in Test).value
        .configurations
        .find(_.configuration == Test.name)
        .get
        .modules.flatMap(_.artifacts.map(_._2))
    }

adds the sources to test:run, but

    (fullClasspath in Compile) ++= {
      (updateClassifiers in Compile).value
        .configurations
        .find(_.configuration == Compile.name)
        .get
        .modules.flatMap(_.artifacts.map(_._2))
    }

does not add the sources to run

Li Haoyi
@lihaoyi
May 29 2017 04:53
huh apparently I wanted Runtime instead of Compile
I have never before seen Runtime in the my 6 years using Scala O.o
learn something new every day
Li Haoyi
@lihaoyi
May 29 2017 05:36
last challenge: how to merge a subproject's own source jar into it's assembly?
Li Haoyi
@lihaoyi
May 29 2017 05:54
ok this gets it into the assembly
    fullClasspath in assembly ++= Seq(
      (packageSrc in (ops, Compile)).value,
      (packageSrc in (terminal, Compile)).value,
      (packageSrc in (ammUtil, Compile)).value,
      (packageSrc in (ammRuntime, Compile)).value,
      (packageSrc in (ammInterp, Compile)).value,
      (packageSrc in (ammRepl, Compile)).value,
      (packageSrc in Compile).value
    )
Li Haoyi
@lihaoyi
May 29 2017 05:59
i wonder if i can do it without packageSrcing things?
I see a packageSrcMappings thing which looks like what I want but don't know what to do with it
Li Haoyi
@lihaoyi
May 29 2017 08:16
I don't suppose anyone would know why SBT's ClasspathFilter classloader doesn't want to load JDK classfiles as resources? https://gist.github.com/lihaoyi/76929bfe2120732ebc9357abe7dcc92b
Li Haoyi
@lihaoyi
May 29 2017 08:23
put it up on stackoverflow, in case anyone wants to get some internet points
eugene yokota
@eed3si9n
May 29 2017 08:38
you know me. i'll do things for internet points - https://stackoverflow.com/a/44238062/3827
Li Haoyi
@lihaoyi
May 29 2017 08:39
thanks!
so i know it creates a hierarchy of classloaders, and I can guess that ClasspathFilter filters the classpath
what I don't get is why the resource java/lang/String.class disappears
after all, the Scala version may change but one JVM can only have one Java version right
eugene yokota
@eed3si9n
May 29 2017 08:40
that's likely close to the root of the tree
since it won't change
Jason's note shows the dump of the tree
it's even using fastparse as example
Li Haoyi
@lihaoyi
May 29 2017 08:42
i mean java/lang/String.class should be at the root of the tree; pretty sure no JVM code can run without it given how deeply it's embedded in the spec and bytecode
but it shouldn't be getting filtered out right?
eugene yokota
@eed3si9n
May 29 2017 08:44
run runs in the context of sbt's thread
Li Haoyi
@lihaoyi
May 29 2017 08:46
why does running in the context of sbt's thread mean java/lang/String.class gets filtered out?
eugene yokota
@eed3si9n
May 29 2017 08:48
I'm guessing that it just returns some nonsensical classloader when it's not handcrafted
Li Haoyi
@lihaoyi
May 29 2017 08:59
should I open an issue for it?
eugene yokota
@eed3si9n
May 29 2017 09:00
it's somewhere in between nice to have and by design at this point I think
Li Haoyi
@lihaoyi
May 29 2017 09:00
using fork seems to avoid that problem, but then it introduces other problems...
eugene yokota
@eed3si9n
May 29 2017 09:00
yea fork you get a fresh JVM
Li Haoyi
@lihaoyi
May 29 2017 09:00
like if I use fork, any subprocesses start assuming they're running in batch-mode and stop being interactive
Li Haoyi
@lihaoyi
May 29 2017 09:11
hmm
i wonder if I can just try to read the resource from both classloaders as a dumb workaround
eugene yokota
@eed3si9n
May 29 2017 09:13
as long as the real usage doesn't get perf penalty, why not
Li Haoyi
@lihaoyi
May 29 2017 09:15
mostly because it's gross and hacky :/
but I can't figure out how to make my subprocesses behave with forked := true
so I guess no other way
Li Haoyi
@lihaoyi
May 29 2017 09:35
/**
  * Try to load resources from two parents; necessary to get Ammonite's source
  * code browsing to work in SBT projects because SBT messes up the context
  * classloader https://stackoverflow.com/q/44237791/871202
  */
class ForkClassLoader(realParent: ClassLoader, fakeParent: ClassLoader)
  extends ClassLoader(realParent){
  // This delegates to the parent automatically
  override def findResource(name: String) = fakeParent.getResource(name)
}
hopefully this won't cause anything to blow up...
Jorge
@jvican
May 29 2017 14:41
Isn't that what dual classloader does?
Li Haoyi
@lihaoyi
May 29 2017 15:19
what's dual classloader?
Ghost
@ghost~540393fe163965c9bc2018ce
May 29 2017 22:46
@lihaoyi run away while you can. This path leads to pain and suffering. And there is no lightsabre.
re: source stuff, make sure you didn't miss the megaUpdate. That's soo much faster than doing it per project.
there is a WIP PR with a Task way of doing it all, no Commands