Gradle只build立一种风味

有人能告诉我是否可以通过命令行build立我的不同口味之一吗?

目前我还没有看到执行的方式,例如:

gradle buildDev 

当Dev是我不同的口味之一。 的确,我必须执行:

 gradle build 

而所有的口味都是build立的。

我想跳过一些口味。 可能吗?

谢谢

虽然build任务没有特定于风味的版本,但是assembleinstall任务的风味特定版本。 assemble将创buildAPK; install将安装在设备/模拟器上。

例如,在这个示例项目中 ,我定义了两种产品口味( chocolatevanilla )以及三种总体构buildtypes( debugreleasemezzanine )。

运行gradle tasks显示,其中包括:

 Build tasks ----------- assemble - Assembles all variants of all applications and secondary packages. assembleChocolate - Assembles all builds for flavor Chocolate assembleChocolateDebug - Assembles the Debug build for flavor Chocolate assembleChocolateDebugTest - Assembles the Test build for the ChocolateDebug build assembleChocolateMezzanine - Assembles the Mezzanine build for flavor Chocolate assembleChocolateRelease - Assembles the Release build for flavor Chocolate assembleDebug - Assembles all Debug builds assembleMezzanine - Assembles all Mezzanine builds assembleRelease - Assembles all Release builds assembleTest - Assembles all the Test applications assembleVanilla - Assembles all builds for flavor Vanilla assembleVanillaDebug - Assembles the Debug build for flavor Vanilla assembleVanillaDebugTest - Assembles the Test build for the VanillaDebug build assembleVanillaMezzanine - Assembles the Mezzanine build for flavor Vanilla assembleVanillaRelease - Assembles the Release build for flavor Vanilla Install tasks ------------- installChocolateDebug - Installs the Debug build for flavor Chocolate installChocolateDebugTest - Installs the Test build for the ChocolateDebug build installChocolateMezzanine - Installs the Mezzanine build for flavor Chocolate installChocolateRelease - Installs the Release build for flavor Chocolate installVanillaDebug - Installs the Debug build for flavor Vanilla installVanillaDebugTest - Installs the Test build for the VanillaDebug build installVanillaMezzanine - Installs the Mezzanine build for flavor Vanilla installVanillaRelease - Installs the Release build for flavor Vanilla uninstallAll - Uninstall all applications. uninstallChocolateDebug - Uninstalls the Debug build for flavor Chocolate uninstallChocolateDebugTest - Uninstalls the Test build for the ChocolateDebug build uninstallChocolateMezzanine - Uninstalls the Mezzanine build for flavor Chocolate uninstallChocolateRelease - Uninstalls the Release build for flavor Chocolate uninstallVanillaDebug - Uninstalls the Debug build for flavor Vanilla uninstallVanillaDebugTest - Uninstalls the Test build for the VanillaDebug build uninstallVanillaMezzanine - Uninstalls the Mezzanine build for flavor Vanilla uninstallVanillaRelease - Uninstalls the Release build for flavor Vanilla 

我会简化@CommonsWare给出的答案,因为通过答案我litte困惑。

考虑这些是产品口味

  • 开发
  • Preprod

gradlew任务

这将列出所有的产品风味以及那里的构buildtypes

 assemble - Assembles all variants of all applications and secondary packages. assembleAndroidTest - Assembles all the Test applications. assembleDebug - Assembles all Debug builds. assembleDEV - Assembles all DEV builds. assemblePREPROD - Assembles all PREPROD builds. assemblePROD - Assembles all PROD builds. assembleRelease - Assembles all Release builds. 

从这里你可以很容易地select风味,并基于此生成一个构build

gradlew assemblePREPROD