我的应用程序目前有5种不同的产品口味。原因并非如此重要,在我的控制之下,但基本上我们需要这么多产品口味来针对具有不同测试数据的不同测试服务器。
prod {
applicationId "com.us.android"
}
stage {
applicationId "com.us.android.stage"
}
qa {
applicationId "com.us.android.qa"
}
dev {
applicationId "com.us.android.dev"
}
legacy {
applicationId "com.us.android.legacy"
}
我遇到的问题是每当我创建一个新版本时,都会构建所有产品风格。因此,对于我的项目构建它需要大约50秒,如果我要评论所有,但我关心的构建时间下降到大约10秒。如果它只是我,那么评论它们是很好的,但是如果我不小心提交了已注释的版本,当我们尝试在其他地方构建时,这会导致更多问题。
我的问题是,是否有任何干净的方法可以使它在本地开发中只构建我需要的构建,但我仍然可以根据需要构建其他分支?
我们正在使用Jenkins,我觉得它可以帮助我们在不需要担心它们的情况下获得这些构建,但我不确定如何。
编辑:以下是一些日志,因为这可能有所帮助。
这是我们拥有所有产品风格但是,构建变体设置为stageDebug:
Executing tasks: [:us:assembleStageDebug]
Parallel execution with configuration on demand is an incubating feature.
:api:compileJava
:datePickerLibrary:compileLint
:us:preBuild UP-TO-DATE
:us:preStageDebugBuild UP-TO-DATE
:datePickerLibrary:copyReleaseLint UP-TO-DATE
:us:checkStageDebugManifest
:datePickerLibrary:preBuild UP-TO-DATE
:datePickerLibrary:preReleaseBuild UP-TO-DATE
:datePickerLibrary:checkReleaseManifest
:us:preDevDebugBuild UP-TO-DATE
:datePickerLibrary:preDebugAndroidTestBuild
:us:preDevReleaseBuild UP-TO-DATE
:datePickerLibrary:preDebugAndroidTestBuild UP-TO-DATE
:datePickerLibrary:preDebugBuild UP-TO-DATE
:us:preProdDebugBuild UP-TO-DATE
:datePickerLibrary:preDebugUnitTestBuild UP-TO-DATE
:us:preProdReleaseBuild UP-TO-DATE
:datePickerLibrary:preReleaseUnitTestBuild UP-TO-DATE
:us:preQaDebugBuild UP-TO-DATE
:datePickerLibrary:prepareComAndroidSupportSupportV132100Library
:us:preQaReleaseBuild UP-TO-DATE
:us:preStageReleaseBuild UP-TO-DATE
:us:prelegacyDebugBuild UP-TO-DATE
:us:prelegacyReleaseBuild UP-TO-DATE
:datePickerLibrary:prepareComAndroidSupportSupportV132100Library UP-TO-DATE
:datePickerLibrary:prepareComAndroidSupportSupportV42100Library
:us:generateStageDebugBuildConfig UP-TO-DATE
:datePickerLibrary:prepareReleaseDependencies UP-TO-DATE
:us:generateStageDebugResValues
:datePickerLibrary:compileReleaseAidl UP-TO-DATE
:api:processResources UP-TO-DATE
:datePickerLibrary:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
:us:processStageDebugGoogleServices
File google-services.json is missing from module root folder. The Google Quickstart Plugin cannot function without it.
:api:classes
:us:generateStageDebugAssets UP-TO-DATE
:api:classes UP-TO-DATE
:api:compileJava UP-TO-DATE
:api:jar
:us:processStageDebugJavaRes UP-TO-DATE
:datePickerLibrary:compileReleaseRenderscript
:us:compileStageDebugNdk UP-TO-DATE
:us:newRelicInstrumentTask UP-TO-DATE
:datePickerLibrary:generateReleaseBuildConfig UP-TO-DATE
:datePickerLibrary:generateReleaseAssets UP-TO-DATE
:datePickerLibrary:mergeReleaseAssets UP-TO-DATE
:datePickerLibrary:compileReleaseRenderscript UP-TO-DATE
[newrelic.info] Detected cached instrumentation.
:datePickerLibrary:generateReleaseResValues UP-TO-DATE
:datePickerLibrary:generateReleaseResources UP-TO-DATE
:datePickerLibrary:mergeReleaseResources UP-TO-DATE
:datePickerLibrary:processReleaseManifest UP-TO-DATE
:datePickerLibrary:processReleaseResources UP-TO-DATE
:datePickerLibrary:generateReleaseSources UP-TO-DATE
:datePickerLibrary:processReleaseJavaRes UP-TO-DATE
:datePickerLibrary:compileReleaseJavaWithJavac UP-TO-DATE
:datePickerLibrary:extractReleaseAnnotations UP-TO-DATE
:datePickerLibrary:mergeReleaseProguardFiles UP-TO-DATE
:datePickerLibrary:packageReleaseJar UP-TO-DATE
:datePickerLibrary:compileReleaseNdk UP-TO-DATE
:datePickerLibrary:packageReleaseJniLibs UP-TO-DATE
:datePickerLibrary:packageReleaseLocalJar UP-TO-DATE
:datePickerLibrary:packageReleaseRenderscript UP-TO-DATE
:datePickerLibrary:packageReleaseResources
:api:jar UP-TO-DATE
:us:validateDebugSigning
:datePickerLibrary:bundleRelease
:us:validateDebugSigning UP-TO-DATE
:us:prepareAndroidClientDatePickerLibraryUnspecifiedLibrary UP-TO-DATE
:us:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:us:prepareComAndroidSupportCardviewV72221Library UP-TO-DATE
:us:prepareComAndroidSupportDesign2221Library UP-TO-DATE
:us:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:us:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE
:us:prepareComAndroidSupportSupportV132221Library UP-TO-DATE
:us:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:us:prepareComFacebookAndroidFacebookAndroidSdk3230Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:us:prepareComInstabugLibraryInstabugcore17Library UP-TO-DATE
:us:prepareComInstabugLibraryInstabugsupport17Library UP-TO-DATE
:us:prepareComMixpanelAndroidMixpanelAndroid462Library UP-TO-DATE
:us:prepareComRengwuxianMaterialedittextLibrary214Library UP-TO-DATE
:us:prepareComRoomoramaCaldroid220Library UP-TO-DATE
:us:prepareComZendeskSdk1322Library UP-TO-DATE
:us:prepareUkCoChrisjenxCalligraphy201Library UP-TO-DATE
:us:prepareStageDebugDependencies
:us:compileStageDebugAidl UP-TO-DATE
:us:compileStageDebugRenderscript UP-TO-DATE
:us:generateStageDebugResources
:us:mergeStageDebugResources UP-TO-DATE
:us:jrebelPinStageDebugResids UP-TO-DATE
:us:mergeStageDebugAssets UP-TO-DATE
:us:processStageDebugManifest UP-TO-DATE
:us:processStageDebugResources UP-TO-DATE
:us:generateStageDebugSources UP-TO-DATE
:us:compileStageDebugJavaWithJavac UP-TO-DATE
:us:compileStageDebugSources UP-TO-DATE
:us:generateStageDebugJrebelLayout
:us:preDexStageDebug UP-TO-DATE
:us:dexStageDebug UP-TO-DATE
:us:newRelicDeinstrumentTask
[newrelic.info] Deinstrumenting...
:us:jrebelPostProcessStageDebugResids UP-TO-DATE
:us:packageStageDebug UP-TO-DATE
:us:zipalignStageDebug UP-TO-DATE
:us:assembleStageDebug
BUILD SUCCESSFUL
Total time: 34.308 secs
这是我们只有期望的舞台产品风味的时候:
Executing tasks: [:urbansitter:assembleStageDebug]
Parallel execution with configuration on demand is an incubating feature.
:api:compileJava
:datePickerLibrary:compileLint
:us:preBuild UP-TO-DATE
:us:preStageDebugBuild UP-TO-DATE
:datePickerLibrary:copyReleaseLint
:us:checkStageDebugManifest UP-TO-DATE
:datePickerLibrary:preBuild UP-TO-DATE
:us:preStageReleaseBuild UP-TO-DATE
:datePickerLibrary:preReleaseBuild UP-TO-DATE
:us:generateStageDebugBuildConfig
:datePickerLibrary:checkReleaseManifest
:datePickerLibrary:preDebugAndroidTestBuild UP-TO-DATE
:datePickerLibrary:preDebugBuild UP-TO-DATE
:datePickerLibrary:preDebugUnitTestBuild UP-TO-DATE
:us:generateStageDebugResValues
:us:generateStageDebugBuildConfig UP-TO-DATE
:datePickerLibrary:preReleaseUnitTestBuild
:us:processStageDebugGoogleServices UP-TO-DATE
File google-services.json is missing from module root folder. The Google Quickstart Plugin cannot function without it.
:datePickerLibrary:prepareComAndroidSupportSupportV132100Library
:us:generateStageDebugAssets UP-TO-DATE
:us:processStageDebugJavaRes UP-TO-DATE
:datePickerLibrary:prepareComAndroidSupportSupportV132100Library UP-TO-DATE
:us:compileStageDebugNdk
:datePickerLibrary:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
:us:newRelicInstrumentTask UP-TO-DATE
:us:compileStageDebugNdk UP-TO-DATE
:api:processResources UP-TO-DATE
[newrelic.info] Detected cached instrumentation.
:datePickerLibrary:prepareReleaseDependencies
:api:classes UP-TO-DATE
:api:jar
:datePickerLibrary:compileReleaseAidl UP-TO-DATE
:datePickerLibrary:compileReleaseRenderscript UP-TO-DATE
:datePickerLibrary:prepareReleaseDependencies UP-TO-DATE
:datePickerLibrary:generateReleaseBuildConfig UP-TO-DATE
:datePickerLibrary:generateReleaseAssets UP-TO-DATE
:datePickerLibrary:mergeReleaseAssets UP-TO-DATE
:datePickerLibrary:generateReleaseResValues UP-TO-DATE
:datePickerLibrary:generateReleaseResources UP-TO-DATE
:datePickerLibrary:mergeReleaseResources
:us:validateDebugSigning UP-TO-DATE
:datePickerLibrary:processReleaseManifest UP-TO-DATE
:datePickerLibrary:processReleaseResources UP-TO-DATE
:datePickerLibrary:generateReleaseSources UP-TO-DATE
:datePickerLibrary:processReleaseJavaRes UP-TO-DATE
:datePickerLibrary:compileReleaseJavaWithJavac UP-TO-DATE
:datePickerLibrary:extractReleaseAnnotations UP-TO-DATE
:datePickerLibrary:mergeReleaseProguardFiles UP-TO-DATE
:datePickerLibrary:packageReleaseJar UP-TO-DATE
:datePickerLibrary:compileReleaseNdk UP-TO-DATE
:datePickerLibrary:packageReleaseJniLibs UP-TO-DATE
:datePickerLibrary:packageReleaseLocalJar UP-TO-DATE
:datePickerLibrary:packageReleaseRenderscript UP-TO-DATE
:datePickerLibrary:packageReleaseResources UP-TO-DATE
:datePickerLibrary:bundleRelease UP-TO-DATE
:us:prepareAndroidClientDatePickerLibraryUnspecifiedLibrary UP-TO-DATE
:us:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:us:prepareComAndroidSupportCardviewV72221Library UP-TO-DATE
:us:prepareComAndroidSupportDesign2221Library UP-TO-DATE
:us:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:us:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE
:us:prepareComAndroidSupportSupportV132221Library UP-TO-DATE
:us:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:us:prepareComFacebookAndroidFacebookAndroidSdk3230Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:us:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:us:prepareComInstabugLibraryInstabugcore17Library UP-TO-DATE
:us:prepareComInstabugLibraryInstabugsupport17Library UP-TO-DATE
:us:prepareComMixpanelAndroidMixpanelAndroid462Library UP-TO-DATE
:us:prepareComRengwuxianMaterialedittextLibrary214Library UP-TO-DATE
:us:prepareComRoomoramaCaldroid220Library UP-TO-DATE
:us:prepareComZendeskSdk1322Library UP-TO-DATE
:us:prepareUkCoChrisjenxCalligraphy201Library UP-TO-DATE
:us:prepareStageDebugDependencies
:us:compileStageDebugAidl UP-TO-DATE
:us:compileStageDebugRenderscript UP-TO-DATE
:us:generateStageDebugResources
:us:mergeStageDebugResources UP-TO-DATE
:us:jrebelPinStageDebugResids UP-TO-DATE
:us:mergeStageDebugAssets UP-TO-DATE
:us:processStageDebugManifest UP-TO-DATE
:us:processStageDebugResources UP-TO-DATE
:us:generateStageDebugSources UP-TO-DATE
:us:compileStageDebugJavaWithJavac UP-TO-DATE
:us:compileStageDebugSources UP-TO-DATE
:us:generateStageDebugJrebelLayout
:us:preDexStageDebug UP-TO-DATE
:us:dexStageDebug UP-TO-DATE
:us:newRelicDeinstrumentTask
[newrelic.info] Deinstrumenting...
:us:jrebelPostProcessStageDebugResids UP-TO-DATE
:us:packageStageDebug UP-TO-DATE
:us:zipalignStageDebug UP-TO-DATE
:us:assembleStageDebug
BUILD SUCCESSFUL
Total time: 8.54 secs
我附加了
的构建日志答案 0 :(得分:2)
通过使用assembleRelease
,它将构建所有风味组合。 assemble
甚至可以构建所有10个命令,包括所有调试。
现在您没有指定 如何构建项目。对于詹金斯来说,assembleRelease
可能是要走的路,建立你所有的组合。
对于您的本地版本,只需使用gradle assembleProdRelease
或gradle assembleDevDebug
即可构建所需的版本。
通过指定多个目标,您也可以在jenkins上构建子集。 e.g。
gradle assembleDevRelease assembleProdRelease [...]
此外,Android Studio内置支持选择您要构建的风格。通过单击Build Variants
,您可以选择要使用默认运行配置运行的变体。要在各种口味之间切换,您只需选择所需的口味即可。