-
Notifications
You must be signed in to change notification settings - Fork 3
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
678f099
commit a823a4d
Showing
24 changed files
with
423 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
`kotlin-dsl-precompiled-script-plugins` | ||
} | ||
|
||
dependencies { | ||
implementation(libs.android.gradle.plugin) | ||
implementation(libs.kotlin.gradle.plugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("androidHilt") { | ||
id = "aidoc.android.hilt" | ||
implementationClass = "org.cazait.HiltAndroidPlugin" | ||
} | ||
register("kotlinHilt") { | ||
id = "aidoc.kotlin.hilt" | ||
implementationClass = "org.cazait.HiltKotlinPlugin" | ||
} | ||
} | ||
} |
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,12 @@ | ||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") | ||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
build-logic/src/main/kotlin/cazait.android.application.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,9 @@ | ||
import cazait.configureKotlinAndroid | ||
import cazait.configureHiltAndroid | ||
|
||
plugins { | ||
id("com.android.application") | ||
} | ||
|
||
configureKotlinAndroid() | ||
configureHiltAndroid() |
3 changes: 3 additions & 0 deletions
3
build-logic/src/main/kotlin/cazait.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,3 @@ | ||
import cazait.configureComposeAndroid | ||
|
||
configureComposeAndroid() |
25 changes: 25 additions & 0 deletions
25
build-logic/src/main/kotlin/cazait.android.feature.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 cazait.configureHiltAndroid | ||
import cazait.libs | ||
|
||
plugins { | ||
id("cazait.android.library") | ||
id("cazait.android.compose") | ||
} | ||
|
||
android { | ||
defaultConfig { | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
} | ||
|
||
configureHiltAndroid() | ||
|
||
dependencies { | ||
val libs = project.extensions.libs | ||
implementation(libs.findLibrary("hilt.navigation.compose").get()) | ||
implementation(libs.findLibrary("androidx.navigation.compose").get()) | ||
androidTestImplementation(libs.findLibrary("androidx.navigation.testing").get()) | ||
|
||
implementation(libs.findLibrary("androidx.lifecycle.viewModelCompose").get()) | ||
implementation(libs.findLibrary("androidx.lifecycle.runtimeCompose").get()) | ||
} |
13 changes: 13 additions & 0 deletions
13
build-logic/src/main/kotlin/cazait.android.library.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,13 @@ | ||
import cazait.configureCoroutineAndroid | ||
import cazait.configureHiltAndroid | ||
import cazait.configureKotest | ||
import cazait.configureKotlinAndroid | ||
|
||
plugins { | ||
id("com.android.library") | ||
} | ||
|
||
configureKotlinAndroid() | ||
configureKotest() | ||
configureCoroutineAndroid() | ||
configureHiltAndroid() |
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,33 @@ | ||
package cazait | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureComposeAndroid() { | ||
val libs = extensions.libs | ||
androidExtension.apply { | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = | ||
libs.findVersion("androidxComposeCompiler").get().toString() | ||
} | ||
|
||
dependencies { | ||
val bom = libs.findLibrary("androidx-compose-bom").get() | ||
add("implementation", platform(bom)) | ||
add("androidTestImplementation", platform(bom)) | ||
|
||
add("implementation", libs.findLibrary("androidx.compose.material3").get()) | ||
add("implementation", libs.findLibrary("androidx.compose.ui").get()) | ||
add("implementation", libs.findLibrary("androidx.constraintlayout.compose").get()) | ||
add("implementation", libs.findLibrary("androidx.compose.ui.tooling.preview").get()) | ||
add("androidTestImplementation", libs.findLibrary("androidx.test.espresso.core").get()) | ||
add("androidTestImplementation", libs.findLibrary("androidx.test.ext.junit").get()) | ||
add("androidTestImplementation", libs.findLibrary("androidx.compose.ui.test").get()) | ||
add("debugImplementation", libs.findLibrary("androidx.compose.ui.tooling").get()) | ||
add("debugImplementation", libs.findLibrary("androidx.compose.ui.testManifest").get()) | ||
} | ||
} | ||
} |
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,20 @@ | ||
package cazait | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureCoroutineAndroid() { | ||
val libs = extensions.libs | ||
configureCoroutineKotlin() | ||
dependencies { | ||
"implementation"(libs.findLibrary("kotlinx.coroutines.android").get()) | ||
} | ||
} | ||
|
||
internal fun Project.configureCoroutineKotlin() { | ||
val libs = extensions.libs | ||
dependencies { | ||
"implementation"(libs.findLibrary("kotlinx.coroutines.core").get()) | ||
"testImplementation"(libs.findLibrary("kotlinx.coroutines.test").get()) | ||
} | ||
} |
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 @@ | ||
package cazait | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.android.build.api.dsl.CommonExtension | ||
import com.android.build.api.dsl.LibraryExtension | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.api.plugins.ExtensionContainer | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
internal val Project.applicationExtension: CommonExtension<*, *, *, *, *> | ||
get() = extensions.getByType<ApplicationExtension>() | ||
|
||
internal val Project.libraryExtension: CommonExtension<*, *, *, *, *> | ||
get() = extensions.getByType<LibraryExtension>() | ||
|
||
internal val Project.androidExtension: CommonExtension<*, *, *, *, *> | ||
get() = runCatching { libraryExtension } | ||
.recoverCatching { applicationExtension } | ||
.onFailure { println("Could not find Library or Application extension from this project") } | ||
.getOrThrow() | ||
|
||
internal val ExtensionContainer.libs: VersionCatalog | ||
get() = getByType<VersionCatalogsExtension>().named("libs") |
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,28 @@ | ||
package cazait | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureHiltAndroid() { | ||
with(pluginManager) { | ||
apply("dagger.hilt.android.plugin") | ||
apply("org.jetbrains.kotlin.kapt") | ||
} | ||
|
||
val libs = extensions.libs | ||
dependencies { | ||
"implementation"(libs.findLibrary("hilt.android").get()) | ||
"kapt"(libs.findLibrary("hilt.android.compiler").get()) | ||
"kaptAndroidTest"(libs.findLibrary("hilt.android.compiler").get()) | ||
} | ||
} | ||
|
||
internal class HiltAndroidPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
configureHiltAndroid() | ||
} | ||
} | ||
} |
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 cazait | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureHiltKotlin() { | ||
with(pluginManager) { | ||
apply("org.jetbrains.kotlin.kapt") | ||
} | ||
|
||
val libs = extensions.libs | ||
dependencies { | ||
"implementation"(libs.findLibrary("hilt.core").get()) | ||
"kapt"(libs.findLibrary("hilt.compiler").get()) | ||
} | ||
} | ||
|
||
internal class HiltKotlinPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
configureHiltKotlin() | ||
} | ||
} | ||
} |
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,16 @@ | ||
package cazait | ||
|
||
import org.gradle.api.Project | ||
|
||
internal fun Project.configureKotestAndroid() { | ||
configureKotest() | ||
configureJUnitAndroid() | ||
} | ||
|
||
internal fun Project.configureJUnitAndroid() { | ||
androidExtension.apply { | ||
testOptions { | ||
unitTests.all { it.useJUnitPlatform() } | ||
} | ||
} | ||
} |
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,21 @@ | ||
package cazait | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.testing.Test | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.withType | ||
|
||
internal fun Project.configureKotest() { | ||
configureJUnit() | ||
val libs = extensions.libs | ||
dependencies { | ||
"testImplementation"(libs.findLibrary("kotest.runner").get()) | ||
"testImplementation"(libs.findLibrary("kotest.assertions").get()) | ||
} | ||
} | ||
|
||
internal fun Project.configureJUnit() { | ||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} | ||
} |
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,66 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
package cazait | ||
|
||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.provideDelegate | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
/** | ||
* https://github.com/android/nowinandroid/blob/main/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt | ||
*/ | ||
internal fun Project.configureKotlinAndroid() { | ||
// Plugins | ||
pluginManager.apply("org.jetbrains.kotlin.android") | ||
|
||
// Android settings | ||
androidExtension.apply { | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
minSdk = 28 | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
isCoreLibraryDesugaringEnabled = true | ||
} | ||
|
||
buildTypes { | ||
getByName("release") { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
} | ||
|
||
configureKotlin() | ||
|
||
val libs = extensions.libs | ||
|
||
dependencies { | ||
add("coreLibraryDesugaring", libs.findLibrary("android.desugarJdkLibs").get()) | ||
} | ||
} | ||
|
||
internal fun Project.configureKotlin() { | ||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
// Treat all Kotlin warnings as errors (disabled by default) | ||
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties | ||
val warningsAsErrors: String? by project | ||
allWarningsAsErrors = warningsAsErrors.toBoolean() | ||
freeCompilerArgs = freeCompilerArgs + listOf( | ||
"-opt-in=kotlin.RequiresOptIn", | ||
) | ||
} | ||
} | ||
} |
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,15 @@ | ||
package cazait | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureVerifyDetekt() { | ||
with(pluginManager) { | ||
apply("io.gitlab.arturbosch.detekt") | ||
} | ||
|
||
val libs = extensions.libs | ||
dependencies { | ||
"detektPlugins"(libs.findLibrary("verify.detektFormatting").get()) | ||
} | ||
} |
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 @@ | ||
/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,10 @@ | ||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
plugins { | ||
id("java-library") | ||
alias(libs.plugins.kotlin.jvm) | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_7 | ||
targetCompatibility = JavaVersion.VERSION_1_7 | ||
} |
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,4 @@ | ||
package org.cazait.core.data | ||
|
||
class MyClass { | ||
} |
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 @@ | ||
/build |
Oops, something went wrong.