@@ -210,80 +210,50 @@ class ScoveragePlugin implements Plugin<PluginAware> {
210
210
}
211
211
}
212
212
213
- if (project. hasProperty(SCOVERAGE_COMPILE_ONLY_PROPERTY )) {
214
- project. logger. info(" Making scoverage compilation the primary compilation task (instead of compileScala)" )
215
-
216
- originalCompileTask. enabled = false ;
217
- compileTask. destinationDirectory = originalCompileTask. destinationDirectory
218
-
219
- project. getTasks(). each {
220
- if (recursiveDependenciesOf(it, true ). contains(originalCompileTask)) {
221
- it. dependsOn(compileTask)
222
- }
223
- }
224
-
225
- // make this project's scoverage compilation depend on scoverage compilation of any other project
226
- // which this project depends on its normal compilation
227
- def originalCompilationDependencies = recursiveDependenciesOf(compileTask, false ). findAll {
228
- it instanceof ScalaCompile
229
- }
230
- originalCompilationDependencies. each {
231
- def dependencyProjectCompileTask = it. project. tasks. findByName(COMPILE_NAME )
232
- def dependencyProjectReportTask = it. project. tasks. findByName(REPORT_NAME )
233
- if (dependencyProjectCompileTask != null ) {
234
- compileTask. dependsOn(dependencyProjectCompileTask)
235
- // we don't want this project's tests to affect the other project's report
236
- testTasks. each {
237
- it. mustRunAfter(dependencyProjectReportTask)
238
- }
239
- }
213
+ compileTask. configure {
214
+ doFirst {
215
+ destinationDir. deleteDir()
240
216
}
241
- } else {
242
- compileTask. configure {
243
- doFirst {
244
- destinationDir. deleteDir()
245
- }
246
217
247
- // delete non-instrumented classes by comparing normally compiled classes to those compiled with scoverage
248
- doLast {
249
- project. logger. info(" Deleting classes compiled by scoverage but non-instrumented (identical to normal compilation)" )
250
- def originalCompileTaskName = project. sourceSets. getByName(SourceSet . MAIN_SOURCE_SET_NAME )
251
- .getCompileTaskName(" scala" )
252
- def originalDestinationDirectory = project. tasks[originalCompileTaskName]. destinationDirectory
253
- def originalDestinationDir = originalDestinationDirectory. get(). asFile
254
- def destinationDir = destinationDirectory. get(). asFile
255
-
256
-
257
- def findFiles = { File dir , Closure<Boolean > condition = null ->
258
- def files = []
259
-
260
- if (dir. exists()) {
261
- dir. eachFileRecurse(FILES ) { f ->
262
- if (condition == null || condition(f)) {
263
- def relativePath = dir. relativePath(f)
264
- files << relativePath
265
- }
218
+ // delete non-instrumented classes by comparing normally compiled classes to those compiled with scoverage
219
+ doLast {
220
+ project. logger. info(" Deleting classes compiled by scoverage but non-instrumented (identical to normal compilation)" )
221
+ def originalCompileTaskName = project. sourceSets. getByName(SourceSet . MAIN_SOURCE_SET_NAME )
222
+ .getCompileTaskName(" scala" )
223
+ def originalDestinationDirectory = project. tasks[originalCompileTaskName]. destinationDirectory
224
+ def originalDestinationDir = originalDestinationDirectory. get(). asFile
225
+ def destinationDir = destinationDirectory. get(). asFile
226
+
227
+
228
+ def findFiles = { File dir , Closure<Boolean > condition = null ->
229
+ def files = []
230
+
231
+ if (dir. exists()) {
232
+ dir. eachFileRecurse(FILES ) { f ->
233
+ if (condition == null || condition(f)) {
234
+ def relativePath = dir. relativePath(f)
235
+ files << relativePath
266
236
}
267
237
}
268
-
269
- files
270
238
}
271
239
272
- def isSameFile = { String relativePath ->
273
- def fileA = new File (originalDestinationDir, relativePath)
274
- def fileB = new File (destinationDir, relativePath)
275
- FileUtils . contentEquals(fileA, fileB)
276
- }
240
+ files
241
+ }
277
242
278
- def originalClasses = findFiles(originalDestinationDir)
279
- def identicalInstrumentedClasses = findFiles(destinationDir, { f ->
280
- def relativePath = destinationDir. relativePath(f )
281
- originalClasses . contains(relativePath) && isSameFile(relativePath )
282
- })
243
+ def isSameFile = { String relativePath ->
244
+ def fileA = new File (originalDestinationDir, relativePath)
245
+ def fileB = new File ( destinationDir, relativePath)
246
+ FileUtils . contentEquals(fileA, fileB )
247
+ }
283
248
284
- identicalInstrumentedClasses. each { f ->
285
- Files . deleteIfExists(destinationDir. toPath(). resolve(f))
286
- }
249
+ def originalClasses = findFiles(originalDestinationDir)
250
+ def identicalInstrumentedClasses = findFiles(destinationDir, { f ->
251
+ def relativePath = destinationDir. relativePath(f)
252
+ originalClasses. contains(relativePath) && isSameFile(relativePath)
253
+ })
254
+
255
+ identicalInstrumentedClasses. each { f ->
256
+ Files . deleteIfExists(destinationDir. toPath(). resolve(f))
287
257
}
288
258
}
289
259
}
0 commit comments