-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to faster build configuration (#311)
**Background** Make faster builds. **Changes** 1. Increase -Xms from 2g to 3g 5.2% (8.8s) of build’s time was wasted to garbage collection. 2. Replace all to bin gradle distribution. Just smaller jar, no docs, no sources. 3. Disable unnecessary android buildFeatures. Less tasks = faster build 4. Disable viewBinding by default. ViewBinding needed only for few modules. No need to enable this feature for all modules. 5. Disable Jetifier. All project modules do not use any legacy support libs. (see [checkJetifierReport.txt](https://github.com/flipperdevices/Flipper-Android-App/files/9364391/checkJetifierReport.txt)) Should be faster more than 15% **Test plan** Green pipelines.
- Loading branch information
Showing
97 changed files
with
365 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.gradle/ | ||
/build | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(libs.android.gradle) | ||
implementation(libs.detekt.gradle) | ||
implementation(libs.kotlin.gradle) | ||
implementation(libs.ktlint.gradle) | ||
implementation(libs.sentry.gradle) | ||
|
||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) | ||
} |
2 changes: 2 additions & 0 deletions
2
buildSrc/src/main/java/ApkConfig.kt → ...om/flipperdevices/buildlogic/ApkConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package com.flipperdevices.buildlogic | ||
|
||
import java.lang.System.getProperty | ||
|
||
object ApkConfig { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
build-logic/plugins/convention/src/main/kotlin/flipper.android-compose.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import com.android.build.gradle.BaseExtension | ||
|
||
plugins { | ||
id("flipper.android-lib") | ||
} | ||
|
||
@Suppress("UnstableApiUsage") | ||
configure<BaseExtension> { | ||
buildFeatures.compose = true | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get() | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
...c/src/main/java/androidLibrary.gradle.kts → ...ain/kotlin/flipper.android-lib.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import com.android.build.gradle.BaseExtension | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("kotlin-android") | ||
kotlin("kapt") | ||
} | ||
|
||
android { | ||
configure<BaseExtension> { | ||
commonAndroid(project) | ||
} |
23 changes: 23 additions & 0 deletions
23
build-logic/plugins/convention/src/main/kotlin/flipper.fdroid.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import com.flipperdevices.buildlogic.ApkConfig | ||
|
||
tasks.register("dumpApkVersion") { | ||
val CODE_PROP = "version_code" | ||
val NAME_PROP = "version_name" | ||
|
||
val outputFileProvider = layout.buildDirectory.file("version/apk-version.properties") | ||
|
||
inputs.property(CODE_PROP, provider { ApkConfig.VERSION_CODE }) | ||
inputs.property(NAME_PROP, provider { ApkConfig.VERSION_NAME }) | ||
outputs.file(outputFileProvider) | ||
|
||
doLast { | ||
val outputFile = outputFileProvider.get().asFile | ||
outputFile.deleteOnExit() | ||
outputFile.parentFile.mkdirs() | ||
|
||
val props = java.util.Properties() | ||
props.setProperty(CODE_PROP, inputs.properties[CODE_PROP].toString()) | ||
props.setProperty(NAME_PROP, inputs.properties[NAME_PROP].toString()) | ||
props.store(outputFile.writer(), /* comments = */ null) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
build-logic/plugins/convention/src/main/kotlin/flipper.lint.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import org.gradle.kotlin.dsl.configure | ||
import org.jlleitschuh.gradle.ktlint.KtlintExtension | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension | ||
|
||
plugins { | ||
id("io.gitlab.arturbosch.detekt") | ||
id("org.jlleitschuh.gradle.ktlint") | ||
} | ||
|
||
configure<KtlintExtension> { | ||
version.set(libs.versions.ktlint.runtime) | ||
android.set(true) | ||
verbose.set(true) | ||
outputToConsole.set(true) | ||
ignoreFailures.set(false) | ||
enableExperimentalRules.set(true) | ||
filter { | ||
exclude("**/generated/**") | ||
include("**/kotlin/**") | ||
} | ||
} | ||
|
||
configure<DetektExtension> { | ||
config = rootProject.files("config/detekt/detekt.yml") | ||
} |
7 changes: 7 additions & 0 deletions
7
build-logic/plugins/convention/src/main/kotlin/versionCatalog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import org.gradle.accessors.dm.LibrariesForLibs | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.the | ||
|
||
// Workaround for https://github.com/gradle/gradle/issues/15383 | ||
val Project.libs: LibrariesForLibs | ||
get() = the<LibrariesForLibs>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pluginManagement { | ||
repositories { | ||
google() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
gradlePluginPortal() | ||
} | ||
|
||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic" | ||
|
||
include( | ||
":plugins:convention", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,13 @@ | ||
plugins { | ||
id("com.android.application") apply false | ||
id("com.android.library") apply false | ||
kotlin("android") apply false | ||
alias(libs.plugins.detekt) | ||
alias(libs.plugins.ktlint) | ||
} | ||
|
||
tasks.register("clean", Delete::class) { | ||
delete(rootProject.buildDir) | ||
} | ||
|
||
val ktLintVersion: String = libs.versions.ktlint.runtime.get() | ||
|
||
subprojects { | ||
apply { | ||
plugin("io.gitlab.arturbosch.detekt") | ||
plugin("org.jlleitschuh.gradle.ktlint") | ||
} | ||
|
||
ktlint { | ||
version.set(ktLintVersion) | ||
android.set(true) | ||
verbose.set(true) | ||
outputToConsole.set(true) | ||
ignoreFailures.set(false) | ||
enableExperimentalRules.set(true) | ||
filter { | ||
exclude("**/generated/**") | ||
include("**/kotlin/**") | ||
} | ||
} | ||
|
||
detekt { | ||
config = rootProject.files("config/detekt/detekt.yml") | ||
} | ||
} | ||
|
||
tasks.register("dumpApkVersion") { | ||
val CODE_PROP = "version_code" | ||
val NAME_PROP = "version_name" | ||
|
||
val outputFileProvider = layout.buildDirectory.file("version/apk-version.properties") | ||
|
||
inputs.property(CODE_PROP, provider { ApkConfig.VERSION_CODE }) | ||
inputs.property(NAME_PROP, provider { ApkConfig.VERSION_NAME }) | ||
outputs.file(outputFileProvider) | ||
|
||
doLast { | ||
val outputFile = outputFileProvider.get().asFile | ||
outputFile.deleteOnExit() | ||
outputFile.parentFile.mkdirs() | ||
|
||
val props = java.util.Properties() | ||
props.setProperty(CODE_PROP, inputs.properties[CODE_PROP].toString()) | ||
props.setProperty(NAME_PROP, inputs.properties[NAME_PROP].toString()) | ||
props.store(outputFile.writer(), /* comments = */ null) | ||
} | ||
alias(libs.plugins.android.app) apply false | ||
alias(libs.plugins.android.lib) apply false | ||
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.kotlin.serialization) apply false | ||
alias(libs.plugins.kotlin.ksp) apply false | ||
alias(libs.plugins.square.anvil) apply false | ||
alias(libs.plugins.protobuf) apply false | ||
alias(libs.plugins.detekt) apply false | ||
alias(libs.plugins.ktlint) apply false | ||
|
||
id("flipper.fdroid") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
androidLibrary | ||
id("flipper.lint") | ||
id("flipper.android-lib") | ||
} | ||
|
||
dependencies { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
androidLibrary | ||
id("flipper.lint") | ||
id("flipper.android-lib") | ||
} | ||
|
||
dependencies { | ||
|
Oops, something went wrong.