Can someone please give me a simple build.gradle example of how I can specify compile-time-only classes that are not included in the runtime deployment (war).
Gradle seems to have gotten this the wrong way around since 'runtime' inherits from 'compile'. I can't imagine a situation where I would want classes at runtime that I wouldn't want at compile time. However, there are many circumstances where I need classes to generate code at compile time that I do not wish to deploy at runtime!
I've ploughed through the bloated gradle documentation but cannot find any clear instructions or examples. I suspect this might be achieved by defining a 'configuration' and setting it as the classpath of the CompileJava plugin - but the documentation falls short on explaining how to achieve this.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With