sbtivyjfrog-cliaws-codeartifactcoursier

SBT dependency resolution is too slow with messages : dependency descriptor has been mediated


I am trying to migrate my scala-sbt project artifactory from JFrog to AWS Codeartifact. I am able to resolve dependencies, compile and publish the jars back to AWS Codeartifact with only one problem, the compilation is too slow.

I see that with AWS Codeartifact, SBT is not using coursier even when I explicitly ask it to use with these options -Dsbt.ivy=false -Dsbt.coursier=true. I see all the dependencies getting downloaded in to ~/.ivy2/ location.

Also I see a lot of messages like this

 dependency descriptor has been mediated: dependency: io.netty#netty-buffer;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-buffer;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-codec-http;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-codec-http;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] == resolving dependencies com.concentra#http4d_2.13;2.0.1->org.http4s#http4s-async-http-client_2.13;0.23.11 [compile->compile(*)]
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-buffer;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-buffer;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-codec-http;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-codec-http;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] == resolving dependencies org.http4s#http4s-async-http-client_2.13;0.23.11->org.scala-lang#scala-library;2.13.8 [compile->master(compile)]
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-buffer;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-buffer;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-codec-http;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-codec-http;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-buffer;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-buffer;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-codec-http;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-codec-http;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-buffer;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-buffer;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-codec-http;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-codec-http;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-buffer;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-buffer;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] dependency descriptor has been mediated: dependency: io.netty#netty-codec-http;4.1.75.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]} => dependency: io.netty#netty-codec-http;4.1.77.Final {compile=[compile(*), master(compile)], runtime=[runtime(*)]}
[debug] == resolving dependencies org.http4s#http4s-a

I am not sure what is the meaning of this message and I dont see this when I use JFrog artifactory and most of the messages are on io.netty dependency.

Has anyone faced similar issues? Is there a way to get rid of the descriptor has been mediated messages and speedup the resolution?


Solution

  • Even though these -Dsbt.ivy=false -Dsbt.coursier=true did not take effect, when coursier was forced through project settings and plugin settings, I see significant improvement in resolution speed.

    Project settings:

    lazy val commonSettings = Seq(
        useCoursier := true, <<-- This change
        ------
    

    Plugin settings in plugins.sbt

    addSbtPlugin("org.scala-sbt"                     % "sbt-maven-resolver"  % "0.1.0")
        addDependencyTreePlugin
        useCoursier := true <<- This change
    

    It also downloaded all the dependencies to the coursier path - ~/Library/Caches/Coursier/v1/https instead of ivy path - ~/.ivy2/. The overall dependency resolution + compilation speed is now on par with that of JFrog