diff --git a/build/build/src/engine/sbt.rs b/build/build/src/engine/sbt.rs index a628d4e6248a..90eae0ce8bf5 100644 --- a/build/build/src/engine/sbt.rs +++ b/build/build/src/engine/sbt.rs @@ -41,6 +41,10 @@ impl CommandProvider for Context { } // This prevents https://github.com/sbt/sbt-assembly/issues/496 cmd.env(ide_ci::env::known::LC_ALL, ide_ci::env::known::C_UTF8); + // This prevents https://github.com/sbt/sbt/issues/6777#issuecomment-1613316167 + cmd.set_env(ide_ci::programs::sbt::SBT_SERVER_FORCESTART, &true)?; + // Again. Preferably there should be no sbt server spawned at all. + cmd.apply(&sbt::ServerAutostart(false)); Ok(cmd) } } diff --git a/build/ci_utils/src/programs/sbt.rs b/build/ci_utils/src/programs/sbt.rs index 7e7d5537f93c..0b90ea025dca 100644 --- a/build/ci_utils/src/programs/sbt.rs +++ b/build/ci_utils/src/programs/sbt.rs @@ -1,7 +1,26 @@ use crate::prelude::*; +use crate::define_env_var; +use crate::program::command::Manipulator; + +define_env_var! { + /// Force the SBT server to start, avoiding `ServerAlreadyBootingException`. + /// See: https://github.com/sbt/sbt/issues/6777#issuecomment-1613316167 + SBT_SERVER_FORCESTART, bool; +} + +#[derive(Clone, Copy, Debug)] +pub struct ServerAutostart(pub bool); +impl Manipulator for ServerAutostart { + fn apply(&self, command: &mut C) { + let arg = "sbt.server.autostart"; + let arg = format!("-D{arg}={}", self.0); + command.arg(arg); + } +} + macro_rules! strong_string { ($name:ident($inner_ty:ty)) => { paste::paste! {