美文网首页
classpath和compile的区别

classpath和compile的区别

作者: 不知名的蛋挞 | 来源:发表于2018-10-21 23:19 被阅读207次

    下面英文就是对compile和classpath区别的解释:

    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)创建Task的多种方法)

    定义classpath,gradle会从“repositories”中下载对应版本的Gradle。如果使用gradle wrapper的话,感觉这个配置会被忽略。Wrapper会自己去下载所使用的gradle版本。

    gradle wrapper task利用gradle-wrapper.properties来下载指定的gradle。

    相关文章

      网友评论

          本文标题:classpath和compile的区别

          本文链接:https://www.haomeiwen.com/subject/bnvyzftx.html