Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #155 from keigomichi/add-composite-build
Browse files Browse the repository at this point in the history
Add composite build
  • Loading branch information
dao0203 authored Feb 10, 2024
2 parents 8335fa7 + 6ce3b09 commit 16031e4
Show file tree
Hide file tree
Showing 20 changed files with 417 additions and 105 deletions.
84 changes: 17 additions & 67 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
@file:Suppress("DSL_SCOPE_VIOLATION")

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.ksp)
alias(libs.plugins.spotless)
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
alias(libs.plugins.tsundokun.android.application)
alias(libs.plugins.tsundokun.android.application.compose)
alias(libs.plugins.tsundokun.android.hilt)
alias(libs.plugins.tsundokun.android.room)
alias(libs.plugins.tsundokun.android.firebase)
alias(libs.plugins.serialization)
kotlin("kapt")
alias(libs.plugins.hilt)
}

android {
namespace = "com.example.tsundokun"
compileSdk = 33

defaultConfig {
applicationId = "com.example.tsundokun"
minSdk = 24
targetSdk = 33
versionCode = 1
versionName = "1.0"

Expand All @@ -37,93 +29,51 @@ android {
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = "1.4.2"
}

packagingOptions {
packaging {
resources {
excludes.add("/META-INF/{AL2.0,LGPL2.1}")
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}

spotless {
kotlin {
target("**/*.kt")
targetExclude("$buildDir/**/*.kt")
targetExclude("bin/**/*.kt")

ktlint("0.49.1")
}
}

dependencies {
implementation(project(":core:model"))

// Jetpack Compose
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphics)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.compose.destinations.core)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.coil.kt)
implementation(libs.coil.compose)
implementation(libs.jsoup)
implementation(libs.room.runtime)
implementation(libs.room.ktx)
implementation(platform("com.google.firebase:firebase-bom:32.2.3"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-config-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")

// Compose Destinations
implementation(libs.compose.destinations.core)
ksp(libs.compose.destinations.ksp)

// Supabase
implementation(platform(libs.supabase.bom))
implementation(libs.supabase.postgrest.kt)
implementation(libs.ktor.client.cio)
implementation(libs.hilt.android)
implementation("com.google.android.gms:play-services-fido:20.1.0")

annotationProcessor(libs.room.compiler)

kapt(libs.hilt.compiler)
kapt(libs.room.compiler)
// Ktor
implementation(libs.ktor.client.cio)

ksp(libs.compose.destinations.ksp)
// Fido
implementation(libs.play.services.fido)

testImplementation(libs.junit)

androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.test.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.compose.ui.test)

debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.testManifest)

}

kapt {
correctErrorTypes = true
}
1 change: 1 addition & 0 deletions build-logic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/convention/build
66 changes: 66 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`kotlin-dsl`
}

group = "com.example.tsundokun.buildlogic"

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.firebase.crashlytics.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.room.gradlePlugin)
compileOnly(libs.ksp.gradlePlugin)
}

gradlePlugin{
plugins{
register("androidApplicationCompose") {
id = "tsundokun.android.application.compose"
implementationClass = "AndroidApplicationComposeConventionPlugin"
}
register("androidApplication"){
id = "tsundokun.android.application"
implementationClass = "AndroidApplicationConventionPlugin"
}
register("androidLibraryCompose"){
id = "tsundokun.android.library.compose"
implementationClass = "AndroidLibraryComposeConventionPlugin"
}
register("androidLibrary"){
id = "tsundokun.android.library"
implementationClass = "AndroidLibraryConventionPlugin"
}
register("androidFeature"){
id = "tsundokun.android.feature"
implementationClass = "AndroidFeatureConventionPlugin"
}
register("androidHilt"){
id = "tsundokun.android.hilt"
implementationClass = "AndroidHiltConventionPlugin"
}
register("androidRoom"){
id = "tsundokun.android.room"
implementationClass = "AndroidRoomConventionPlugin"
}
register("androidFirebase"){
id = "tsundokun.android.firebase"
implementationClass = "AndroidApplicationFirebaseConventionPlugin"
}
register("androidTest"){
id = "tsundokun.android.test"
implementationClass = "AndroidTestConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import com.android.build.api.dsl.ApplicationExtension
import com.example.tsundokun.buildlogic.configureAndroidCompose
import com.example.tsundokun.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
}
extensions.configure<ApplicationExtension> {
configureAndroidCompose(this)
defaultConfig.targetSdk = 33
}

dependencies {
add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get())
add("implementation", libs.findLibrary("androidx.lifecycle.viewModel.compose").get())
add("implementation", libs.findLibrary("androidx.lifecycle.runtime.compose").get())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import com.android.build.api.dsl.ApplicationExtension
import com.example.tsundokun.buildlogic.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

class AndroidApplicationConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
}

extensions.configure<ApplicationExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 33
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import com.example.tsundokun.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

class AndroidApplicationFirebaseConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.google.gms.google-services")
apply("com.google.firebase.crashlytics")
}

dependencies {
val bom = libs.findLibrary("firebase.bom").get()
add("implementation", platform(bom))
add("implementation", libs.findLibrary("firebase.analytics").get())
add("implementation", libs.findLibrary("firebase.config").get())
add("implementation", libs.findLibrary("firebase.crashlytics").get())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import com.example.tsundokun.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

class AndroidFeatureConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("tsundokun.android.library")
apply("tsundokun.android.hilt")
}

dependencies {
add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get())
add("implementation", libs.findLibrary("androidx.lifecycle.viewmodel.compose").get())
add("implementation", libs.findLibrary("androidx.lifecycle.runtime.compose").get())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import com.example.tsundokun.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

class AndroidHiltConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.google.devtools.ksp")
apply("dagger.hilt.android.plugin")
}

dependencies {
add("implementation", libs.findLibrary("hilt-android").get())
add("ksp", libs.findLibrary("hilt-compiler").get())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import com.android.build.gradle.LibraryExtension
import com.example.tsundokun.buildlogic.configureAndroidCompose
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType

class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(project: Project) {
with(project) {
pluginManager.apply("com.android.library")
val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import com.android.build.gradle.LibraryExtension
import com.example.tsundokun.buildlogic.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

class AndroidLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
}

extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 33
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import androidx.room.gradle.RoomExtension
import com.example.tsundokun.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

class AndroidRoomConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("androidx.room")
apply("com.google.devtools.ksp")
}

extensions.configure<RoomExtension> {
schemaDirectory("$projectDir/schemas")
}

dependencies {
add("implementation", libs.findLibrary("room-runtime").get())
add("implementation", libs.findLibrary("room-ktx").get())
add("ksp", libs.findLibrary("room-compiler").get())
}
}
}
}
Loading

0 comments on commit 16031e4

Please sign in to comment.