scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Support scala native service loaders

Open bishabosha opened this issue 4 months ago • 1 comments

Version(s) 1.9.0

Describe the bug It appears service loaders are not discovered when packaging a scala native project To Reproduce inspired from https://github.com/lbialy/hms

//> using dep io.github.cquiroz::scala-java-time::2.6.0
//> using dep "io.github.cquiroz::scala-java-time-tzdb:2.6.0"

package time

import java.time.{Instant, ZoneId}
import java.time.format.DateTimeFormatter

@main def Test =
  println(s"available: ${ZoneId.getAvailableZoneIds()}")
  println(ZoneId.of("Europe/Zurich"))

this is the output when running a packaged app: (scala-cli --power package --native load-tz.scala -f)

available: [UTC, GMT]
Exception in thread "main" java.time.zone.ZoneRulesException: Unknown time-zone ID: Europe/Zurich
	at java.time.zone.ZoneRulesProvider$.getProvider(Unknown Source)
	at java.time.zone.ZoneRulesProvider$.getRules(Unknown Source)
	at java.time.ZoneRegion$.ofId(Unknown Source)
	at java.time.ZoneId$.of(Unknown Source)
	at java.time.ZoneId.of(Unknown Source)
	at time.load$minustz$package$.Test(Unknown Source)
	at time.Test.main(Unknown Source)
	at <none>.main(Unknown Source)

Expected behaviour when building the same file and dependencies with sbt (generated with sbt new scala-native/scala-native.g8)

available: [Asia/Aden, America/Cuiaba, Etc/GMT+9, Etc/GMT+8, Africa/Nairobi, America/Marigot,...
Europe/Zurich

bishabosha avatar Sep 12 '25 09:09 bishabosha

also unrelated - should probably allow to configure service loaders manually

bishabosha avatar Sep 12 '25 09:09 bishabosha