Gradle:类路径和编译依赖项之间有什么区别? [英] Gradle: What is the difference between classpath and compile dependencies?

查看:100
本文介绍了Gradle:类路径和编译依赖项之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在向我的项目中添加依赖项时,我永远不确定应该给它们加上什么前缀,例如类路径 编译。



例如,下面的依赖项应该是编译时还是类路径?



还应该在我的应用程序 build.gradle中还是在 module 特定的build.gradle中? / p>

当前build.gradle(在应用程序级别):

  apply插件:'java'

存储库{
mavenCentral()
}

依赖项{
compile'org .hibernate:hibernate-core:5.0.5.Final'
编译'mysql:mysql-connector-java:5.1.38'
}


解决方案

我猜你是在引用 compile classpath dependencies {} 块内。如果是这样,则它们是依赖项配置


配置只是一组命名的依赖项。


code> compile 配置由Java插件创建。 classpath 配置通常在 buildSrc {} 块中看到,其中需要声明构建的依赖项 .gradle本身(也许是用于插件)。


When adding dependencies to my project I am never sure what prefix I should give them, e.g. "classpath" or "compile".

For example, should my dependencies below be compile time or classpath?

Also, should this be in my applications build.gradle or in the module specific build.gradle?

Current build.gradle (at application level):

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.hibernate:hibernate-core:5.0.5.Final'
    compile 'mysql:mysql-connector-java:5.1.38'
} 

解决方案

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).

这篇关于Gradle:类路径和编译依赖项之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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