设为首页 加入收藏

TOP

Chapter 7. Dependency Management Basics 依赖管理基础(二)
2017-10-13 10:04:58 】 浏览:10044
Tags:Chapter Dependency Management Basics 依赖 管理 基础
s going on here? This build script says a few things about the project. Firstly, it states that Hibernate core 3.6.7.Final is required to compile the project's production source. By implication, Hibernate core and its dependencies are also required at runtime. The build script also states that any junit >= 4.0 is required to compile the project's tests. It also tells Gradle to look in the Maven central repository for any dependencies that are required. The following sections go into the details.

7.3. Dependency configurations

In Gradle dependencies are grouped into configurations. A configuration is simply a named set of dependencies. We will refer to them as dependency configurations.

//gradle中依赖以组的形式配置,一个配置就是一个简单的依赖的名字的集合。我们称它依赖配置

You can use them to declare the external dependencies of your project. As we will see later, they are also used to declare the publications of your project.

//我们可以使用它们声明外部依赖,后面我们也会看到,它们也可以用来声明项目的发布

The Java plugin defines a number of standard configurations. These configurations represent the classpaths that the Java plugin uses. Some are listed below, and you 

can find more details in Table 45.5, “Java plugin - dependency configurations”.

//java插件定义了一些标准配置,部分如下

compile

The dependencies required to compile the production source of the project.

//用于编译项目源代码的依赖

runtime

The dependencies required by the production classes at runtime. By default, also includes the compile time dependencies.

//

testCompile

The dependencies required to compile the test source of the project. By default, also includes the compiled production classes and the compile time dependencies.

testRuntime

The dependencies required to run the tests. By default, also includes the compile, runtime and test compile dependencies.

Various plugins add further standard configurations. You can also define your own custom configurations to use in your build. Please see Section 23.3, “Dependency configurations” for the details of defining and customizing dependency configurations.

7.4. External dependencies

There are various types of dependencies that you can declare. One such type is an external dependency. This is a dependency on some files built outside the current build, and stored in a repository of some kind, such as Maven central, or a corporate Maven or Ivy repository, or a directory in the local file system.

To define an external dependency, you add it to a dependency configuration:

//为了定义外部依赖,你需要把它添加到依赖配置中

Example 7.2. Definition of an external dependency

build.gradle

dependencies {
    compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final' } 

An external dependency is identified using groupname and version attributes. Depending on which kind of repository you are using, group and version may be optional.

//外部依赖使用group name和version属性来生命,group和version是可选的

The shortcut form for declaring external dependencies looks like “group:name:version”.

//生命外部依赖的简洁写法为group:name:version

Example 7.3. Shortcut definition of an external dependency

build.gradle

dependencies {
    compile 'org.hibernate:hibernate-core:3.6.7.Final'
}

To find out more about defining and working with dependencies, have a look at Section 23.4, “How to declare your dependencies”.

首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇全新的手势,侧滑返回、全局右滑.. 下一篇Chapter 8. Introduction to mult..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目