diff --git a/cli/scb-cli.scala b/cli/scb-cli.scala index 23247fc2..1266c73c 100755 --- a/cli/scb-cli.scala +++ b/cli/scb-cli.scala @@ -31,7 +31,7 @@ class FailedProjectException(msg: String) with NoStackTrace val communityBuildVersion = - sys.props.getOrElse("communitybuild.version", "v0.3.16") + sys.props.getOrElse("communitybuild.version", "v0.3.17") private val CBRepoName = "VirtusLab/community-build3" val projectBuilderUrl = s"https://raw.githubusercontent.com/$CBRepoName/master/project-builder" diff --git a/project-builder/mill/MillCommunityBuild.sc b/project-builder/mill/MillCommunityBuild.sc index db543db4..6ec91b6d 100644 --- a/project-builder/mill/MillCommunityBuild.sc +++ b/project-builder/mill/MillCommunityBuild.sc @@ -1,5 +1,6 @@ +package build import $ivy.`com.lihaoyi::upickle:3.0.0` -import $file.MillVersionCompat, MillVersionCompat.compat.{ +import MillVersionCompat.compat.{ CoursierModule, JavaModule, PublishModule, @@ -11,7 +12,7 @@ import $file.MillVersionCompat, MillVersionCompat.compat.{ Val, toZincWorker } -import $file.CommunityBuildCore, CommunityBuildCore.Scala3CommunityBuild.{ +import CommunityBuildCore.Scala3CommunityBuild.{ TestingMode => _, ProjectBuildConfig => _, ProjectOverrides => _, @@ -188,8 +189,8 @@ class MillTaskEvaluator()(implicit ctx: Ctx) extends TaskEvaluator[NamedTask] { // Main entry point for Mill community build // Evaluate tasks until first failure and publish report -def runBuild(configJson: String, targets: Seq[String])(implicit ctx: Ctx) = { - +def runBuild(configJson: String, projectDir: String, targets: Seq[String])(implicit ctx: Ctx) = { + val outputDir: os.Path = os.Path.expandUser(projectDir) / os.up println(s"Build config: ${configJson}") val config = read[ProjectBuildConfig](configJson) println(s"Parsed config: ${config}") @@ -305,7 +306,6 @@ def runBuild(configJson: String, targets: Seq[String])(implicit ctx: Ctx) = { |************************" |""".stripMargin) - val outputDir = os.pwd / os.up os.write.over(outputDir / "build-summary.txt", buildSummary.toJson) val failedModules = projectsBuildResults diff --git a/project-builder/mill/build.sh b/project-builder/mill/build.sh index a4a9e95b..2233f47b 100755 --- a/project-builder/mill/build.sh +++ b/project-builder/mill/build.sh @@ -25,6 +25,7 @@ echo Project projectConfig: $projectConfig echo '##################################' scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +projectDir=$PWD/$repoDir cd $repoDir @@ -42,7 +43,7 @@ millSettings=( function tryBuild() { mill=$1 echo "Try build using $mill" - $mill "${millSettings[@]}" runCommunityBuild "$scalaVersion" "${projectConfig}" "${targets[@]}" + $mill "${millSettings[@]}" runCommunityBuild --scalaVersion="$scalaVersion" --configJson="${projectConfig}" --projectDir=$projectDir "${targets[@]}" } diff --git a/project-builder/mill/compat/0.12.sc b/project-builder/mill/compat/0.12.sc new file mode 100644 index 00000000..40401993 --- /dev/null +++ b/project-builder/mill/compat/0.12.sc @@ -0,0 +1,16 @@ +package build +// Same as 0.11 +object compat { + type CoursierModule = mill.scalalib.CoursierModule + type JavaModule = mill.scalalib.JavaModule + type PublishModule = mill.scalalib.PublishModule + type ScalaModule = mill.scalalib.ScalaModule + type TestModule = mill.scalalib.TestModule + type ZincWorkerModule = mill.scalalib.ZincWorkerModule + type TestResult = mill.testrunner.TestResult + type Val = mill.api.Val + val Val = mill.api.Val + type Task[+T] = mill.Task[T] + + def toZincWorker(v: ZincWorkerModule) = mill.define.ModuleRef(v) +} \ No newline at end of file diff --git a/project-builder/mill/prepare-project.sh b/project-builder/mill/prepare-project.sh index e954a022..6c1082eb 100755 --- a/project-builder/mill/prepare-project.sh +++ b/project-builder/mill/prepare-project.sh @@ -16,7 +16,8 @@ export OPENCB_PROJECT_DIR=$repoDir scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -MILL_0_11=0.11.6 +MILL_0_12="0.12.0-RC2" +MILL_0_11=0.11.12 MILL_0_10=0.10.15 MILL_0_9=0.9.12 RESOLVE="resolve _" @@ -39,7 +40,7 @@ else fi if [[ "$millVersion" == "" ]]; then echo "Trying one of predefiend mill versions" - for v in $MILL_0_11 $MILL_0_10 $MILL_0_9; do + for v in $MILL_0_12 $MILL_0_11 $MILL_0_10 $MILL_0_9; do if `${scriptDir}/millw --mill-version $v $RESOLVE > /dev/null 2>/dev/null`; then echo "Successfully applied build using mill $v" millVersion=$v @@ -63,8 +64,8 @@ echo "Detected mill version=$millVersion, binary version: $millBinaryVersion" millBinaryVersionMajor=`echo $millVersion | cut -d . -f 1` millBinaryVersionMinor=`echo $millVersion | cut -d . -f 2` # 0.9 is the minimal verified supported version -# 0.12 does not exit yet -if [[ "$millBinaryVersionMajor" -ne "0" || ( "$millBinaryVersionMinor" -lt "9" || "$millBinaryVersionMinor" -gt "11" ) ]]; then +# 0.13 does not exit yet +if [[ "$millBinaryVersionMajor" -ne "0" || ( "$millBinaryVersionMinor" -lt "9" || "$millBinaryVersionMinor" -gt "12" ) ]]; then echo "Unsupported mill version" exit 1 fi @@ -98,14 +99,18 @@ fi # Rename build.sc to build.scala - Scalafix does ignore .sc files # Use scala 3 dialect to allow for top level defs -adaptedFiles=($PWD/build.sc ) +millBuildExt="mill" +if [[ "$millBinaryVersionMajor" -eq "0" && "$millBinaryVersionMinor" -le "11" ]]; then + millBuildExt=sc +fi +adaptedFiles=( $PWD/build.${millBuildExt} ) if [[ -d ./project ]]; then - adaptedFiles+=(`find ./project -type f -name "*.sc"`) + adaptedFiles+=(`find ./project -type f -name "*.$millBuildExt"`) fi -for scFile in "${adaptedFiles[@]}"; do - echo "Apply scalafix rules to $scFile" - scalaFile="${scFile%.sc}.scala" - cp $scFile $scalaFile +for buildFile in "${adaptedFiles[@]}"; do + echo "Apply scalafix rules to $buildFile" + scalaFile="${buildFile%.$millBuildExt}.scala" + cp $buildFile $scalaFile scalafix \ --rules file:${scriptDir}/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala \ --files $scalaFile \ @@ -113,15 +118,28 @@ for scFile in "${adaptedFiles[@]}"; do --syntactic \ --settings.Scala3CommunityBuildMillAdapter.targetScalaVersion "$scalaVersion" \ --settings.Scala3CommunityBuildMillAdapter.millBinaryVersion "$millBinaryVersion" \ - --scala-version 3.1.0 > ${scFile}.adapted \ - && mv ${scFile}.adapted $scFile \ - || (echo "Failed to adapted $scFile, ignoring changes"; cat ${scFile}.adapted; rm -f ${scFile}.adapted) + --scala-version 3.1.0 > ${buildFile}.adapted \ + && mv ${buildFile}.adapted $buildFile \ + || (echo "Failed to adapt $buildFile, ignoring changes"; cat ${buildFile}.adapted; rm -f ${buildFile}.adapted) rm $scalaFile done for f in "${adaptedFiles[@]}"; do dir="$(dirname $(realpath "$f"))" - ln -fs $scriptDir/../shared/CommunityBuildCore.scala ${dir}/CommunityBuildCore.sc - ln -fs $scriptDir/MillCommunityBuild.sc ${dir}/MillCommunityBuild.sc - ln -fs $scriptDir/compat/$millBinaryVersion.sc ${dir}/MillVersionCompat.sc + cp $scriptDir/MillCommunityBuild.sc ${dir}/MillCommunityBuild.$millBuildExt + cp $scriptDir/compat/$millBinaryVersion.sc ${dir}/MillVersionCompat.$millBuildExt + + if [[ "$millBinaryVersionMajor" -gt "0" || "$millBinaryVersionMinor" -ge "12" ]]; then + # Compat for Mill 0.12+ sources + echo "package build" | cat - $scriptDir/../shared/CommunityBuildCore.scala > ${dir}/CommunityBuildCore.$millBuildExt + else + # Compat for Mill 0.11+ sources + cp $scriptDir/../shared/CommunityBuildCore.scala ${dir}/CommunityBuildCore.$millBuildExt + for fileCopy in ${dir}/CommunityBuildCore.$millBuildExt ${dir}/MillCommunityBuild.$millBuildExt ${dir}/MillVersionCompat.$millBuildExt; do + scala-cli $scriptDir/../shared/searchAndReplace.scala -- $fileCopy "package build\n" "" + scala-cli $scriptDir/../shared/searchAndReplace.scala -- $fileCopy "import CommunityBuildCore." "import \$file.CommunityBuildCore, CommunityBuildCore." + scala-cli $scriptDir/../shared/searchAndReplace.scala -- $fileCopy "import MillVersionCompat." "import \$file.MillVersionCompat, MillVersionCompat." + done + fi + done diff --git a/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala b/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala index 143979ae..12178c4f 100644 --- a/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala +++ b/project-builder/mill/scalafix/rules/src/main/scala/fix/Scala3CommunityBuildMillAdapter.scala @@ -54,7 +54,7 @@ class Scala3CommunityBuildMillAdapter( "Scala_3", "scala_3", "scala", - "Scala" + // "Scala" - explicitly ignored ) val Scala3Literal = raw""""3.\d+.\d+(?:-RC\d+)?"""".r diff --git a/project-builder/sbt/CommunityBuildPlugin.scala b/project-builder/sbt/CommunityBuildPlugin.scala index 0804f5d5..4d7d0f5a 100644 --- a/project-builder/sbt/CommunityBuildPlugin.scala +++ b/project-builder/sbt/CommunityBuildPlugin.scala @@ -10,7 +10,7 @@ import scala.collection.JavaConverters._ import scala.collection.mutable import Scala3CommunityBuild._ -import Scala3CommunityBuild.Utils._ +import Scala3CommunityBuild.Utils.{LibraryDependency, logOnce} import TaskEvaluator.EvalResult class SbtTaskEvaluator(val project: ProjectRef, private var state: State) @@ -94,13 +94,12 @@ object CommunityBuildPlugin extends AutoPlugin { private def extraLibraryDependencies( buildScalaVersion: Option[String], projectScalaVersion: String - ) = + ): Seq[ModuleID] = if (!projectScalaVersion.startsWith("3.")) Nil else - Scala3CommunityBuild.Utils - .extraLibraryDependencies(buildScalaVersion.getOrElse(projectScalaVersion)) + Utils.extraLibraryDependencies(buildScalaVersion.getOrElse(projectScalaVersion)) .map { - case Scala3CommunityBuild.Utils.LibraryDependency( + case LibraryDependency( org, artifact, version, @@ -194,7 +193,7 @@ object CommunityBuildPlugin extends AutoPlugin { if (scalaVersion.startsWith("3.")) remove else remove ++ appendScala3Exclusive - Scala3CommunityBuild.Utils.mapScalacOptions( + Utils.mapScalacOptions( current = currentScalacOptions, append = filteredAppend, remove = filteredRemove @@ -420,7 +419,7 @@ object CommunityBuildPlugin extends AutoPlugin { case "*%*" :: _ => originalModuleIds.keys.toSeq case ids => ids } - val filteredIds = filterTargets(idsToUse, config.projects.exclude.map(_.r)) + val filteredIds = Utils.filterTargets(idsToUse, config.projects.exclude.map(_.r)) println("Starting build...") // Find projects that matches maven diff --git a/scripts/bisect.scala b/scripts/bisect.scala index 703b6fac..3f2b2d7f 100755 --- a/scripts/bisect.scala +++ b/scripts/bisect.scala @@ -9,7 +9,7 @@ import java.nio.file.attribute.PosixFilePermissions import java.nio.charset.StandardCharsets import java.nio.file._ -val communityBuildVersion = "v0.3.16" +val communityBuildVersion = "v0.3.17" @main def run(args: String*): Unit = val config = scopt.OParser diff --git a/scripts/build-all.sh b/scripts/build-all.sh index daa37a2c..21aba87c 100755 --- a/scripts/build-all.sh +++ b/scripts/build-all.sh @@ -7,7 +7,7 @@ if [ $# -ne 1 ]; then fi VERSION="$1" -export PREV_CB_VERSION="v0.3.15" +export PREV_CB_VERSION="v0.3.16" javaDefault=11 javaAccessoryVersions=(8 17 21)