-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resources can not be found at compile time when added as dependency (Scala 3) #86
Comments
Unfortunately, it doesn't work for me in a real world scenario: //> using repositories sonatype-s01:snapshots
//> using dep dev.rolang::dumbo:0.5.2
//> using dep de.hellobonnie::swan-mock-server:0.0.0+259-010141f9-SNAPSHOT
import _root_.dumbo.ResourceFilePath
ResourceFilePath.fromResourcesDir("migration/swan")
The problem seems to come from |
@taig Ok I see. Thanks for providing the example, it helped investigation. TL;DR It seems to be caused by double URL encoded Looks like coursier is storing the file name URL encoded. So a file name like
Can't tell for sure whether the file name should not have been URL encoded in the file system or In any case it doesn't seem to be related to the usage of macros, I get the same behavior when applying it at runtime, the resources can't be found due to double URL encoded path. |
Should be working now. //> using repositories sonatype-s01:snapshots
//> using repositories sonatype:snapshots
//> using dep dev.rolang::dumbo:0.5.2-4-247449e-SNAPSHOT
//> using dep de.hellobonnie::swan-mock-server:0.0.0+259-010141f9-SNAPSHOT
import _root_.dumbo.ResourceFilePath
println(ResourceFilePath.fromResourcesDir("migration/swan")) scala-cli dumbo.sc
Compiling project (Scala 3.5.2, JVM (21))
Compiled project (Scala 3.5.2, JVM (21))
List(/migration/swan/V0001__initial.sql) |
Thanks, I successfully migrated to 0.5.3 and could get rid of my custom resource scanner 👏 -def migrate(px: SxPool[IO], logger: Logger[IO])(database: String, migrations: String): IO[Unit] =
+def migrate(px: SxPool[IO], logger: Logger[IO])(database: String, migrations: List[ResourceFilePath]): IO[Unit] =
given Console[IO] = Consoles(logger.append(Scope.Root / "dumbo" / database))
- for
- resources <- Resources
- .list(migrations)
- .filter(_.extName === ".sql")
- .map(path => ResourceFilePath(s"/$path"))
- .compile
- .toList
- _ <- Dumbo.withResources[IO](resources).withSession(px).runMigration
- yield ()
+ Dumbo.withResources[IO](migrations).withSession(px).runMigration.void |
Had to revert due to a different issue that emerged 🙃 |
@taig One thing I occasionally need to do with sbt is to run Have also this setting in some places to ensure that resources are copied beforehand. (Compile / compile) := ((Compile / compile) dependsOn (Compile / copyResources)).value The order in which resources are copied and the compilation is executed seem to vary in sbt depending on how you run the tasks... 🤔 |
Thank you, that does indeed fix the problem 🙏 |
Scala 3 version of
Dumbo.withResourcesIn
is not able to list resources that are added as dependency at compile time (mentioned in #79 (comment) ).The text was updated successfully, but these errors were encountered: