@@ -21,10 +21,12 @@ lazy val sbtPluginFilePath: String =
21
21
def log (msg : String ) = println(Console .GREEN + msg + Console .RESET )
22
22
23
23
/** Executes shell command, returns false in case of error. */
24
- def exec (projectDir : Path , binary : String , arguments : String * ): Int =
24
+ def exec (projectDir : Path , binary : String , arguments : Seq [String ], environment : Map [String , String ]): Int =
25
+ import collection .JavaConverters ._
25
26
val command = binary +: arguments
26
27
log(command.mkString(" " ))
27
28
val builder = new ProcessBuilder (command : _* ).directory(projectDir.toFile).inheritIO()
29
+ builder.environment.putAll(environment.asJava)
28
30
val process = builder.start()
29
31
val exitCode = process.waitFor()
30
32
exitCode
@@ -40,6 +42,7 @@ sealed trait CommunityProject:
40
42
val dependencies : List [CommunityProject ]
41
43
val binaryName : String
42
44
val runCommandsArgs : List [String ] = Nil
45
+ val environment : Map [String , String ] = Map .empty
43
46
44
47
final val projectDir = communitybuildDir.resolve(" community-projects" ).resolve(project)
45
48
@@ -53,7 +56,7 @@ sealed trait CommunityProject:
53
56
log(s " Publishing $project" )
54
57
if publishCommand eq null then
55
58
throw RuntimeException (s " Publish command is not specified for $project. Project details: \n $this" )
56
- val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand): _* )
59
+ val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand), environment )
57
60
if exitCode != 0 then
58
61
throw RuntimeException (s " Publish command exited with code $exitCode for project $project. Project details: \n $this" )
59
62
published = true
@@ -63,11 +66,11 @@ sealed trait CommunityProject:
63
66
log(s " Documenting $project" )
64
67
if docCommand eq null then
65
68
throw RuntimeException (s " Doc command is not specified for $project. Project details: \n $this" )
66
- val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ docCommand): _* )
69
+ val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ docCommand), environment )
67
70
if exitCode != 0 then
68
71
throw RuntimeException (s " Doc command exited with code $exitCode for project $project. Project details: \n $this" )
69
72
70
- final def build (): Int = exec(projectDir, binaryName, buildCommands : _* )
73
+ final def build (): Int = exec(projectDir, binaryName, buildCommands, environment )
71
74
72
75
final def buildCommands = runCommandsArgs :+ testCommand
73
76
@@ -86,6 +89,7 @@ final case class MillCommunityProject(
86
89
// uncomment once mill is released
87
90
// if ignoreDocs then null else s"$baseCommand.docJar"
88
91
override val runCommandsArgs = List (" -i" , " -D" , s " dottyVersion= $compilerVersion" )
92
+ override val environment = Map (" MILL_VERSION" -> " 0.9.6-16-a5da34" )
89
93
90
94
final case class SbtCommunityProject (
91
95
project : String ,
@@ -102,12 +106,12 @@ final case class SbtCommunityProject(
102
106
scalacOptions.map(" \" " + _ + " \" " ).mkString(" List(" , " ," , " )" )
103
107
104
108
private val baseCommand =
105
- " clean; set logLevel in Global := Level.Error; set updateOptions in Global ~= (_.withLatestSnapshots(false)); "
106
- ++ (if scalacOptions.isEmpty then " " else s """ set scalacOptions in Global ++= $scalacOptionsString; """ )
109
+ " clean; set Global/ logLevel := Level.Error; set Global/updateOptions ~= (_.withLatestSnapshots(false)); "
110
+ ++ (if scalacOptions.isEmpty then " " else s """ set Global/scalacOptions ++= $scalacOptionsString; """ )
107
111
++ s " ++ $compilerVersion!; "
108
112
109
113
override val testCommand =
110
- """ set testOptions in Global += Tests.Argument(TestFramework("munit.Framework"), "+l"); """
114
+ """ set Global/testOptions += Tests.Argument(TestFramework("munit.Framework"), "+l"); """
111
115
++ s " $baseCommand$sbtTestCommand"
112
116
113
117
override val publishCommand =
@@ -124,7 +128,7 @@ final case class SbtCommunityProject(
124
128
case Some (ivyHome) => List (s " -Dsbt.ivy.home= $ivyHome" )
125
129
case _ => Nil
126
130
extraSbtArgs ++ sbtProps ++ List (
127
- " -sbt-version" , " 1.4.9 " ,
131
+ " -sbt-version" , " 1.5.0 " ,
128
132
" -Dsbt.supershell=false" ,
129
133
s " -Ddotty.communitybuild.dir= $communitybuildDir" ,
130
134
s " --addPluginSbtFile= $sbtPluginFilePath"
@@ -140,12 +144,12 @@ object projects:
140
144
141
145
private def forceDoc (projects : String * ) =
142
146
projects.map(project =>
143
- s """ ;set $project/Compile/doc/sources ++= ( $project/Compile/doc/tastyFiles).value ; $project/doc """
147
+ s """ ;set $project/Compile/doc/sources ++= ( $project/Compile/doc/dotty.tools.sbtplugin.DottyPlugin.autoImport. tastyFiles).value ; $project/doc """
144
148
).mkString(" " )
145
149
146
150
private def aggregateDoc (in : String )(projects : String * ) =
147
151
val tastyFiles =
148
- (in +: projects).map(p => s " ( $p/Compile/doc/tastyFiles).value " ).mkString(" ++ " )
152
+ (in +: projects).map(p => s " ( $p/Compile/doc/dotty.tools.sbtplugin.DottyPlugin.autoImport. tastyFiles).value " ).mkString(" ++ " )
149
153
s """ ;set $in/Compile/doc/sources ++= file("a.scala") +: ( $tastyFiles) ; $in/doc """
150
154
151
155
lazy val utest = MillCommunityProject (
@@ -512,7 +516,7 @@ object projects:
512
516
513
517
lazy val cats = SbtCommunityProject (
514
518
project = " cats" ,
515
- sbtTestCommand = " set scalaJSStage in Global := FastOptStage;buildJVM;validateAllJS" ,
519
+ sbtTestCommand = " set Global/scalaJSStage := FastOptStage;buildJVM;validateAllJS" ,
516
520
sbtPublishCommand = " catsJVM/publishLocal;catsJS/publishLocal" ,
517
521
dependencies = List (discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations),
518
522
scalacOptions = SbtCommunityProject .scalacOptions.filter(_ != " -Ysafe-init" ) // disable -Ysafe-init, due to -Xfatal-warning
0 commit comments