build.gradle: compile group vs compile, buildscript, classpath

不羁岁月 提交于 2020-11-30 07:53:51

问题


What is the difference between "compile group" and "compile"? Just another way to define a dependency?

Ex:

compile group: 'org.slf4j', name: 'slf4j-jcl', version: '1.7.21'

And i think this also will work:

compile("org.slf4j:slf4j-jcl:1.7.21")

Why do i have the declare mavenCentral() again and another dependencies block inside the buildscript block?

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
    }
}

From my point of view, when you compile something it will be in your classPath?


回答1:


compile specifies an external dependency for the project you are building. compile requires group, name, and version. These can either be broken out or specified using the short form "group:name:version". see Gradle Dependency Management Basics

The buildscript block declares the dependencies of your gradle build itself while the normal dependencies block declares the dependencies of the project you are going to build



来源:https://stackoverflow.com/questions/39480226/build-gradle-compile-group-vs-compile-buildscript-classpath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!