build.gradle:编译组vs编译,buildscript,类路径 [英] build.gradle: compile group vs compile, buildscript, classpath

查看:119
本文介绍了build.gradle:编译组vs编译,buildscript,类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译组"和编译"之间有什么区别?定义依赖项的另一种方法?

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

例如:

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

我认为这也将起作用:

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

为什么还要再次声明mavenCentral()和buildscript块中的另一个依赖项块?

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")
    }
}

从我的角度来看,当您编译某些东西时,它会出现在您的classPath中吗?

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

推荐答案

compile为正在构建的项目指定外部依赖项. compile需要组,名称和版本.可以使用短格式"group:name:version" 进行细分或指定这些名称.参见 Gradle Dependency Management Basics

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

buildscript块声明了gradle构建本身的依赖关系,而 normal 依赖关系块声明了您要构建的项目的依赖关系

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

这篇关于build.gradle:编译组vs编译,buildscript,类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆