10
10
lazy val root = project
11
11
.in(file(" ." ))
12
12
.aggregate(profiledb, plugin, profilingSbtPlugin)
13
- .settings(Seq (
14
- name := " profiling-root" ,
15
- publish := {},
16
- publishLocal := {},
17
- watchSources ++=
18
- (watchSources in plugin).value ++
19
- (watchSources in profiledb).value ++
20
- (watchSources in integrations).value
21
- ))
13
+ .settings(
14
+ Seq (
15
+ name := " profiling-root" ,
16
+ publish := {},
17
+ publishLocal := {},
18
+ watchSources ++=
19
+ (watchSources in plugin).value ++
20
+ (watchSources in profiledb).value ++
21
+ (watchSources in integrations).value
22
+ )
23
+ )
22
24
23
25
import build .BuildImplementation .BuildDefaults
24
26
import com .trueaccord .scalapb .compiler .Version .scalapbVersion
@@ -44,21 +46,24 @@ lazy val plugin = project
44
46
),
45
47
libraryDependencies ++= testDependencies,
46
48
testOptions in Test ++= List (Tests .Argument (" -v" ), Tests .Argument (" -s" )),
49
+ allDepsForCompilerPlugin := {
50
+ val jar = (Keys .packageBin in Compile ).value
51
+ val profileDbJar = (Keys .`package` in Compile in profiledb).value
52
+ val absoluteJars = List (jar, profileDbJar).classpath
53
+ val pluginDeps = (managedClasspath in Compile ).value
54
+ (absoluteJars ++ pluginDeps)
55
+ },
47
56
// Make the tests to compile with the plugin
48
57
optionsForSourceCompilerPlugin := {
49
- val jar = (Keys .`package` in Compile ).value
50
- val profileDbJar = (Keys .`package` in Compile in profiledb).value
51
- val absoluteJars = List (jar, profileDbJar).map(_.getAbsolutePath)
52
- // Should we filter out all the scala artifacts?
53
- val pluginDeps = (managedClasspath in Compile ).value.files.toList
54
- val pluginAndDeps = (absoluteJars ++ pluginDeps).mkString(" :" )
58
+ val jar = (Keys .packageBin in Compile ).value
59
+ val pluginAndDeps = allDepsForCompilerPlugin.value.map(_.data.getAbsolutePath()).mkString(" :" )
55
60
val addPlugin = " -Xplugin:" + pluginAndDeps
56
61
val dummy = " -Jdummy=" + jar.lastModified
57
62
// Enable debugging information when necessary
58
63
val debuggingPluginOptions =
59
64
if (! enableStatistics.value) Nil
60
- else List (" -Ystatistics" )// , "-P:scalac-profiling:show-profiles")
61
- // else List("-Xlog-implicits", "-Ystatistics:typer")
65
+ else List (" -Ystatistics" ) // , "-P:scalac-profiling:show-profiles")
66
+ // else List("-Xlog-implicits", "-Ystatistics:typer")
62
67
Seq (addPlugin, dummy) ++ debuggingPluginOptions
63
68
},
64
69
scalacOptions in Test ++= optionsForSourceCompilerPlugin.value,
@@ -78,14 +83,13 @@ lazy val plugin = project
78
83
case (2 , y) if y >= 12 => new File (scalaSource.value.getPath + " -2.12" )
79
84
}.toList
80
85
}),
81
- packageBin in Compile := (assembly in Compile ).value,
86
+ Keys .`package` in Compile := (assembly in Compile ).value,
82
87
test in assembly := {},
83
88
assemblyOption in assembly :=
84
89
(assemblyOption in assembly).value
85
90
.copy(includeScala = false , includeDependency = true )
86
91
)
87
92
88
-
89
93
// Trick to copy profiledb with Scala 2.11.11 so that vscode can depend on it
90
94
lazy val profiledb211 = profiledb
91
95
.copy(id = " profiledb-211" )
@@ -112,10 +116,13 @@ lazy val vscodeIntegration = project
112
116
publish := (publish in VscodeImplementation ).dependsOn(publish in profiledb211).value,
113
117
publishLocal :=
114
118
(publishLocal in VscodeImplementation ).dependsOn(publishLocal in profiledb211).value,
115
- publishExtension := (Def .task {
116
- val scalaExtensionDir = (baseDirectory in VscodeScala ).value./ (" scala" )
117
- sys.process.Process (Seq (" vsce" , " package" ), scalaExtensionDir).!!
118
- }).dependsOn(publishLocal).value
119
+ publishExtension := (Def
120
+ .task {
121
+ val scalaExtensionDir = (baseDirectory in VscodeScala ).value./ (" scala" )
122
+ sys.process.Process (Seq (" vsce" , " package" ), scalaExtensionDir).!!
123
+ })
124
+ .dependsOn(publishLocal)
125
+ .value
119
126
)
120
127
121
128
lazy val profilingSbtPlugin = project
@@ -141,16 +148,19 @@ lazy val integrations = project
141
148
scalaHome := BuildDefaults .setUpScalaHome.value,
142
149
parallelExecution in Test := false ,
143
150
scalacOptions ++= BuildDefaults .scalacProfilingScalacOptions.value,
144
- clean := Def .sequential(
145
- clean,
146
- (clean in Test in CirceTests ),
147
- (clean in Test in MonocleTests ),
148
- (clean in Test in MonocleExample ),
149
- (clean in Compile in ScalatestCore ),
150
- (clean in Compile in MagnoliaTests ),
151
- (clean in ScalacCompiler )
152
- ).value,
153
- test := Def .sequential(
151
+ clean := Def
152
+ .sequential(
153
+ clean,
154
+ (clean in Test in CirceTests ),
155
+ (clean in Test in MonocleTests ),
156
+ (clean in Test in MonocleExample ),
157
+ (clean in Compile in ScalatestCore ),
158
+ (clean in Compile in MagnoliaTests ),
159
+ (clean in ScalacCompiler )
160
+ )
161
+ .value,
162
+ test := Def
163
+ .sequential(
154
164
(showScalaInstances in ThisBuild ),
155
165
(profilingWarmupCompiler in Compile ), // Warmup example, classloader is the same for all
156
166
(compile in Compile ),
@@ -160,54 +170,80 @@ lazy val integrations = project
160
170
(compile in Compile in ScalatestCore ),
161
171
(compile in Compile in MagnoliaTests ),
162
172
(compile in ScalacCompiler )
163
- ).value,
173
+ )
174
+ .value,
164
175
testOnly := Def .inputTaskDyn {
165
176
val keywords = keywordsSetting.parsed
166
177
val emptyAnalysis = Def .task(sbt.inc.Analysis .Empty )
167
178
val CirceTask = Def .taskDyn {
168
- if (keywords.contains(Keywords .Circe )) Def .sequential(
169
- (compile in Test in CirceTests )
170
- ) else emptyAnalysis
179
+ if (keywords.contains(Keywords .Circe ))
180
+ Def .sequential(
181
+ (compile in Test in CirceTests )
182
+ )
183
+ else emptyAnalysis
171
184
}
172
185
val IntegrationTask = Def .taskDyn {
173
- if (keywords.contains(Keywords .Integration )) Def .sequential(
174
- (compile in Compile )
175
- ) else emptyAnalysis
186
+ if (keywords.contains(Keywords .Integration ))
187
+ Def .sequential(
188
+ (compile in Compile )
189
+ )
190
+ else emptyAnalysis
176
191
}
177
192
val MonocleTask = Def .taskDyn {
178
- if (keywords.contains(Keywords .Monocle )) Def .sequential(
179
- (compile in Test in MonocleTests ),
180
- (compile in Test in MonocleExample )
181
- ) else emptyAnalysis
193
+ if (keywords.contains(Keywords .Monocle ))
194
+ Def .sequential(
195
+ (compile in Test in MonocleTests ),
196
+ (compile in Test in MonocleExample )
197
+ )
198
+ else emptyAnalysis
182
199
}
183
200
val ScalatestTask = Def .taskDyn {
184
- if (keywords.contains(Keywords .Scalatest )) Def .sequential(
185
- (compile in Compile in ScalatestCore ),
186
- (compile in Compile in ScalatestTests )
187
- ) else emptyAnalysis
201
+ if (keywords.contains(Keywords .Scalatest ))
202
+ Def .sequential(
203
+ (compile in Compile in ScalatestCore ),
204
+ (compile in Compile in ScalatestTests )
205
+ )
206
+ else emptyAnalysis
188
207
}
189
208
val ScalacTask = Def .taskDyn {
190
- if (keywords.contains(Keywords .Scalac )) Def .sequential(
191
- (compile in Compile in ScalacCompiler )
192
- ) else emptyAnalysis
209
+ if (keywords.contains(Keywords .Scalac ))
210
+ Def .sequential(
211
+ (compile in Compile in ScalacCompiler )
212
+ )
213
+ else emptyAnalysis
193
214
}
194
215
val BetterFilesTask = Def .taskDyn {
195
- if (keywords.contains(Keywords .BetterFiles )) Def .sequential(
196
- (compile in Compile in BetterFilesCore )
197
- ) else emptyAnalysis
216
+ if (keywords.contains(Keywords .BetterFiles ))
217
+ Def .sequential(
218
+ (compile in Compile in BetterFilesCore )
219
+ )
220
+ else emptyAnalysis
198
221
}
199
222
val ShapelessTask = Def .taskDyn {
200
- if (keywords.contains(Keywords .Shapeless )) Def .sequential(
201
- (compile in Compile in ShapelessCore ),
202
- (compile in Test in ShapelessCore )
203
- ) else emptyAnalysis
223
+ if (keywords.contains(Keywords .Shapeless ))
224
+ Def .sequential(
225
+ (compile in Compile in ShapelessCore ),
226
+ (compile in Test in ShapelessCore )
227
+ )
228
+ else emptyAnalysis
204
229
}
205
230
val MagnoliaTask = Def .taskDyn {
206
- if (keywords.contains(Keywords .Magnolia )) Def .sequential(
207
- (compile in Compile in MagnoliaTests )
208
- ) else emptyAnalysis
231
+ if (keywords.contains(Keywords .Magnolia ))
232
+ Def .sequential(
233
+ (compile in Compile in MagnoliaTests )
234
+ )
235
+ else emptyAnalysis
209
236
}
210
- Def .sequential(CirceTask , MonocleTask , IntegrationTask , ScalatestTask , ScalacTask , BetterFilesTask , ShapelessTask , MagnoliaTask )
237
+ Def .sequential(
238
+ CirceTask ,
239
+ MonocleTask ,
240
+ IntegrationTask ,
241
+ ScalatestTask ,
242
+ ScalacTask ,
243
+ BetterFilesTask ,
244
+ ShapelessTask ,
245
+ MagnoliaTask
246
+ )
211
247
}.evaluated
212
248
)
213
249
0 commit comments