In a project I have multiple sourceSets:
sourceSets {
main {
java {
srcDir 'src'
}
}
other {
java {
srcDir 'other'
}
}
test {
java {
srcDir 'test'
}
}
}
Code in ‘src’ use code from ‘other’ therefore I need:
dependencies {
compile sourceSets.other.output
}
Now in a plugin (.groovy) I would like to set this dependency dynamically. I have tried:
def compileConf = project.getConfigurations().findByName("compile")
compileConf.getDependencies().add("sourceSets.other.output")
¨ which gives:
java.lang.String cannot be cast to org.gradle.api.artifacts.Dependency
Is it possible to do it with a Closure instead?