Gradle:什么是默认配置,以及如何更改它 [英] Gradle: What Is The Default Configuration and How Do I Change It

查看:290
本文介绍了Gradle:什么是默认配置,以及如何更改它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行依赖任务时,有几个部分:编译,运行时,测试编译...

其中一个部分是default - 默认配置神器。这部分是什么,它用于什么?



如何更改默认配置中的内容?

详情: Gradle 1.7

解决方案

除非您的版本发布Ivy模块,否则项目依赖关系时,> default 配置主要是相关的。给定一个具有项目A和B的多项目构建,如果A声明了一个项目依赖关系而不明确命名配置(例如 dependencies {compile project(:B)} ,A(更精确地说A的 compile 配置)将取决于项目B的 default 配置。换句话说, dependencies {compile project(:B)} 是 dependencies {compile project(path::B,configuration:default)的快捷方式}



默认配置从运行时配置,这意味着它包含运行时配置的所有依赖和工件,并且可能更多。您可以在通常情况下添加依赖和工件(在B的构建脚本中使用依赖关系 / artifacts 块),或者,B可以声明自定义配置, A可以依靠明确命名该配置(例如 dependencies {compile project(path::B,configuration:myCustomConfig)}


When I run the "dependencies" task there are several sections: compile, runtime, testCompile ...

One of those sections is "default - Configuration for default artifacts." What is this section and what is it used for?

How do I change what is in the "default configuration"?

Details: Gradle 1.7

解决方案

Unless your build is publishing Ivy modules, the default configuration is mainly relevant when dealing with project dependencies in a multi-project build. Given a multi-project build with projects A and B, if A declares a project dependency on B without explicitly naming a configuration (e.g. dependencies { compile project(":B") }, A (more precisely A's compile configuration) will depend on project B's default configuration. In other words, dependencies { compile project(":B") } is a shortcut for dependencies { compile project(path: ":B", configuration: "default") }.

The default configuration extends from the runtime configuration, which means that it contains all the dependencies and artifacts of the runtime configuration, and potentially more. You can add dependencies and artifacts in the usual way (using a dependencies/artifacts block in B's build script). Alternatively, B could declare a custom configuration, and A could depend on that by explicitly naming that configuration (e.g. dependencies { compile project(path: ":B", configuration: "myCustomConfig") }.

这篇关于Gradle:什么是默认配置,以及如何更改它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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