diff --git a/coordinator/configs/projects-config.conf b/coordinator/configs/projects-config.conf index 68fce1ca..48de0630 100644 --- a/coordinator/configs/projects-config.conf +++ b/coordinator/configs/projects-config.conf @@ -91,6 +91,7 @@ armanbilge_feral.projects.exclude = [ "com.armanbilge%feral-lambda-api-gateway-proxy-http4s" ] armanbilge_gcp4s.tests = compile-only +armanbilge_van-cats.source-version=3.4 // override -source:future assist-iot-sripas_scala-mqtt-wrapper { sbt.commands = [ "excludeLibraryDependency org.wartremover:wartremover_{scalaVersion}", @@ -203,6 +204,13 @@ disneystreaming_smithy4s { smithy4s-dynamic.tests = compile-only } } +disneystreaming_smithy-translate { + source-patches = [{ + path = "buildSetup.sc" + pattern = "case ZincWorkerUtil.DottyVersion("0"," + replace-with = "case ZincWorkerUtil.Scala3Version(" + }] +} disneystreaming_weaver-test { sbt.options=["-Dcommunitybuild.dualVersion=minor:+1"] } diff --git a/coordinator/src/main/resources/buildPlan.reference.conf b/coordinator/src/main/resources/buildPlan.reference.conf index 39448568..44912248 100644 --- a/coordinator/src/main/resources/buildPlan.reference.conf +++ b/coordinator/src/main/resources/buildPlan.reference.conf @@ -13,6 +13,9 @@ projects { overrides = {} } +// A fixed Scala `-source` setting to be applied to the project. +source-version = null + // Mode of tests execution one of disabled|compile-only|full tests = full diff --git a/coordinator/src/main/scala/core.scala b/coordinator/src/main/scala/core.scala index e0979af7..14967b7c 100644 --- a/coordinator/src/main/scala/core.scala +++ b/coordinator/src/main/scala/core.scala @@ -105,6 +105,7 @@ case class ProjectBuildConfig( sbt: SbtConfig = SbtConfig(), mill: MillConfig = MillConfig(), tests: TestingMode = TestingMode.Full, + sourceVersion: Option[String] = None, // We should use Option[Int] here, but json4s fails to resolve signature https://github.com/json4s/json4s/issues/1035 sourcePatches: List[SourcePatch] = Nil ) derives ConfigReader diff --git a/project-builder/build-revision.sh b/project-builder/build-revision.sh index f9c1aa33..89dcd547 100755 --- a/project-builder/build-revision.sh +++ b/project-builder/build-revision.sh @@ -29,7 +29,18 @@ scalaBinaryVersionMajor=`echo $scalaVersion | cut -d . -f 1` scalaBinaryVersionMinor=`echo $scalaVersion | cut -d . -f 2` echo "Scala binary version found: $scalaBinaryVersion" -commonAppendScalacOptions="-source:$scalaBinaryVersion-migration,-Wconf:msg=can be rewritten automatically under:s" +sourceVersion=`echo $projectConfig | jq -r '.sourceVersion // ""'` +sourceVersionSetting="" +if [[ -z "$sourceVersion" ]]; then + sourceVersion="$scalaBinaryVersion-migration" + sourceVersionSetting="-source:$sourceVersion" + echo "Implicitly using source version $sourceVersion" +else + echo "Using configured source version: $sourceVersion" + sourceVersionSetting="REQUIRE:-source:$sourceVersion" +fi + +commonAppendScalacOptions="$sourceVersionSetting,-Wconf:msg=can be rewritten automatically under:s" commonRemoveScalacOptions="-deprecation,-feature,-Xfatal-warnings,-Werror,MATCH:.*-Wconf.*any:e,-migration," echo "Would try to apply common scalacOption (best-effort, sbt/mill only):" echo "Append: $commonAppendScalacOptions" diff --git a/project-builder/shared/CommunityBuildCore.scala b/project-builder/shared/CommunityBuildCore.scala index bfeb7f35..3d10a0a2 100644 --- a/project-builder/shared/CommunityBuildCore.scala +++ b/project-builder/shared/CommunityBuildCore.scala @@ -349,32 +349,40 @@ object Scala3CommunityBuild { ): Seq[String] = { val (removeMatchSettings, removeSettings) = remove.partition { _.startsWith("MATCH:") } val matchPatterns = removeMatchSettings.map(_.stripPrefix("MATCH:")) + + val (required, standardAppendSettings) = append.partition(_.startsWith("REQUIRE:")) + val requiredAppendSettings = required.map(_.stripPrefix("REQUIRE:")) def isSourceVersion(v: String) = v.matches(raw"^-?-source(:(future|(\d\.\d+))(-migration)?)?") + def resolveSourceVersion(v: String): Option[String] = v.split(":").drop(1).headOption val SourceVersionPattern = raw"^((3\.\d+|future)(-migration)?)$$".r val definedSourceSetting = current.find(isSourceVersion) lazy val definedSourceVersion: Option[String] = - definedSourceSetting.flatMap(_.split(":").drop(1).headOption) // -source:version + definedSourceSetting.flatMap(resolveSourceVersion) // -source:version .orElse(current.find(SourceVersionPattern.findFirstIn(_).isDefined)) // -source version .flatMap(SourceVersionPattern.findFirstMatchIn(_)) .flatMap(m => Option(m.group(1))) - val forceFutureMigrationVersion = definedSourceVersion.contains("future") + lazy val requiredSourceVersion = requiredAppendSettings.find(isSourceVersion).flatMap(resolveSourceVersion) + val forceSourceVersion = definedSourceVersion.contains("future") || requiredSourceVersion.isDefined val appendSettings = { def excludeIf(setting: String, expr: Boolean, reason: => String) = { if(expr) logOnce(s"Would not apply setting `$setting`: $reason") expr } + val forcedAppendSettings: Seq[String] = Seq( - if(forceFutureMigrationVersion) Some("-source:future-migration") else None + if(forceSourceVersion) Some(s"-source:${requiredSourceVersion.getOrElse("future-migration")}") else None ).flatten - append.filterNot{ setting => + + standardAppendSettings.filterNot{ setting => excludeIf(setting, - isSourceVersion(setting) && (definedSourceSetting.nonEmpty || forceFutureMigrationVersion), + isSourceVersion(setting) && (definedSourceSetting.nonEmpty || forceSourceVersion), s"Project has predefined source version: ${definedSourceSetting.get}" ) } ++ forcedAppendSettings } + val normalizedExcludePatterns = (appendSettings ++ removeSettings).distinct.map { setting => Seq[String => String]( setting => if (setting.startsWith("--")) setting.tail else setting,