美文网首页
Gradle resolutionStrategy 使用subs

Gradle resolutionStrategy 使用subs

作者: 临界最终散射面 | 来源:发表于2019-03-08 10:36 被阅读0次

    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 使用subs

          本文链接:https://www.haomeiwen.com/subject/ncwlpqtx.html