@@ -301,36 +301,21 @@ class ScoveragePlugin implements Plugin<PluginAware> {
301
301
}
302
302
303
303
private String resolveScalaVersion (Project project ) {
304
- def scalaVersion = null
305
304
306
- def configurations = [
307
- project. configurations. compile,
308
- project. configurations. compileOnly,
309
- project. configurations. implementation
310
- ]
311
- def dependencies = configurations. collectMany { it. dependencies }
305
+ def resolvedDependencies = project. configurations. compileClasspath. resolvedConfiguration. firstLevelModuleDependencies
312
306
313
- def scalaLibrary = dependencies . find {
314
- it. group == " org.scala-lang" && it. name == " scala-library"
307
+ def scalaLibrary = resolvedDependencies . find {
308
+ it. moduleGroup == " org.scala-lang" && it. moduleName == " scala-library"
315
309
}
316
310
317
- if (scalaLibrary != null ) {
318
- scalaVersion = scalaLibrary. version
319
- }
320
-
321
- if (scalaVersion == null && project. pluginManager. hasPlugin(" io.spring.dependency-management" )) {
322
- scalaVersion = project. dependencyManagement. compile. managedVersions[" org.scala-lang:scala-library" ]
323
- }
324
-
325
- if (scalaVersion == null ) {
311
+ if (scalaLibrary == null ) {
326
312
project. logger. info(" No scala library detected. Using property 'scoverageScalaVersion'" )
327
- scalaVersion = project. extensions. scoverage. scoverageScalaVersion. get()
313
+ return project. extensions. scoverage. scoverageScalaVersion. get()
328
314
} else {
329
315
project. logger. info(" Detected scala library in compilation classpath" )
330
- scalaVersion = scalaVersion. substring(0 , scalaVersion. lastIndexOf(" ." ))
316
+ def fullScalaVersion = scalaLibrary. moduleVersion
317
+ return fullScalaVersion. substring(0 , fullScalaVersion. lastIndexOf(" ." ))
331
318
}
332
-
333
- return scalaVersion
334
319
}
335
320
336
321
private Set<? extends Task > recursiveDependenciesOf (Task task ) {
0 commit comments