Why does classpath += configurations.some_configuration work?

I found this example on medium.com

There are amongst otheres the lines

// build.gradle
classpath += configurations.macDevOnly    
classpath += sourceSets.devOnly.runtimeClasspath

Here is the whole code

configurations {
  macDevOnly.extendsFrom(devOnly)  //descriptive conf name

sourceSets {
    devOnly {
        kotlin.srcDirs = ['dev-src']
        resources.srcDirs = ['dev-res']
        java.srcDirs = [] // disable java devOnly dirs
        compileClasspath += sourceSets.main.runtimeClasspath

dependencies {
   devOnly platform("io.micronaut:micronaut-bom:$micronautVersion")
   macDevOnly "io.micronaut:micronaut-runtime-osx"
   devOnly "net.java.dev.jna:jna"
   devOnly "io.methvin:directory-watcher"  

run.classpath += configurations.macDevOnly

tasks.withType(JavaExec) {
    classpath += configurations.devOnly    //add to classpath when current platform is macOS
    if (OperatingSystem.current().isMacOsX())
        classpath += configurations.macDevOnly    
        classpath += sourceSets.devOnly.runtimeClasspath

Why does the assignment of the classpaths above work?

  1. Below the classpath (of sourceSets.main?) is set to the configuration macDevOnly
classpath += configurations.macDevOnly
  1. For the sourceSet devOnly there is only the variable compileClasspath but not runtimeClasspath set.
    2.1) But then it is set below the runtimeClasspath of the sourceSet devOnly is set.
classpath += sourceSets.devOnly.runtimeClasspath

Then another question:
There is a sourceSet and a Configuration with the same name of “devOnly”. How is this resolved?