There has been a lot of discussion regarding this topic, mainly here, but not clear conclusion.
You are on the right track: currently the best solution is to declare your own provided
configuration, that will included compile-only dependencies and add to to your compile classpath:
configurations{
provided
}
dependencies{
//Add libraries like lombok, findbugs etc
provided '...'
}
//Include provided for compilation
sourceSets.main.compileClasspath += [configurations.provided]
// optional: if using 'idea' plugin
idea {
module{
scopes.PROVIDED.plus += [configurations.provided]
}
}
// optional: if using 'eclipse' plugin
eclipse {
classpath {
plusConfigurations += [configurations.provided]
}
}
Typically this works well.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…