Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Moves release flavour to build type
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Hentges committed Apr 17, 2019
1 parent 8e59585 commit d2b1b6b
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 156 deletions.
89 changes: 34 additions & 55 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,48 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
manifestPlaceholders.isRaptorEnabled = "false"
buildConfigField "boolean", "IS_RELEASED", "false"
}

def releaseTemplate = {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
matchingFallbacks = ['release'] // Use on the "release" build type in dependencies (AARs)
}

buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
releaseRaptor {
initWith release
manifestPlaceholders.isRaptorEnabled = "true"
matchingFallbacks = ['release']
}
debug {
shrinkResources false
minifyEnabled false
applicationIdSuffix ".debug"
manifestPlaceholders.isRaptorEnabled = "true"
}
// "releaseRaptor" is only used for performance testing, and isn't a real "release" type
releaseRaptor releaseTemplate >> { // the ">>" concatenates the releaseRaptor-specific options with the template
manifestPlaceholders.isRaptorEnabled = "true"
}
nightly releaseTemplate >> {
buildConfigField "boolean", "IS_RELEASED", "true"
}
beta releaseTemplate >> {
buildConfigField "boolean", "IS_RELEASED", "true"
}
}

variantFilter { // There's a "release" build type that exists by default that we don't use (it's replaced by "nightly" and "beta")
if (buildType.name == 'release') {
setIgnore true
}
}

testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}

flavorDimensions "abi", "channel"
flavorDimensions "abi"

productFlavors {
// Processor architectures (abi dimension)

arm {
dimension "abi"
ndk {
Expand All @@ -78,41 +90,6 @@ android {
abiFilter "arm64-v8a"
}
}

// Product channels (channel dimension)

// "Greenfield" is our clean version of Fenix without any of the "Fennec transition" code.
greenfield {
dimension "channel"
}
firefoxNightly {
dimension "channel"

// Aurora was a channel between nightly builds and beta versions. Aurora builds were published on Google
// Play. When the Aurora channel was shutdown in April 2017 the decision was made to instead ship Nightly
// builds to Google Play using the existing application id. Previously Nightly builds were not available
// on Google Play. Since then our Nightly package name is "fennec_aurora" instead of "fennec_nightly".
applicationId "org.mozilla.fennec_aurora"
}
firefoxBeta {
dimension "channel"

applicationId "org.mozilla.firefox_beta"
}
firefoxRelease {
dimension "channel"

applicationId "org.mozilla.firefox"
}
}

variantFilter { variant ->
def flavors = variant.flavors*.name.toString().toLowerCase()

if (!flavors.contains("greenfield")) {
// For now everything that isn't a "greenfield" build isn't used. So let's ignore those variants.
setIgnore(true)
}
}

compileOptions {
Expand Down Expand Up @@ -148,9 +125,10 @@ android.applicationVariants.all { variant ->
// -------------------------------------------------------------------------------------------------

def buildType = variant.buildType.name
def versionCode = null

if (buildType == "release") {
def versionCode = generatedVersionCode
if (buildType == "nightly") {
versionCode = generatedVersionCode

// The Google Play Store does not allow multiple APKs for the same app that all have the
// same version code. Therefore we need to have different version codes for our ARM and x86
Expand All @@ -166,15 +144,16 @@ android.applicationVariants.all { variant ->
versionCode = versionCode + 1
}// else variant.flavorName.contains("Arm")) use generated version code

variant.outputs.all { output ->
variant.outputs.all {
setVersionCodeOverride(versionCode)
}
}

println("----------------------------------------------")
println("Build type: " + buildType)
println("Variant name: " + variant.name)
println("Build type: " + variant.buildType.name)
println("Flavor: " + variant.flavorName)
println("Version code: " + variant.mergedFlavor.versionCode)
println("Version code: " + (versionCode ?: variant.mergedFlavor.versionCode))

// -------------------------------------------------------------------------------------------------
// BuildConfig: Set variables for Sentry, Crash Reporting, and Telemetry
Expand Down Expand Up @@ -213,7 +192,7 @@ android.applicationVariants.all { variant ->

print("Adjust token: ")

if (variantName.contains("Release")) {
if (variant.buildType.buildConfigFields['IS_RELEASED']?.value) {
try {
def token = new File("${rootDir}/.adjust_token").text.trim()
buildConfigField 'String', 'ADJUST_TOKEN', '"' + token + '"'
Expand Down Expand Up @@ -357,7 +336,7 @@ dependencies {
}

androidTestImplementation Deps.espresso_idling_resources

androidTestImplementation Deps.tools_test_runner
androidTestImplementation Deps.tools_test_rules
androidTestUtil Deps.orchestrator
Expand Down
11 changes: 0 additions & 11 deletions app/src/firefoxBeta/AndroidManifest.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/firefoxNightly/AndroidManifest.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/firefoxRelease/AndroidManifest.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AdjustMetricsService(private val application: Application) : MetricsServic
if ((BuildConfig.ADJUST_TOKEN.isNullOrEmpty())) {
Log.i(LOGTAG, "No adjust token defined")

if (!BuildConfig.DEBUG) {
if (BuildConfig.IS_RELEASED) {
throw IllegalStateException("No adjust token defined for release build")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
preferenceMakeDefaultBrowser?.onPreferenceClickListener =
getClickListenerForMakeDefaultBrowser()

preferenceLeakCanary?.isVisible = BuildConfig.DEBUG
if (BuildConfig.DEBUG) {
preferenceLeakCanary?.isVisible = !BuildConfig.IS_RELEASED
if (!BuildConfig.IS_RELEASED) {
preferenceLeakCanary?.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _, newValue ->
(context?.applicationContext as FenixApplication).toggleLeakCanary(newValue as Boolean)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/mozilla/fenix/utils/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Settings private constructor(context: Context) {

val isCrashReportingEnabled: Boolean
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_crash_reporter), true) &&
BuildConfig.CRASH_REPORTING && BuildConfig.BUILD_TYPE == "release"
BuildConfig.CRASH_REPORTING && BuildConfig.IS_RELEASED

val isRemoteDebuggingEnabled: Boolean
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_remote_debugging), false)
Expand Down
6 changes: 3 additions & 3 deletions automation/taskcluster/decision_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import taskcluster

from lib import build_variants
from lib.tasks import TaskBuilder, schedule_task_graph, _get_architecture_and_build_type_and_product_from_variant
from lib.tasks import TaskBuilder, schedule_task_graph, get_architecture_and_build_type_from_variant
from lib.chain_of_trust import (
populate_chain_of_trust_task_graph,
populate_chain_of_trust_required_but_unused_files
Expand Down Expand Up @@ -57,7 +57,7 @@ def pr_or_push(is_master_push):
build_tasks[assemble_task_id] = BUILDER.craft_assemble_task(variant)
build_tasks[taskcluster.slugId()] = BUILDER.craft_test_task(variant)

arch, build_type, _ = _get_architecture_and_build_type_and_product_from_variant(variant)
arch, build_type = get_architecture_and_build_type_from_variant(variant)
# autophone only supports arm and aarch64, so only sign/perftest those builds
if (
build_type == 'releaseRaptor' and
Expand Down Expand Up @@ -88,7 +88,7 @@ def nightly(track):
push_tasks = {}

build_task_id = taskcluster.slugId()
build_tasks[build_task_id] = BUILDER.craft_assemble_release_task(architectures, is_staging)
build_tasks[build_task_id] = BUILDER.craft_assemble_nightly_task(architectures, is_staging)

signing_task_id = taskcluster.slugId()
signing_tasks[signing_task_id] = BUILDER.craft_nightly_signing_task(
Expand Down
Loading

0 comments on commit d2b1b6b

Please sign in to comment.