That's quite easy, you need to create a new configuration
configurations {
compileOnly
}
than add the dependencies of this configuration to the source sets (otherwise compilation fails)
sourceSets {
main {
compileClasspath += configurations.compileOnly
}
test {
compileClasspath += configurations.compileOnly
}
}
The last thing is to tell your IDE that their is something additional, for example for Idea you have to use this
idea {
module {
scopes.PROVIDED.plus += configurations.compileOnly
}
}
Now you can use the compileOnly
configuration in your dependencies
section as usual