下面英文就是對compile和classpath區(qū)別的解釋:
I’m going to guess that you’re referencing compile and classpath
within the dependencies {} block. If that is so, those are dependency
Configurations.
A configuration is simply a named set of dependencies. The compile
configuration is created by the Java plugin. The classpath
configuration is commonly seen in the buildSrc {} block where one
needs to declare dependencies for the build.gradle, itself (for
plugins, perhaps).
classpath的作用:
buildscript itself needs something to run, use classpath
complie的作用:
your project needs something to run, use compile
所以在Project中的gradle的dependencies 指添加依賴是使用classpath的盼樟,classpath 一般是添加buildscript本身需要運行的東西晨缴。比如build.gradle中需要用到TaskName為t1的Task击碗,而這個Task定義在其他插件里面们拙,就要通過classpath添加該插件。(例子詳見(4)創(chuàng)建Task的多種方法)
定義classpath械拍,gradle會從“repositories”中下載對應(yīng)版本的Gradle。如果使用gradle wrapper的話甲馋,感覺這個配置會被忽略迄损。Wrapper會自己去下載所使用的gradle版本。
gradle wrapper task利用gradle-wrapper.properties來下載指定的gradle芹敌。