-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
428a872
commit a8ecd6e
Showing
45 changed files
with
582 additions
and
415 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) apply false | ||
alias(libs.plugins.android.library) apply false | ||
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.kotlin.compose) apply false | ||
alias(libs.plugins.kotlin.kapt) apply false | ||
alias(libs.plugins.hilt) apply false | ||
id("deps-management.convention") apply true | ||
} |
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,34 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "com.miquido.buildlogic" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
kotlin { | ||
compilerOptions { | ||
jvmTarget = JvmTarget.JVM_17 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.android.gradlePlugin) | ||
implementation(libs.android.tools.common) | ||
implementation(libs.kotlin.gradlePlugin) | ||
implementation(libs.kotlin.compose.gradlePlugin) | ||
implementation(libs.deps.update.scanner.gradlePlugin) | ||
implementation(libs.deps.catalog.updater.gradlePlugin) | ||
} | ||
|
||
tasks { | ||
validatePlugins { | ||
enableStricterValidation = true | ||
failOnWarning = true | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../build-logic/convention/src/main/kotlin/android-application.compose.convention.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,10 @@ | ||
import com.miquido.configureAndroidCompose | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.plugin.compose") | ||
} | ||
|
||
android { | ||
configureAndroidCompose(this) | ||
} |
18 changes: 18 additions & 0 deletions
18
gradle/build-logic/convention/src/main/kotlin/android-application.convention.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,18 @@ | ||
import com.miquido.configureAndroid | ||
import com.miquido.configureKotlinAndroid | ||
import com.miquido.projectTargetSdk | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
id("lint.convention") | ||
id("ktlint.convention") | ||
id("detekt.convention") | ||
} | ||
|
||
android { | ||
defaultConfig.targetSdk = projectTargetSdk | ||
|
||
configureAndroid(this) | ||
configureKotlinAndroid() | ||
} |
10 changes: 10 additions & 0 deletions
10
gradle/build-logic/convention/src/main/kotlin/android-library.compose.convention.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,10 @@ | ||
import com.miquido.configureAndroidCompose | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.plugin.compose") | ||
} | ||
|
||
android { | ||
configureAndroidCompose(this) | ||
} |
31 changes: 31 additions & 0 deletions
31
gradle/build-logic/convention/src/main/kotlin/android-library.convention.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,31 @@ | ||
import com.miquido.configureAndroid | ||
import com.miquido.configureKotlinAndroid | ||
import com.miquido.disableUnnecessaryAndroidTests | ||
import com.miquido.projectTargetSdk | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
id("lint.convention") | ||
id("ktlint.convention") | ||
id("detekt.convention") | ||
} | ||
|
||
android { | ||
configureAndroid(this) | ||
configureKotlinAndroid() | ||
|
||
testOptions.targetSdk = projectTargetSdk | ||
|
||
androidComponents { | ||
disableUnnecessaryAndroidTests(this) | ||
} | ||
// The resource prefix is derived from the module name, | ||
// so resources inside ":core:module1" must be prefixed with "core_module1_" | ||
resourcePrefix = path | ||
.split("""\W""".toRegex()) | ||
.drop(1) | ||
.distinct() | ||
.joinToString(separator = "_") | ||
.lowercase() + "_" | ||
} |
26 changes: 26 additions & 0 deletions
26
gradle/build-logic/convention/src/main/kotlin/com/miquido/AndroidCommonSetup.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,26 @@ | ||
package com.miquido | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.Project | ||
|
||
internal fun Project.configureAndroid( | ||
commonExtension: CommonExtension<*, *, *, *, *, *> | ||
) = with(commonExtension) { | ||
compileSdk = projectCompileSdk | ||
|
||
defaultConfig { | ||
minSdk = projectMinSdk | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
@Suppress("UnstableApiUsage") | ||
testOptions { | ||
animationsDisabled = true | ||
unitTests { | ||
isIncludeAndroidResources = true | ||
all { | ||
it.maxParallelForks = Runtime.getRuntime().availableProcessors() - 1 | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
gradle/build-logic/convention/src/main/kotlin/com/miquido/ComposeSetup.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,31 @@ | ||
package com.miquido | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.assign | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension | ||
|
||
/** | ||
* Configure Compose-specific options | ||
*/ | ||
internal fun Project.configureAndroidCompose( | ||
commonExtension: CommonExtension<*, *, *, *, *, *>, | ||
) { | ||
commonExtension.apply { | ||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
dependencies { | ||
add("implementation", libs.findLibrary("androidx-compose-foundation").get()) | ||
add("implementation", libs.findLibrary("androidx-compose-runtime").get()) | ||
add("implementation", libs.findLibrary("androidx-compose-ui").get()) | ||
} | ||
} | ||
|
||
extensions.configure<ComposeCompilerGradlePluginExtension> { | ||
enableStrongSkippingMode = true | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
gradle/build-logic/convention/src/main/kotlin/com/miquido/InstrumentedTestsSetup.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,19 @@ | ||
package com.miquido | ||
|
||
import com.android.build.api.variant.LibraryAndroidComponentsExtension | ||
import org.gradle.api.Project | ||
|
||
/** | ||
* Disable unnecessary Android instrumented tests for the [project] if there is no `androidTest` folder. | ||
* Otherwise, these projects would be compiled, packaged, installed and ran only to end-up with the following message: | ||
* | ||
* > Starting 0 tests on AVD | ||
* | ||
* Note: this could be improved by checking other potential sourceSets based on buildTypes and flavors. | ||
*/ | ||
internal fun Project.disableUnnecessaryAndroidTests( | ||
components: LibraryAndroidComponentsExtension, | ||
) = components.beforeVariants { | ||
it.enableAndroidTest = it.enableAndroidTest | ||
&& projectDir.resolve("src/androidTest").exists() | ||
} |
42 changes: 42 additions & 0 deletions
42
gradle/build-logic/convention/src/main/kotlin/com/miquido/KotlinSetup.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,42 @@ | ||
package com.miquido | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.kotlin.dsl.assign | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.provideDelegate | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension | ||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension | ||
|
||
internal fun Project.configureKotlinAndroid() { | ||
configureKotlin<KotlinAndroidProjectExtension>() | ||
} | ||
|
||
internal fun Project.configureKotlinJvm() { | ||
configureKotlin<KotlinJvmProjectExtension>() | ||
} | ||
|
||
/** | ||
* Configure base Kotlin options | ||
*/ | ||
private inline fun <reified T : KotlinTopLevelExtension> Project.configureKotlin() = configure<T> { | ||
// Treat all Kotlin warnings as errors (disabled by default) | ||
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties | ||
val warningsAsErrors: String? by project | ||
when (this) { | ||
is KotlinAndroidProjectExtension -> compilerOptions | ||
is KotlinJvmProjectExtension -> compilerOptions | ||
else -> TODO("Unsupported project extension $this ${T::class}") | ||
}.apply { | ||
kotlinExtension.jvmToolchain { | ||
languageVersion = JavaLanguageVersion.of(11) | ||
} | ||
allWarningsAsErrors = warningsAsErrors.toBoolean() | ||
freeCompilerArgs.add( | ||
// Enable experimental coroutines APIs, including Flow | ||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", | ||
) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
gradle/build-logic/convention/src/main/kotlin/com/miquido/ProjectExtensions.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,9 @@ | ||
package com.miquido | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
val Project.libs | ||
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs") |
6 changes: 6 additions & 0 deletions
6
gradle/build-logic/convention/src/main/kotlin/com/miquido/Versions.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,6 @@ | ||
package com.miquido | ||
|
||
const val projectVersionName = "1.0.0-beta" | ||
const val projectCompileSdk = 34 | ||
const val projectMinSdk = 23 | ||
const val projectTargetSdk = 34 |
27 changes: 27 additions & 0 deletions
27
gradle/build-logic/convention/src/main/kotlin/deps-management.convention.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,27 @@ | ||
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask | ||
import nl.littlerobots.vcu.plugin.VersionCatalogUpdateExtension | ||
|
||
plugins { | ||
id("com.github.ben-manes.versions") | ||
id("nl.littlerobots.version-catalog-update") | ||
} | ||
|
||
tasks.withType<DependencyUpdatesTask> { | ||
rejectVersionIf { | ||
isNonStable(candidate.version) | ||
} | ||
} | ||
|
||
extensions.configure<VersionCatalogUpdateExtension> { | ||
sortByKey = false | ||
keep { | ||
keepUnusedLibraries = true | ||
} | ||
} | ||
|
||
private fun isNonStable(version: String): Boolean { | ||
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) } | ||
val regex = "^[0-9,.v-]+(-r)?$".toRegex() | ||
val isStable = stableKeyword || regex.matches(version) | ||
return isStable.not() | ||
} |
30 changes: 30 additions & 0 deletions
30
gradle/build-logic/convention/src/main/kotlin/detekt.convention.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,30 @@ | ||
import com.miquido.libs | ||
|
||
val detektConfiguration: Configuration by configurations.creating | ||
|
||
dependencies { | ||
detektConfiguration(libs.findLibrary("detekt").get()) | ||
detektConfiguration(libs.findLibrary("detekt-rules-libraries").get()) | ||
} | ||
|
||
tasks.register("detekt", JavaExec::class) { | ||
group = "verification" | ||
description = "Check Kotlin code style." | ||
classpath = detektConfiguration | ||
mainClass.set("io.gitlab.arturbosch.detekt.cli.Main") | ||
inputs.files(fileTree("src").matching { | ||
include("**/*.kt") | ||
exclude("test/**/*.kt", "androidTest/**/*.kt") | ||
}) | ||
outputs.file("build/reports/detekt-report.xml") | ||
outputs.cacheIf { true } | ||
|
||
args = listOf( | ||
"--input", "src", | ||
"--excludes", "src/test/**,src/androidTest/**", | ||
"--config", "$rootDir/.codeStyleConfig/detekt-config.yml", | ||
"--report", "xml:build/reports/detekt-report.xml,html:build/reports/detekt-report.html" | ||
) | ||
|
||
maxHeapSize = "256m" | ||
} |
10 changes: 10 additions & 0 deletions
10
gradle/build-logic/convention/src/main/kotlin/jvm-library.convention.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,10 @@ | ||
import com.miquido.configureKotlinJvm | ||
|
||
plugins { | ||
id("org.jetbrains.kotlin.jvm") | ||
id("lint.convention") | ||
id("ktlint.convention") | ||
id("detekt.convention") | ||
} | ||
|
||
configureKotlinJvm() |
29 changes: 29 additions & 0 deletions
29
gradle/build-logic/convention/src/main/kotlin/ktlint.convention.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,29 @@ | ||
import com.miquido.libs | ||
|
||
val ktlintConfiguration: Configuration by configurations.creating | ||
|
||
dependencies { | ||
ktlintConfiguration(libs.findLibrary("ktlint").get()) | ||
} | ||
|
||
tasks.register("ktlint", JavaExec::class) { | ||
group = "verification" | ||
description = "Check Kotlin code style." | ||
classpath = ktlintConfiguration | ||
mainClass.set("com.pinterest.ktlint.Main") | ||
inputs.files(fileTree("src").matching { | ||
include("**/*.kt") | ||
exclude("test/**/*.kt", "androidTest/**/*.kt") | ||
}) | ||
outputs.file("build/reports/ktlint-report.xml") | ||
outputs.cacheIf { true } | ||
|
||
args = listOf( | ||
"src/**/*.kt", "!src/test/**/*.kt", "!src/androidTest/**/*.kt", | ||
"--editorconfig=${rootDir}/.codeStyleConfig/.editorconfig", | ||
"--reporter=checkstyle,output=build/reports/ktlint-report.xml", | ||
"--reporter=plain" | ||
) | ||
|
||
maxHeapSize = "256m" | ||
} |
Oops, something went wrong.