com-lihaoyi/mill

transitive runtime dependencies not available during tests

francisdb opened this issue · 8 comments

mill 0.1.3

I have tests using specs2 and specs2-mock
specs2-mock depends on mockito-core
mockito-core has runtime scoped dependencies declared

but when I run my tests they seem to be missing (this works correctly in sbt)

CAUSED BY
 java.lang.ClassNotFoundException: net.bytebuddy.dynamic.loading.ClassLoadingStrategy (Jvm.scala:115)
mill.modules.Jvm$$anon$1.findClass(Jvm.scala:115)
org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.<init>(SubclassByteBuddyMockMaker.java:33)
org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.<init>(ByteBuddyMockMaker.java:21)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:54)
org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:18)
org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:17)
org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:186)
org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:180)
org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
org.mockito.Mockito.mock(Mockito.java:1729)
org.mockito.Mockito.mock(Mockito.java:1642)

@francisdb Do you use the same version of specs2-mock in both mill and sbt version of build?

@rockjam yes same version but will first do another test now that #211 is fixed

I see. It looks like mockito is special in some regard, and it resolves differently from other libraries. You can check once again, but I'm pretty sure that this problem still persists

Confirmed to still be an issue. I guess coursier needs some extra config to include runtime scoped dependencies when mill is building the runClasspath

Yes, it seems so, however coursier cli handles mockito with runtime scoped dependencies nicely. I think that mill misses something in coursier integration code. I will look into it

@francisdb this issue is addressed by #270

@francisdb should be fixed in mill 0.1.7-28-bbd162 . Try it out

I can confirm this is fixed on master 👍🏻