Hello,
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
//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?
- Below the classpath (of sourceSets.main?) is set to the configuration macDevOnly
classpath += configurations.macDevOnly
- 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?
Thanks!