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

Mill support: enable importing projects which contain build.mill(.scala) but not wrapper script #674

Closed
wants to merge 5 commits into from
Closed
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,30 @@ class MillProjectInstaller extends BspProjectInstallProvider {

override def canImport(workspace: File): Boolean =
Option(workspace) match {
case Some(directory) if directory.isDirectory => isBspCompatible(directory) || isLegacyBspCompatible(directory)
case Some(directory) if directory.isDirectory =>
BspUtil.findFileByName(directory, "build.mill").isDefined ||
BspUtil.findFileByName(directory, "build.mill.scala").isDefined ||
isBspCompatible(directory) ||
isLegacyBspCompatible(directory)
case _ => false
}

override def getConfigSetup: ConfigSetup = MillSetup

override def serverName: String = "Mill"

override def installCommand(workspace: File): Try[Seq[String]] = {
override def installCommand(workspace: File): Try[Seq[String]] = Try {
// note: The legacy part is only executed for mill bootstrap script so it is not applicable for Windows.
// Maybe it could be, but we decided to support mill.bat file only for the newer bsp approach
val isLegacyMill = !SystemInfo.isWindows && isLegacyBspCompatible(workspace)
val millFileOpt = getMillFile(workspace)
millFileOpt match {
case Some(file) if isMillFileBspCompatible(file, workspace) =>
Success(Seq(file.getAbsolutePath, "-i", "mill.bsp.BSP/install"))
case Some(file) if isLegacyMill =>
Success(Seq(file.getAbsolutePath, "-i", "mill.contrib.BSP/install"))
case _ => Failure(new IllegalStateException("Unable to install BSP as this is not a Mill project"))
case Some(file) if isLegacyMill && !isMillFileBspCompatible(file, workspace) =>
Seq(file.getAbsolutePath, "-i", "mill.contrib.BSP/install")
case Some(file) => // executes if isMillFileBspCompatible
unkarjedy marked this conversation as resolved.
Show resolved Hide resolved
Seq(file.getAbsolutePath, "-i", "mill.bsp.BSP/install")
case _ =>
Seq("mill", "-i", "mill.bsp.BSP/install")
}
}

Expand Down