-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
BSP: Provide mill source files #1029
Conversation
@lefou this is ready for review |
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 suspect the SpecialClassLoader
never carried the mill API. But, maybe it's a good thing to be more verbose in case we don't get a SpecialClassLoader
.
I made some comments below.
bsp/src/mill/bsp/ModuleUtils.scala
Outdated
val repos = Evaluator | ||
.evalOrElse(evaluator, T.task(T.traverse(modules)(_.repositoriesTask)()), Seq.empty) |
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.
The T.task
is probably redundant. T.traverse
already produces a task.
@@ -36,7 +36,7 @@ object Lib{ | |||
depToDependency: Dep => coursier.Dependency, | |||
deps: TraversableOnce[Dep], | |||
mapDependencies: Option[Dependency => Dependency] = None, | |||
ctx: Option[mill.util.Ctx.Log] = None) = { | |||
ctx: Option[mill.util.Ctx.Log] = None): (Seq[Dependency], Resolution) = { |
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.
👍 for explicit return type.
bsp/src/mill/bsp/ModuleUtils.scala
Outdated
Agg( | ||
ivy"com.lihaoyi::mill-main:$millVersion", | ||
ivy"com.lihaoyi::mill-scalalib:$millVersion", | ||
ivy"com.lihaoyi::mill-scalajslib:$millVersion", | ||
ivy"com.lihaoyi::mill-scalanativelib:$millVersion" | ||
), | ||
sources = sources |
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 think these deps were never there before, at least all my experiments with mill-bsp resulted in missing mill API when editing build.sc
. But, we should not bury such a hardcoded list here. Instead, this is knowledge best located in the buildfile (build.sc
). We could generate a Scala file there (generateSources
or BuildInfo plugin) and use it here. We have this exactly hard-coded list also in GenIdeaImpl
, and I think this is an opportunity to fix both places the right way.
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.
Excellent idea! Check out the new commit.
bsp/src/mill/bsp/ModuleUtils.scala
Outdated
val millJars = resolveDependencies( | ||
Resolve.defaultRepositories, | ||
depToDependency(_, BuildInfo.scalaVersion), | ||
BuildInfo.millEmbeddedModules.map(module => ivy"com.lihaoyi::mill-$module:${BuildInfo.millVersion}"), |
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 think using full ivy artifact is the way to go (using module.publishSelfDependency()
when generating the BuildInfo
). Less assumptions about the deps.
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.
Check out the new commit.
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.
@joan38 I'm sorry when it appears as nitpicking. I think keeping the generated file dependency free is a good thing, so I suggest to use a plain string to transport the dependency. I added suggestions to show what I have in mind. Don't know if it compiles though.
If tests work, this looks good to me! Looking forward to try that out.
build.sc
Outdated
@@ -260,6 +261,8 @@ object scalalib extends MillModule { | |||
| val ammonite = "${Deps.ammonite.dep.version}" | |||
| /** Version of Zinc. */ | |||
| val zinc = "${Deps.zinc.dep.version}" | |||
| /** Dependency artifacts embedded in mill by default. */ | |||
| val millEmbeddedDeps = ${artifacts.map(artifact => s"""ivy"${artifact.group}::${artifact.id}:${artifact.version}"""")} |
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.
| val millEmbeddedDeps = ${artifacts.map(artifact => s"""ivy"${artifact.group}::${artifact.id}:${artifact.version}"""")} | |
| val millEmbeddedDeps = ${artifacts.map(artifact => s""""${artifact.group}:${artifact.id}:${artifact.version}"""")} |
Artitfact ID is already platform-resolved. Also I'd rather just use the string.
scalalib/src/GenIdeaImpl.scala
Outdated
for(name <- artifactNames) | ||
yield ivy"com.lihaoyi::mill-$name:${sys.props("MILL_VERSION")}", | ||
false, | ||
Versions.millEmbeddedDeps, |
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.
Versions.millEmbeddedDeps, | |
Versions.millEmbeddedDeps.map(d => ivy"$d"), |
bsp/src/mill/bsp/ModuleUtils.scala
Outdated
val millJars = resolveDependencies( | ||
Resolve.defaultRepositories, | ||
depToDependency(_, BuildInfo.scalaVersion), | ||
Versions.millEmbeddedDeps, |
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.
Versions.millEmbeddedDeps, | |
Versions.millEmbeddedDeps.map(d => ivy"$d"), |
@joan38, since our move to GitHub Actions, there is no longer the need to rebase or force-pushg all PRs to latest master to let tests pass. We can squash when merging. |
Your suggestions are good @lefou, keep on nitpicking that's how we achieve perfection :) Do you recommend moving this back to I'm just used to amend force pushing but would incremental commits better help incremental reviewing? |
You asked for it. ;-)
Yes.
Yeah, avoiding forced pushes would greatly help, esp. in the Github UI. |
Not sure why the following does not bring in the dependencies anymore since
0.9.x
:So this is resolving the source files directly. Let me know if you have a better idea.