These are chat archives for sbt/sbt

9th
Aug 2017
Taro L. Saito
@xerial
Aug 09 00:46
I've just finished the migration of all my sbt plugins (sbt-sonatype, sbt-pack, sbt-sql, sbt-jcheckstyle) to sbt 1.0. So far sbt-1.0.0-RC3 seems good enough for starting migration from 0.13.x
Taro L. Saito
@xerial
Aug 09 00:54
Dropping Scala 2.10 is getting realistic for me :)
eugene yokota
@eed3si9n
Aug 09 00:54
Thanks for all the work!
Taro L. Saito
@xerial
Aug 09 00:59
You are welcome and thanks for your help through this channel and github. It has been quite helpful
schwannden
@schwannden
Aug 09 01:53
Hi, is there a way to stop sbt from prepending all log with the [info], [error], [warning] tag?
eugene yokota
@eed3si9n
Aug 09 01:54
I don't think so
Rob Norris
@tpolecat
Aug 09 05:51
Anyone know how to eval a task at startup? I'd like to run dependencyUpdates whenever the build is [re]loaded.
eugene yokota
@eed3si9n
Aug 09 05:56
onLoad or .sbtrc I guess
onLoad in Global := { s => "something" :: s }?
I didn't have that task so I had to fake it but the following worked for me:
    dependencyUpdates := { println("hi") },
    onLoad in Global := { s => "dependencyUpdates" :: s }
eugene yokota
@eed3si9n
Aug 09 06:01
works on reload too
sbt:helloworld> reload
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /xxxx/project
[info] Loading settings from build.sbt ...
[info] Set current project to helloworld (in build file:/xxxx/)
hi
[success] Total time: 0 s, completed Aug 9, 2017 2:01:23 AM
Rob Norris
@tpolecat
Aug 09 06:03
aha, cool
onLoad was a setting and dependencyUpdates is a task so i assumed it wouldn't work
that's freakin mysterious but :+1:
eugene yokota
@eed3si9n
Aug 09 06:04
onLoad is a state transition function as a setting
Rob Norris
@tpolecat
Aug 09 06:05
so I cons the name of the task onto the state?
eugene yokota
@eed3si9n
Aug 09 06:05
yea
like humans typing into the shell
sbt shell is basically a State monad where you are the IO device
Rob Norris
@tpolecat
Aug 09 06:06
ok is it onLoad in ThisBuild or something, or just unscoped onLoad?
eugene yokota
@eed3si9n
Aug 09 06:07
in Global
Rob Norris
@tpolecat
Aug 09 06:07
ah sorry, you did that above
brilliant, works perfectly
eugene yokota
@eed3si9n
Aug 09 06:08
nice
Rob Norris
@tpolecat
Aug 09 06:08
i never would have figured that out. thanks!
Rich
@Richtype
Aug 09 09:24
Can enablePlugins be used as a project setting, or does it have to be implemented as a method on the Project class?
Dale Wijnand
@dwijnand
Aug 09 09:29
Plugins and settings are loaded and evaluated in different orders, which is probably why enabling plugins isn't a setting itself. See http://www.scala-sbt.org/1.x/docs/Setting-Initialization.html
Rich
@Richtype
Aug 09 09:31
@dwijnand ah thanks for the info.
Rich
@Richtype
Aug 09 09:37
Just reading the example from above doc. Hasn't extending Build been deprecated?
Dale Wijnand
@dwijnand
Aug 09 09:56
That's correct. That doc needs updating.
But most details in there are still correct/relevant.
Nicolas A Perez
@anicolaspp
Aug 09 13:20
I need to add a folder and some other .property files to the classpath. How one does that using sbt?
let's suppose the files and the folder I want to add are all inside another folder called required
Dale Wijnand
@dwijnand
Aug 09 13:44
Nicolas A Perez
@anicolaspp
Aug 09 13:54
@dwijnand that looks about right, but it does not work

I have this:

config/a.properties
config/b.properties

config/META-INFO/c.properties

I added this to build.sbt

 includeFilter in (Compile, unmanagedResources) := "*.*",
    unmanagedResourceDirectories in Compile += baseDirectory.value / "config"

but nothing gets cp to target/classes

@dwijnand any ideas?
Dale Wijnand
@dwijnand
Aug 09 14:03
property files aren't classes, so makes sense for them not to be cp to target/classes
Nicolas A Perez
@anicolaspp
Aug 09 14:04
but they will be in the class path?
I am using a lib that expects they in the class path
that is why
Dale Wijnand
@dwijnand
Aug 09 14:06
yep resources will be in the classpath at runtime
Nicolas A Perez
@anicolaspp
Aug 09 14:06
ok
thanks
Nicolas A Perez
@anicolaspp
Aug 09 14:11
@dwijnand those file are not making into the classpath
Dale Wijnand
@dwijnand
Aug 09 14:14
@anicolaspp Hmm
Alessandro Vermeulen
@spockz
Aug 09 14:14
Is there a way to see the (sub)project that is causing a log in sbt? We have parallel builds with output that is now mixed, we would like to have a way to merge the log again
Dale Wijnand
@dwijnand
Aug 09 14:14
Maybe you could put together a reproduction of what you're trying to do on Stackoverflow?
Nicolas A Perez
@anicolaspp
Aug 09 14:16
I move them to src/main/resources
@dwijnand so I I do sbt run they show up unde target/classes
but still can't find them on the classpath
Neverminder
@Neverminder
Aug 09 14:25
How to automatically run a task on SBT before it launches the application?
Dale Wijnand
@dwijnand
Aug 09 14:30
onLoad?
Neverminder
@Neverminder
Aug 09 14:32
So something like onLoad := println("")?
or do I have to explicitly create a task for that and append?
Dale Wijnand
@dwijnand
Aug 09 14:36
Nicest way is to create a task and invoke it with onLoad. But you could also execute code while defining onLoad (like your println example). Here's the new docs page: http://www.scala-sbt.org/1.0/docs/Howto-Startup.html
Neverminder
@Neverminder
Aug 09 14:39
Anything that works with 0.13.16? Tried something like this, but it errors
val bar: TaskKey[Unit] = TaskKey[Unit]("test", "test")
bar := { println("test") }

onLoad += bar
Neverminder
@Neverminder
Aug 09 14:47
Thanks, worked it out from that link
Dale Wijnand
@dwijnand
Aug 09 14:51
:+1:
Alessandro Vermeulen
@spockz
Aug 09 18:20
Is there a way I can get access to all the (resolved) transitive library dependencies of project a from the definition of project b?
Or its own for that matter
OlegYch
@OlegYch
Aug 09 18:46
managedClasspath
Erik Bruchez
@ebruchez
Aug 09 19:43

Hi all I am trying to run test setup/cleanup from sbt.

There is Tests.Setup() and Tests.Cleanup(). But the Scala code which runs within sbt doesn't have access to test code compiled with sbt. I would have to place it under project, I think, which is annoying because that code cannot leverage lots of utilities I am compiling alongside my tests.

I thought I could use the ClassLoader option of Tests.Setup(). This gives me access to the ClassLoaderof the compiled test classes, and then I could, with reflection, run some setup/cleanup methods. But this only works if the tests do not run in forked mode.

Is there a better way?