Gradle 配置集成

Gradle configurations integration

我在 build.gradle

中找到了这段代码
configurations {
    all {
        resolutionStrategy {
            cacheDynamicVersionsFor 0, 'seconds'
        }
    }
    integration
}

我在任何地方都找不到 integration 关键字代表什么。你能给我解释一下吗?

在此示例中,构建是声明一个名为integration配置。在大多数情况下,配置可以被认为是依赖项的桶或集合。如果插件或 Gradle 核心关于特定配置是新的,通常不需要声明它,因为它一开始就已经存在了。

我们假设 'integration' 是 'integration test' 的缩写。那么这里发生的事情是您的构建在说:"Hey, I need a bunch of dependencies for running my integration test, but I don't want to pollute the classpath for the other kinds of runtime environments. So please make me a bucket of dependencies to isolate the integration test".

稍后在构建文件(您没有显示)中,您将找到一个 dependencies 块,其中 integration 配置填充了 运行 所需的模块考试。最后,一些实际使用它的任务,大概是为了设置类路径。

它可以用于许多其他原因。但不管它是什么,它可能是自定义的,如果你愿意,你可以将它(以及对它的所有引用)重命名为 'aCollectionOfAwesomeDependenciesUsedForRunningOurIntegrationTest'。