@@ -27,16 +27,32 @@ final testTasks = scalaVersions.collect { scalaLibrary ->
2727 def (major, minor) = version. split(' _' ). collect(Integer . &valueOf)
2828 final javaConcatenation = major > 2 || minor > 11 // after 2.11 scala uses java.lang.StringBuilder to perform concatenation
2929
30- final implementationConfiguration = configurations. create(" ${ version} Implementation" ) {
30+ final customSourceSet = sourceSets. create(" ${ version} " ) {
31+ scala {
32+ srcDirs = [' src/test/scala' ]
33+ }
34+ }
35+
36+ final implementationConfiguration = configurations. named(customSourceSet. implementationConfigurationName) {
3137 canBeConsumed = false
3238 canBeResolved = false
3339 canBeDeclared = true
3440 }
35- final classPathConfiguration = configurations. create(" ${ version} CompileClasspath" ) {
41+
42+ final classPathConfiguration = configurations. named(customSourceSet. compileClasspathConfigurationName) {
3643 canBeConsumed = false
3744 canBeResolved = true
3845 canBeDeclared = false
39- extendsFrom(implementationConfiguration)
46+ extendsFrom(implementationConfiguration. get())
47+ customSourceSet. compileClasspath + = it
48+ }
49+
50+ tasks. named(customSourceSet. getCompileTaskName(" scala" ), ScalaCompile ) {
51+ // Despite the compatibility matrix, scala compiler doesn't properly
52+ // ger the right compiler flags with JDK11 toolchain. Using 8 works.
53+ // * https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html
54+ // * https://github.com/gradle/gradle/issues/19456
55+ configureCompiler(it, 8 )
4056 }
4157
4258 dependencies { handler ->
@@ -47,26 +63,19 @@ final testTasks = scalaVersions.collect { scalaLibrary ->
4763 }
4864 }
4965
50- final customSourceSet = sourceSets. create(" ${ version} " ) {
51- scala {
52- srcDirs = [' src/test/scala' ]
53- compileClasspath + = classPathConfiguration
54- }
55- }
56-
5766 return tasks. register(" test$version " , Test ) {
5867 classpath = classpath
5968 .filter { ! it. toString(). contains(' scala-library' ) } // exclude default scala-library
6069 .minus(files(sourceSets. test. scala. classesDirectory)) // exclude default /build/classes/scala/test folder
6170 .plus(customSourceSet. output. classesDirs) // add /build/classes/scala/${version} folder
62- .plus(classPathConfiguration) // add new scala-library configuration
71+ .plus(classPathConfiguration. get()) // add new scala-library configuration
6372 systemProperty(' uses.java.concat' , javaConcatenation)
6473 dependsOn(tasks. named(" compile${ version.capitalize()} Scala" ))
6574 group = ' verification'
6675 }
6776}
6877
69- tasks. named(' test' , Test ). configure {
78+ tasks. named(' test' , Test ) {
7079 systemProperty(' uses.java.concat' , false ) // version 2.10.7 does not use java concatenation
7180 finalizedBy(testTasks)
7281}
0 commit comments