代码之家  ›  专栏  ›  技术社区  ›  Yarh

如何将构建变体传播到库中?

  •  0
  • Yarh  · 技术社区  · 6 年前

    在gradle 3之前,我们可以

    configurations {
      client1DevCompile
      ...
    }
    dependencies {
      client1DevCompile project(
        path: ':common',
        configuration: 'app1DevRelease'
      )
    ...
    }
    


    在我的主要模块中

    flavorDimensions "environment"
    productFlavors {
        prod {
            applicationId "package"
            dimension "environment"
        }
    
        qa {
            applicationId "package.qa"
            dimension "environment"
        }
    
        dev {
            applicationId "package.dev"
            dimension "environment"
        }
    }
    
    and in sub module i have
    flavorDimensions "environment"
    productFlavors {
        prod { dimension "environment" }
        qa { dimension "environment" }
        dev { dimension "environment" }
    }
    

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  0
  •   Afshin    6 年前

    flavorDimensions "environment"
    productFlavors {
        prod { dimension "environment" }
        qa { dimension "environment" }
        dev { dimension "environment" }
    }
    

    别忘了给子模块添加依赖项。

    我有类似的(最好说更复杂的)情况,它的工作非常大。以下是我的主要/子模块gradle风格示例:

    主要内容:

    flavorDimensions "brand", "mode"
    
    productFlavors {
        // Brand
        a {
            dimension "brand"
            applicationIdSuffix ".a"
        }
        b{
            dimension "brand"
            applicationIdSuffix ".b"
        }
    
        // Demo-mode
        normal {
            dimension "mode"
            resValue "string", "demo_verion", ""
        }
        demo {
            dimension "mode"
            applicationIdSuffix ".demo"
            versionNameSuffix "-demo"
            resValue "string", "demo_verion", "DEMO VERSION"
        }
    }
    
    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation project(':submodulelib')
    }
    

    flavorDimensions "brand"
    
    productFlavors {
        // Brand
        a{
            dimension "brand"
            externalNativeBuild {
                cmake {
                    cFlags "-DA"
                }
            }
        }
        b{
            dimension "brand"
            externalNativeBuild {
                cmake {
                    cFlags "-DB"
                }
            }
        }
    }