-
Notifications
You must be signed in to change notification settings - Fork 502
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
Add option to pass lib dependencies to coursier #2628
base: main
Are you sure you want to change the base?
Add option to pass lib dependencies to coursier #2628
Conversation
@fthomas or @exoego I got the idea for this based on coursier/coursier#1987 and I think it makes sense to have this in steward too. Also I am a bit stuck with a test strategy, maybe you can give me an idea or hint? So far I did build steward local and tested with a locally published version of a self written lib to handle |
6bf7454
to
6203ee3
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2628 +/- ##
==========================================
- Coverage 91.18% 81.41% -9.78%
==========================================
Files 166 147 -19
Lines 3404 2615 -789
Branches 317 42 -275
==========================================
- Hits 3104 2129 -975
- Misses 300 486 +186 ☔ View full report in Codecov by Sentry. |
fyi: I created this lib, that can be added this way and I am using a build of the branch of this PR to run steward daily for a bunch of repos. Works just fine. |
Nice! I'm wondering: would this also work without this patch if gar-coursier would just be added to this project's |
I think I tried that at some point and it did not. But I'll check again and let you know. |
@fthomas I just realized, that it can't work as a dependency of the project, since we already load a plugin from GAR. But even if I would add it to /project, it can't work. Coursier needs the dependency to be loaded in the class loader before resolving the service specific url. For example |
I experimented a little bit with adding gar-coursier as a dependency to the project. According to https://get-coursier.io/docs/extra.html#extra-protocols, Coursier should search for that plugin via the println(
_root_.coursier.cache.CacheUrl.getClass.getClassLoader
.loadClass("coursier.cache.protocol.ArtifactregistryHandler")
) and observed what is printed with and without gar-coursier as a dependency. Without the additional dependency,
If I add
The same happens with This suggests to me that it should be possible to use gar-coursier with Scala Steward without any modifications by just adding the gar-coursier JAR to Scala Steward's classpath. |
Hey @fthomas sorry, for the late answer it got buried in my notifications. I will try to make it run the in the way you suggested. If I am successful, I'll only make a PR to add documentation on how to use custom protocol handlers with Scala Steward. |
@987Nabil thanks for working on this! Have you had some luck with the experiment? |
That depends how you run Scala Steward, right? For the GitHub Action it could be possible to use Coursier's |
Btw, it would be helpful if anyone who uses an extra protocol handler like gar-coursier and the Scala Steward GitHub Action to try and test the |
Linking sbt/sbt#6375 here. I guess if that PR is merged eventually, it would be nice if Scala Steward takes |
This can be used to add custom url handlers to coursier, so scala-steward could for example reach s3 buckets, google cloud storage or artifactregistry. See https://get-coursier.io/docs/extra.html#extra-protocols and coursier/coursier#1987
521f3d0
to
437388f
Compare
437388f
to
34318b6
Compare
Yeah, it doesn't seem to take it into account yet, we added an extra protocol handler in sbt via csrConfiguration := csrConfiguration.value.withProtocolHandlerDependencies(
Seq("org.example" % "google-artifact-repository-coursier" % "0.1.0")
) but it didn't help 🤷♂️ . We also got exceptions from the sbt-plugin as described in this PR For now I just added an extra protocol handler as core dependency together with the sbt-plugin update like in this commit to get it working . Would be good if scala-steward could pick up the coursier configs from the sbt project or accept an extra protocol handler as parameter. |
If I read this right, the https://github.com/scala-steward-org/sbt-plugin would need additional logic to export the additionally protocol handler from the |
This can be used to add custom url handlers to coursier, so
scala-steward could for example reach s3 buckets, google cloud storage
or artifactregistry.
See https://get-coursier.io/docs/extra.html#extra-protocols and
coursier/coursier#1987