development

Gradle 풍미 만 빌드

big-blog 2020. 10. 7. 07:50
반응형

Gradle 풍미 만 빌드


누군가가 명령 줄을 통해 내 다른 버전 중 하나만 빌드 할 수 있는지 말해 줄 수 있습니까?

현재로서는 실행 방법을 보지 못했습니다. 예를 들면 다음과 같습니다.

gradle buildDev 

Dev가 내 다른 맛 중 하나 일 때. 실제로 다음을 실행해야합니다.

gradle build

그리고 모든 맛이 만들어졌습니다.

몇 가지 맛을 건너 뛰고 싶습니다. 가능할까요?

감사


build작업 의 특징 별 버전은 없지만 assembleinstall작업 의 특징 별 버전이 있습니다. assembleAPK를 생성합니다. install장치 / 에뮬레이터에 설치합니다.

예를 들어,에 이 샘플 프로젝트 , 내가 두 제품의 맛 (정의 chocolatevanilla)과 총 3 개 빌드 유형을 ( debug, release, 및 mezzanine).

특히 러닝 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

I would simplify the answer given by @CommonsWare because going through the answer i was litte confused.

Consider these are the product flavours

  • Dev
  • Preprod
  • Prod

Run

gradlew task

This will list out all Product flavours along with there build types

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.

From this you can easily choose the flavours and will generate a build based on that

gradlew assemblePREPROD


If your productFlavor is chocolate you can do

./gradlew assembleChocolateRelease

or

./gradlew assembleChocolateDebug

참고URL : https://stackoverflow.com/questions/21307444/gradle-build-only-a-flavour

반응형