These are chat archives for sbt/sbt

8th
Aug 2017
Roman Tkalenko
@tkroman
Aug 08 2017 01:18
Hi guys. What is the right way to share build code between multi-project builds? I.e. if I have a bunch of compiler parameters and want to reuse them. Say, there are 3 projects: common, projectA & projectB, where the latter two depend on common as a ProjectRef (or ProjectRoot, doesn't matter). What I want is to have a scalacOptions.sbt in the common project , and for both common and projectA / projectB to be compiled with these flags.
eugene yokota
@eed3si9n
Aug 08 2017 02:44
@tkroman when you say "project" do you mean independent builds, or subprojects within one build?
if it's just subprojects, you can put all your stuff in Seq[Setting[_]]
if it's across multiple builds, you'd need to turn it into an in-house plugin (which in turn can be source-based)
Roman Tkalenko
@tkroman
Aug 08 2017 03:14
I mean separate projects (are they "builds" in SBT terminology?). Plugin seems like an overkill, though. I guess copy-pasting is fine. At least until it's obviously not)
inb4 yes, monorepo:/
Which is not that bad actually. At the previous job we did a bunch of "microservices" which turned out to be a tangled mess of jars, and now the builds are pretty clean.
OlegYch
@OlegYch
Aug 08 2017 03:21
val commonSettings = Seq(bla := bla); val foo = project.settings(commonSettings)
OlegYch
@OlegYch
Aug 08 2017 03:31
commonSettings can be defined in a regular scala file in project/
Roman Tkalenko
@tkroman
Aug 08 2017 06:08
@OlegYch that would work if I had just a bunch of sub-modules. When they are not connected in any way other than the ProjectRef, I couldn't make that work (which seems logical to me)
Roman Tkalenko
@tkroman
Aug 08 2017 06:18
I mean, if the commonSettings are defined in the /common/project/commonSettings.sbt file, how would you refer to them from the /projectA/build.sbt? There is no root project to apply this settings.
basically, what @eed3si9n said seems to be the right thing.
I just thought that since project is a sort of meta-build-thingy, I could do some trick where the settings are applied to the build files
The problem, for which a plugin would be really the right way to go. Only I hoped for some build-level magic :)
Albert Serrallé Ríos
@aserrallerios
Aug 08 2017 06:40
thnx for the response @eed3si9n! I'm actually using sbt-errors-summary but as far as I know it cannot "group by warning/error type". My project is flooded by warnings and I want to approach them by type to make it bearable :D
Ólafur Páll Geirsson
@olafurpg
Aug 08 2017 07:35

@dwijnand the trick was to use key.all(ScopeFilter).value instead of key.value in my task implementation, roughly

// before
def task = Def.inputTask { val args = parser.parsed;  compile.value; ... }
// after
def task(args: T, filter: ScopeFilter) = Def.task { compile.all(filter).value; ... }

I have no idea if this may cause unwanted problems, it seems to do what I want. In addition, injecting the filter makes it easier to build a custom task to run across multiple projects, etc.

Dale Wijnand
@dwijnand
Aug 08 2017 07:36
I see. Interesting, thanks.
Ólafur Páll Geirsson
@olafurpg
Aug 08 2017 07:36
@aserrallerios compiler reported messages don't have IDs attached to them, it would be possible to group some kinds of messages that have the same string message (e.g., "unused import"), but other messages like type errors or missing implicits are harder to group together.
@dwijnand I find key.all(ScopeFilter) to be a very useful trick
Dale Wijnand
@dwijnand
Aug 08 2017 07:38
Yeah, I've reached for it a few times. It's good.
Taro L. Saito
@xerial
Aug 08 2017 08:52
Hi. What is a proper way to generate sbt.io.internal.Source objects in sbt 1.0? Some settings such as watchSources have changed from Seq[File] to Seq[sbt.io.internal.Source]. I need to know how to migrate File based configurations to use Sources.
Taro L. Saito
@xerial
Aug 08 2017 08:59
Related sbt/io#67
Dale Wijnand
@dwijnand
Aug 08 2017 09:08
perhaps this might help - it's how watchSources in Defaults was changed to Source: https://github.com/sbt/sbt/pull/3303/commits/0daca42c29188a511fd85bf4826dc05dac258b4b#diff-6373e7f7122325e753b75fe1cc76ff5fL320
Taro L. Saito
@xerial
Aug 08 2017 09:12
@dwijnand Thx!
I'm now having a trouble in using IntelliJ IDEA for sbt-1.0 plugin projects, so finding such source code reference is a bit hard
Dale Wijnand
@dwijnand
Aug 08 2017 09:14
yeah IntelliJ doesn't do alternative source directories..
Taro L. Saito
@xerial
Aug 08 2017 09:16
Error:Error while importing SBT project:<br/>...<br/><pre>[error]     at sbt.MainLoop$.run(MainLoop.scala:98)
[error]     at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:76)
[error]     at sbt.io.Using.apply(Using.scala:23)
[error]     at sbt.MainLoop$.runWithNewLog(MainLoop.scala:70)
[error]     at sbt.MainLoop$.runAndClearLast(MainLoop.scala:52)
[error]     at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:37)
[error]     at sbt.MainLoop$.runLogged(MainLoop.scala:29)
[error]     at sbt.StandardMain$.runManaged(Main.scala:104)
[error]     at sbt.xMain.run(Main.scala:71)
[error]     at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]     at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]     at xsbt.boot.Launch$.run(Launch.scala:109)
[error]     at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]     at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]     at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]     at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error]     at xsbt.boot.Boot$.main(Boot.scala:17)
[error]     at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: sbt/internal/librarymanagement/GetClassifiersModule
[error] Use 'last' for the full log.</pre><br/>See complete log in <a href="file:/Users/leo/Library/Logs/IntelliJIdea2017.2/sbt.last.log">file:/Users/leo/Library/Logs/IntelliJIdea2017.2/sbt.last.log</a>
I'm seeing this error when loading projects using sbt-1.0.0-RC3 in IntelliJ
Dale Wijnand
@dwijnand
Aug 08 2017 09:20
yeah GetClassifiersModule was moved out of internal between RC2 and RC3 https://github.com/sbt/librarymanagement/pull/124/files#diff-e71f31f8cf0b6d5ce958bad7a0c3b187L73
So looks like a change in the importing module. Maybe already fixed, just making it's way down the plugin release cycles.
Taro L. Saito
@xerial
Aug 08 2017 09:24
ok. Then I should wait for a while until the fix is available
Just from curiosity, why are you splitting sbt-related modules (e.g., io, librarymanagement) into separate repositories?
Dale Wijnand
@dwijnand
Aug 08 2017 09:25
@jastice has been doing a great job staying on top of things. Perhaps he can comment on what the state of importing RC3 builds is.
Taro L. Saito
@xerial
Aug 08 2017 09:25
@dwijnand Good to know
Dale Wijnand
@dwijnand
Aug 08 2017 09:27
There are different reasons why the repos was split. Among which: allows other tools to benefit from subsystems of sbt without consuming the whole of sbt (such as zinc). Also allows for subsystems to be replaces (such as librarymanagement)
Another reason is more repos means smaller repos. So if you're just an incremental compiler afficionado you don't have to worry about sbt settings and scopes, etc
Taro L. Saito
@xerial
Aug 08 2017 09:30
I see. That makes a lot of sense.
Justin Kaeser
@jastice
Aug 08 2017 09:32
@xerial @dwijnand oh, I missed that one. Will be fixed in tomorrow's nightly then
Taro L. Saito
@xerial
Aug 08 2017 09:33
@jastice That's great. This fix will be helpful for migrating sbt-plugins to 1.0.x
For each my sbt-plugin migration, I'm seeing different issues (x_x)
https://github.com/xerial/sbt-sonatype was a relatively easier one for the migration
Justin Kaeser
@jastice
Aug 08 2017 09:36
actually, it should be working already in nightly. what Scala Plugin version are you on @xerial ?
Taro L. Saito
@xerial
Aug 08 2017 09:36
2017.2.5
Justin Kaeser
@jastice
Aug 08 2017 09:38
it's hopefully fixed in the next bugfix release which is presumably coming out today or tomorrow, but I'd recommend the nightly to keep closer to the upstream changes
Taro L. Saito
@xerial
Aug 08 2017 09:40
image.png
Justin Kaeser
@jastice
Aug 08 2017 09:41
yup
Taro L. Saito
@xerial
Aug 08 2017 09:47
@jastice It worked! and now I can see sbt-1.0.0-RC3 library sources. Thanks!
Justin Kaeser
@jastice
Aug 08 2017 09:47
great!
Albert Serrallé Ríos
@aserrallerios
Aug 08 2017 10:44
@olafurpg oh, that's unfortunate :(
Pawel
@odwrotnie
Aug 08 2017 11:54
How do you run 2 tasks in parallel?
Justin Kaeser
@jastice
Aug 08 2017 12:10
@odwrotnie all task1 task2
Dale Wijnand
@dwijnand
Aug 08 2017 12:20
from the shell, yeah, with all
Pawel
@odwrotnie
Aug 08 2017 12:20
and how to create task that will run them?
Dale Wijnand
@dwijnand
Aug 08 2017 12:21
Just depend on them. They'll be run in parallel.
Pawel
@odwrotnie
Aug 08 2017 12:23
Thank!
Pawel
@odwrotnie
Aug 08 2017 12:36
How do you run on p1 and p2 (they both have main class) in parallel? I can't figure it out...
lazy val root = (project in file("."))
  .aggregate(p1, p2)

lazy val p1 = (project in file("p1"))
  .settings(
    libraryDependencies ++= Seq(logging,
      logback,
      scalatest))

lazy val p2 = (project in file("p2"))
  .settings(
    libraryDependencies ++= Seq(logging,
      logback,
      scalatest))
Dale Wijnand
@dwijnand
Aug 08 2017 12:43
run := {
  val () = (run in p1 in Compile).evaluated
  val () = (run in p2 in Compile).evaluated
  ()
}
Pawel
@odwrotnie
Aug 08 2017 12:52
Thanks!
OlegYch
@OlegYch
Aug 08 2017 13:01
or sbt-revolver
N.S. Cutler
@godenji
Aug 08 2017 13:07
does sbt-scripted work out of the box for 1.0? Getting same error as listed in sbt-launcher's readme
Error during sbt execution: Could not finder sbt launch configuration ...
works fine for 0.13.16
scripted generates a snapshot jar which, when depended on by a test sbt project, works fine for both 0.13.16 and 1.0. Something seems to be off when running scripted tests.
Sam Halliday
@fommil
Aug 08 2017 17:01
I'm a bit confused by how the sbt parsers work... Space ~ NatBasic ~ Space ~ NatBasic ~ Space ~ NatBasic ~ Space ~ StringBasic
what am I supposed to use to get the non-Space bits out in the subsequent functor pattern match
Sam Halliday
@fommil
Aug 08 2017 17:09
I'm matching on start ~ _ ~ finish ~ _ ~ minutes ~ _ ~ name which seems inefficient
eugene yokota
@eed3si9n
Aug 08 2017 17:32
if you don't want Spcace you should use ~>, I think
Sam Halliday
@fommil
Aug 08 2017 17:32
I tried lots of permutations of that
oh, you mean in the pattern matcher?
nope, that doesn't work either
I'll live with the _
eugene yokota
@eed3si9n
Aug 08 2017 17:34
token(Space ~> NatBasic).example(" foo") ^^^ { case x => ... }
I think you just need to make a bunch of small parsers and then chain them together
Sam Halliday
@fommil
Aug 08 2017 17:36
yeah, probably. I'll stick with the underscores. Thanks!
Rich
@Richtype
Aug 08 2017 17:43
~ run doesn't re run on 1.0.0-rc3 after I modify and save a file, but seems to work fine when I set the sbt.version to 0.13.16
eugene yokota
@eed3si9n
Aug 08 2017 19:12
@Richtype could you open GitHub issue for it plz?
Rich
@Richtype
Aug 08 2017 19:17
@eed3si9n I didn't reinstall sbt for 1.0 just created a new project and set the sbt.version, is that OK?
eugene yokota
@eed3si9n
Aug 08 2017 19:17
should be fine if everything else is working
Rich
@Richtype
Aug 08 2017 19:20
@eed3si9n Yes, I'll try a hello world project then open the issue?
eugene yokota
@eed3si9n
Aug 08 2017 19:20
sounds good
N.S. Cutler
@godenji
Aug 08 2017 22:11
:point_up: August 8, 2017 9:07 AM not sure what exactly is causing boot.properties to disappear for ^scripted 1.0.0-RC3/2.12 tests. Passing boot.properties path as a system property for 1.0.0-RC3 phase gets the tests to run, but this is far from ideal.
I wonder if Coursier might be involved somehow. Anyone else hit this issue with scripted?