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'

  }

}

你可能感兴趣的:(Gradle resolutionStrategy 使用substitution替换远程依赖到本地工程)