Tuesday, August 6, 2013

Gradle how to add 'providedCompile' configuration

"providedCompile" configuration is used to declare dependencies that will be provided in run time so there is no need to copy the dependencies to resources folder.



But this configuration has not added in some plugins by default (ex. “java” plugin). Thus we have to manually configure our build script for “providedCompile” configuration.


First we add configuration for providedCompile as below,




configurations { providedCompile }



Then we have to add the new configuration into classpaths as below.





sourceSets.main.compileClasspath += configurations.providedCompile
sourceSets.test.compileClasspath += configurations.providedCompile
sourceSets.test.runtimeClasspath += configurations.providedCompile