Gradle compile:
如果你的jar包/依赖代码 在编译的时候需要依赖,在运行的时候也需要,那么就用compile
例如 :
compile 'org.springframework:spring-webmvc:4.3.9.RELEASE'
前提:apply plugin: 'war'
或者apply plugin: 'java'
Gradle providedCompile:
如果你的jar包/依赖代码 仅在编译的时候需要,但是在运行时不需要依赖,就用providedCompile
例如:
providedCompile group: 'javax.servlet.jsp.jstl', name: 'jstl', version: '1.2'
前提:apply plugin: 'war'
Gradle runtime:
如果你的jar包/依赖代码 仅在运行的时候需要,但是在编译时不需要依赖,就用runtime
例如:
runtime group: 'mysql', name: 'mysql-connector-java', version: '5.1.42'
前提:apply plugin: 'java'
以上所说的前提,如果不正确配置的话,就会遇到依赖包无法导入,以及runtime以及providedCompile无法使用的情况。
http://www.concretepage.com/build-tools/gradle/gradle-compile-providedcompile-example