Skip to content
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

Fix bsp: getMillBuildClasspath return URI string #1325

Merged
merged 5 commits into from
May 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bsp/src/mill/bsp/ModuleUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ object ModuleUtils {
target
}

/**
* Compute the BuildClasspath for the Mill build (build.sc files)
*
* @param evaluator mill evaluator that can resolve build information
* @param sources classpath for source jars or not
* @return Mill build Classpath(URI)
*/
def getMillBuildClasspath(evaluator: Evaluator,
sources: Boolean): Seq[String] = {

Expand All @@ -144,7 +151,9 @@ object ModuleUtils {
* java.net.URL = file:/C:/Users/Developer/mill/./
* scala> java.nio.file.Paths.get(".").toAbsolutePath.toUri.toURL.getFile
* String = /C:/Users/Developer/mill/./
* */
*
* It works for @camper42 on MacOS & Windows IDEA, works for @fabianhjr on Linux(NixOS)
*/
val classpath: Seq[Path] = Try(
evaluator.rootModule.getClass.getClassLoader
.asInstanceOf[SpecialClassLoader])
Expand All @@ -162,7 +171,7 @@ object ModuleUtils {
val binarySource =
if (sources) all.filter(url => isPathSourceJar(url))
else all.filter(url => !isPathSourceJar(url))
binarySource.filter(path => exists(path)).map(_.wrapped.toString)
binarySource.filter(path => exists(path)).map(_.toNIO.toUri.toString)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we don't use a better return type here. At least, we should add some Scaladoc to line 126 to make it clear, that the returned Strings are meant to be URIs.

}

/**
Expand Down