-
Notifications
You must be signed in to change notification settings - Fork 81
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 Coursier as a library management implementation #270
Conversation
Essentially, this is a port of the current The only current problem is that using coursier to fetch sbtplugins (with |
This is a fantastic step in the right direction. I'm not sure I can do a meaningful review but I'm going to try anyway. However, I also got stuck on the sbt plugins and that was one of the reasons I couldn't complete the PR, as I ran out of ideas. One question: when you set the resolver to coursier does the sbt launcher also fetch the sbt jars themselves using coursier or ivy? On a CI environment this is often the slowest part of the build. |
I'm pretty sure this is not happening, nor I have a clue on how this can be done, maybe @eed3si9n can help? |
sbt launcher is its own small program that has its own Ivy embedded. It might be good to at least parallelize download of that like sbt 1's Ivy in lm. |
I experimented with using coursier for this too: leonardehrenfried/sbt@4d41125#diff-2d60fc47edf4d9f1c9de681e52e5cd47R95 I downloaded the dependencies but then the JVM couldn't find or load them. In the end I gave up. IMO, we can however solve one problem at a time and this one can be tackled later. In any case, the change would need to happen to the |
Thanks for your efforts @andreaTP! Have you thought about adding this to the sbt-coursier repository instead? It already has plenty of scripted tests. These currently ensure the sbt-coursier plugin is fine, but I guess they could be tweaked to run against a custom version of sbt, depending on lm-coursier, like you do here. These tests should be rather thorough, so this could help catch bugs in lm-coursier (and debug the issue with sbt plugins I guess). I can help move that there. |
@@ -259,6 +260,22 @@ lazy val lmIvy = (project in file("ivy")) | |||
), | |||
) | |||
|
|||
lazy val lmCoursier = (project in file("coursier")) | |||
.enablePlugins(ContrabandPlugin, JsonCodecPlugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these plugins necessary?
.enablePlugins(ContrabandPlugin, JsonCodecPlugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kept Contraband that is now used and removed the unused JsonCodec
build.sbt
Outdated
commonSettings, | ||
crossScalaVersions := Seq(scala212, scala211), | ||
name := "librarymanagement-coursier", | ||
libraryDependencies ++= Seq(coursier, coursierCache, scalaTest, scalaCheck), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only depend on scalaTest
and scalaCheck
for the tests?
libraryDependencies ++= Seq(coursier, coursierCache, scalaTest, scalaCheck), | |
libraryDependencies ++= Seq(coursier, coursierCache, scalaTest % Test, scalaCheck % Test), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct thanks
name := "librarymanagement-coursier", | ||
libraryDependencies ++= Seq(coursier, coursierCache, scalaTest, scalaCheck), | ||
managedSourceDirectories in Compile += | ||
baseDirectory.value / "src" / "main" / "contraband-scala", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like above, is this needed? (unless you plan to add contraband stuff to lmCoursier
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now yes
|
||
case class CoursierModuleSettings() extends ModuleSettings | ||
|
||
private[sbt] class CoursierDependencyResolution(resolvers: Vector[Resolver]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be like a case class, or made behave like one? That way, fields corresponding to the various sbt-coursier keys could correspond to fields here, that could be customized via a .copy(…)
.
Users could then easily tweak various parameters of the resolution.
And it might also be interesting to have a next version of sbt-coursier just set and / or customize dependencyResolution
, updating the various fields. (That would provide a migration path sbt-coursier -> lm-coursier).
Using a simple case class might pose some binary compatibility issues though… Maybe contraband could help here? (Maybe via a separate class to keep all the parameters.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the keys don't necessarily need to be here in a first time, just something case-class like, fine with binary compatibility if we add fields, would allow to add the various fields later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding a contraband CoursierSettings
class, this also affect previous comments around contraband itself
val localArtifacts: Map[Artifact, Either[FileError, File]] = Gather[Task] | ||
.gather( | ||
resolution.artifacts.map { a => | ||
Cache.file[Task](a).run.map((a, _)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to pass a logger here too, for progress bars and all to appear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
val fetch = Fetch.from(repositories, Cache.fetch[Task](logger = Some(createLogger()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger
(TermDisplay
at least) should be stopped (via TermDisplay.stop()
). This might result in spurious terminal state else (some progress bar updates not being flushed in particular).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@alexarchambault first round done, ready for the next 😃 |
@alexarchambault finally solved the issue with the meta-build! 🥇 I reworked it again a few times until being able to compile sbt itself with coursier as LM. |
The validator has checked the following projects, tested using dbuild, projects built on top of each other.
✅ The result is: SUCCESS The binaries are at https://dl.bintray.com/sbt/maven-snapshots |
A validation involving this pull request is in progress... |
The validator has checked the following projects, tested using dbuild, projects built on top of each other.
✅ The result is: SUCCESS The binaries are at https://dl.bintray.com/sbt/maven-snapshots |
789a4cc
to
abc6d69
Compare
A validation involving this pull request is in progress... |
The validator has checked the following projects, tested using dbuild, projects built on top of each other.
✅ The result is: SUCCESS The binaries are at https://dl.bintray.com/sbt/maven-snapshots |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work @leonardehrenfried, @andreaTP, and @alexarchambault
This is a revamp of the great effort done first by @leonardehrenfried in #190
Now we can reproduce the test cases using the scripted tests implementation.
Current status is that normal project dependencies are properly downloaded and resolved, while sbt plugins gets downloaded but not discovered by Sbt itself.
I'm not sure if the resolution of sbt-plugins is mandatory to start integrating this PR.
I've noticed that now coursier is able to publish artifacts, but I think this can be added in a second stage.
I will ask for help and review by @alexarchambault and @eed3si9n