question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sbt-1.3.0-M2 breaks code that relies on URLClassLoader

See original GitHub issue

steps

problem

expectation

  • sbt class loader should provide a URLClassLoader to get local resource URls.

notes

sbt version: 1.3.0-M2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
eatkinscommented, Apr 3, 2019

Should be fixed in #4601

ethanatkins@Ethans-MacBook-ProZ:~/work/oss/sbt/community/airframe$ sbt8 -Dsbt.supershell=never -Dsbt.version=1.3.0-M2 "logJVM/testOnly *ResourceTest"                                                                                                                                     
Getting org.scala-sbt sbt 1.3.0-M2  (this may take some time)...
:: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        80 artifacts copied, 0 already retrieved (29549kB/218ms)
[info] Loading settings for project global-plugins from idea.sbt,global.sbt ...
[info] Loading global plugins from /Users/ethanatkins/.sbt/1.0/plugins
[info] Loading settings for project airframe-build from plugin.sbt ...
[info] Loading project definition from /Users/ethanatkins/work/oss/sbt/community/airframe/project
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project root from build.sbt ...
[info] Resolving key references (32254 settings) ...
[info] Set current project to airframe-root (in build file:/Users/ethanatkins/work/oss/sbt/community/airframe/)
[info] ResourceTest:
[info] Resource
[info] - should find files from the current class loader
[info] - should find resources from jar files *** FAILED ***
[info]   0 was not greater than 0 (ResourceTest.scala:41)
[info] - should find classes of specific types *** FAILED ***
[info]   0 was not greater than 0 (ResourceTest.scala:49)
[info] ResourceReader trait
[info] - should find files using the context class
[info] Run completed in 509 milliseconds.
[info] Total number of tests run: 4
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 2, canceled 0, ignored 0, pending 0
[info] *** 2 TESTS FAILED ***
[error] Failed tests:
[error]         wvlet.log.io.ResourceTest
[error] (logJVM / Test / testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 3 s, completed Apr 2, 2019 5:00:51 PM
ethanatkins@Ethans-MacBook-ProZ:~/work/oss/sbt/community/airframe$ sbt8 -Dsbt.supershell=never -Dsbt.version=1.3.0-meta-0 "logJVM/testOnly *ResourceTest"                                                                                                                                 
Getting org.scala-sbt sbt 1.3.0-meta-0  (this may take some time)...
:: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        80 artifacts copied, 0 already retrieved (29706kB/149ms)
[info] Loading settings for project global-plugins from idea.sbt,global.sbt ...
[info] Loading global plugins from /Users/ethanatkins/.sbt/1.0/plugins
[info] Loading settings for project airframe-build from plugin.sbt ...
[info] Loading project definition from /Users/ethanatkins/work/oss/sbt/community/airframe/project
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
/Users/ethanatkins/work/oss/sbt/community/airframe/build.sbt:251: warning: value watchSources in object Keys is deprecated (since 1.3.0): WatchSource has been replaced by Glob. To add file triggers to a task with key: Key, set `Key / watchTriggers := Seq[Glob](...)`.               
      watchSources += new sbt.internal.io.Source(
      ^
[info] Loading settings for project root from build.sbt ...
[info] Resolving key references (32319 settings) ...
[info] Set current project to airframe-root (in build file:/Users/ethanatkins/work/oss/sbt/community/airframe/)
[info] ResourceTest:
[info] Resource
[info] - should find files from the current class loader
[info] - should find resources from jar files
[info] - should find classes of specific types
[info] ResourceReader trait
[info] - should find files using the context class
[info] Run completed in 681 milliseconds.
[info] Total number of tests run: 4
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 4, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 4 s, completed Apr 2, 2019 5:01:39 PM
1reaction
eatkinscommented, Apr 1, 2019

Ok, cool. I didn’t fully understand the use case. My point is simply that there is nothing in the sbt spec that says that run or test provide any specific URLClassLoader implementation so you are relying on undefined behavior. As long as we can agree on that point (or agree to disagree), I think we can move on.

I’m not saying you’re wrong. I am suggesting that if a URLClassLoader with specific semantics is required then it would be best practice to actually manage your classloaders manually and not rely on what sbt provides by default. Then you will not be impacted if sbt (or any other build tool) changes the implementation out from underneath you.

Again, I am planning to fix the current airframe build before sbt 1.3.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found