# Why does classpath += configurations.some\_configuration work?

**URL:** <https://discuss.gradle.org/t/why-does-classpath-configurations-some-configuration-work/42480>\
**Category:** Help/Discuss\
**Created:** [March 21, 2022, 1:28pm UTC](https://discuss.gradle.org/t/why-does-classpath-configurations-some-configuration-work/42480 "2022-03-21T13:28:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vonSpotz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vonspotz/32/9779_2.png) [@vonSpotz](https://discuss.gradle.org/u/vonSpotz)\
**Post date:** [March 21, 2022, 1:28pm UTC](https://discuss.gradle.org/t/why-does-classpath-configurations-some-configuration-work/42480/1 "2022-03-21T13:28:23Z")

</div>

Hello,  
I found this example on [medium.com](http://medium.com)

There are amongst otheres the lines

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

Here is the whole code

```gradle
//build.gradle
configurations {
  devOnly  
  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
    jvmArgs('-noverify',
            '-XX:TieredStopAtLevel=1',
            '-Dcom.sun.management.jmxremote',
            "-Dlogback.configurationFile=logback-dev.xml",
            '-Dmicronaut.environments=dev')
}
```

Why does the assignment of the classpaths above work?

1. Below the classpath (of sourceSets.main?) is set to the _configuration_ macDevOnly

```gradle
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.

```gradle
classpath += sourceSets.devOnly.runtimeClasspath
```

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

Thanks!
