Gradle resolutionStrategy 使用substitution替换远程依赖到本地工程

Defines the strategies around dependency resolution. For example, forcing certain dependency versions, substitutions, conflict resolutions or snapshot timeouts.

Examples:

apply plugin: 'java' //so that there are some configurations

configurations.all {

  resolutionStrategy {

    // fail eagerly on version conflict (includes transitive dependencies)

    // e.g. multiple different versions of the same dependency (group and name are equal)

    failOnVersionConflict()

    // prefer modules that are part of this build (multi-project or composite build) over external modules

    preferProjectModules()

    // force certain versions of dependencies (including transitive)

    //  *append new forced modules:

    force 'asm:asm-all:3.3.1', 'commons-io:commons-io:1.4'

    //  *replace existing forced modules with new ones:

    forcedModules = ['asm:asm-all:3.3.1']

    // add dependency substitution rules

    dependencySubstitution {

此方法可以用本地工程替换远程依赖

      substitute module('org.gradle:api') with project(':api')

      substitute project(':util') with module('org.gradle:util:3.0')

    }

    // cache dynamic versions for 10 minutes

    cacheDynamicVersionsFor 10*60, 'seconds'

    // don't cache changing modules at all

    cacheChangingModulesFor 0, 'seconds'

  }

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • This project was bootstrapped with Create React App. Belo...
    unspecx阅读 5,241评论 0 2
  • Recently we presented Gradle. Today we will talk about ma...
    ifels阅读 4,968评论 0 1
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 10,066评论 0 23
  • 他把音乐掰开 没有发现音符 他把她掰开 也没有发现幸福 后来他掰开了更多的 存在 结果都让他失望 他成了亚细亚的唐...
    楊孜阅读 810评论 0 6
  • 今天,是我們最后一天的研學了,我們要去最后的兩個地方了,我也是能依依不舍,我們來到了天府廣場,四川科技馆,还要...
    小哈_e6e1阅读 335评论 0 0