bug: issues with duplicate resources with bloop 2.0.7
Bloop 2.0.7 introduced copying of resources on compilation (https://github.com/scalacenter/bloop/commit/b7fc29c4d221e3c3ecbcb99ccc0b64d540c2119c). This is causing some weird behaviour in bleep.
- When I am using liquibase and loading the changelog.xml from the resource folder it now complains that it finds two files in the path instead of one.
- Changes to files in the resource directory are not applied until a clean -> compile is done. (this might be fixed in 2.0.8 here https://github.com/scalacenter/bloop/commit/306fcaec93f8eca5ce718a8fa034c86105246157)
I'm going to try and create a reproducer and test it with the latest version of bloop to see if it matters for the second point. As for the first point I'm not sure why it picks up both directories (it might just be some insane liquibase thing).
gaah, i was so content because it didn't do that!
we're going to change some things then. we're explicitly adding the resource directories to the classpath a place or two - i suppose that's no longer a good idea.
i've actually noticed having resources double up myself, but i hadn't dug into why it happened
https://github.com/oyvindberg/bleep/blob/master/bleep-model/src/scala/bleep/model/SourceLayout.scala Is this the right place to start poking around?
yes, absolutely. you will find some usage of it in different contexts and we'll have to figure out which ones to keep.
in particular there is a utility method fixedClasspath which computes a new classpath for a project which explicitly adds resource directories - we can at least remove the resource directory in there
then there is GenBloopFiles, where we add resource directories for upstream projects, which means the bloop project file looks like this:
"classpath": [
"/Users/oyvind/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/ch/epfl/scala/bloop-config_2.13/2.3.1/bloop-config_2.13-2.3.1.jar",
// ...
"/Users/oyvind/bleep/.bleep/builds/bsp/.bloop/bleep-model/jvm213/classes",
"/Users/oyvind/bleep/.bleep/builds/bsp/.bloop/bleep-nosbt/jvm213/classes",
"/Users/oyvind/bleep/.bleep/generated-resources/bleep-model@jvm213/bleep.scripts.GenerateResources",
"/Users/oyvind/bleep/bleep-model/src/resources",
"/Users/oyvind/bleep/bleep-nosbt/src/resources"
]
we'll have to remove those as well, see this code here:
val classPath: model.JsonSet[Path] =
model.JsonSet.fromIterable(
allTransitiveTranslated.values.flatMap(x => x.project.classesDir :: x.project.resources.getOrElse(Nil)) ++ resolvedRuntimeDependencies.jars
)
do we know why this change was made in bloop? i really struggle to see why this is better
this is the relevant bugfix: https://github.com/scalacenter/bloop/pull/2553
And relevant discussion on Discord: https://discord.com/channels/632150470000902164/884881696300859442/1329770048931369062
I'm having such issues too, although I'm not sure if it's identical because it didn't seem like reverting to 0.0.11 helped.
For instance I frequently get this:
zio.FiberFailure: Interrupted by thread "zio-fiber-722041198"
at bookphone.Main.run(Main.scala:75)
Caused by: org.flywaydb.core.api.FlywayException: Found more than 1 SQL callback script called afterMigrate!
Offenders:
-> /home/naftoli/repositories/gitlab.com/bookphone/bookphone/04-main/src/resources/db/migration/afterMigrate.sql
-> /home/naftoli/repositories/gitlab.com/bookphone/bookphone/.bleep/builds/normal/.bloop/04-main/classes/db/migration/afterMigrate.sql
at org.flywaydb.core.internal.callback.SqlScriptCallbackFactory.<init>(SqlScriptCallbackFactory.java:79)
at org.flywaydb.core.FlywayExecutor.prepareCallbacks(FlywayExecutor.java:306)
at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:197)
at org.flywaydb.core.Flyway.migrate(Flyway.java:186)
at bookphone.FlywayHelpers$.$anonfun$flywayLayer$10(FlywayHelpers.scala:72)
at zio.ZIOCompanionVersionSpecific.$anonfun$attempt$1(ZIOCompanionVersionSpecific.scala:100)
at zio.ZIO$.$anonfun$suspendSucceed$1(ZIO.scala:4864)
at zio.internal.FiberRuntime.runLoop(FiberRuntime.scala:1063)
at zio.internal.FiberRuntime.runLoop(FiberRuntime.scala:1152)
at zio.internal.FiberRuntime.runLoop(FiberRuntime.scala:1094)
at zio.internal.FiberRuntime.runLoop(FiberRuntime.scala:1152)
at zio.internal.FiberRuntime.runLoop(FiberRuntime.scala:1067)
at zio.internal.FiberRuntime.evaluateEffect(FiberRuntime.scala:412)
at zio.internal.FiberRuntime.evaluateMessageWhileSuspended(FiberRuntime.scala:487)
at zio.internal.FiberRuntime.drainQueueOnCurrentThread(FiberRuntime.scala:249)
at zio.internal.FiberRuntime.run(FiberRuntime.scala:137)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Also, more than once I've modified application.conf and the change wasn't picked up -- the copy in .bleep hadn't been updated.
It's bothering me a lot also, but I've been in crunch time for a long while so I haven't had the time to fix it yet. Will get to it quite soon