Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id("com.android.application")
`android-default-config`
}

android {
defaultConfig {
applicationId = Android.id
versionCode = Android.versionCode
versionName = Android.versionName
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
dataBinding = true
}
}

dependencies {
implementation("androidx.constraintlayout:constraintlayout:2.1.1")
}
29 changes: 29 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven("https://plugins.gradle.org/m2/")
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
classpath("org.jlleitschuh.gradle:ktlint-gradle:10.2.0")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
}
}

allprojects {
plugins.apply("org.jlleitschuh.gradle.ktlint")

repositories {
google()
mavenCentral()
}
}

task("clean", Delete::class) {
delete = setOf(rootProject.buildDir)
}
32 changes: 32 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins{
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
val androidGradleVersion = "4.2.2"
val kotlinVersion = "1.5.31"

val compileKotlin: org.jetbrains.kotlin.gradle.tasks.KotlinCompile by tasks
compileKotlin.kotlinOptions {
languageVersion = kotlinVersion
}

gradlePlugin {
plugins {
register("android-default-config") {
id = "android-default-config"
implementationClass = "place.pic.android.plus.scripts.CommonConfig"
}
}
}

repositories {
google()
mavenCentral()
}

dependencies {
implementation("com.android.tools.build:gradle:$androidGradleVersion")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation(gradleApi())
implementation(localGroovy())
}
43 changes: 43 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
object Android {
// android
const val id = "place.pic.android.plus"
const val minSdk = 26
const val targetSdk = 31
const val versionCode = 1
const val versionName = "1.0"
}

object Libs {
const val gradle = "com.android.tools.build:gradle:${Versions.gradle}"

const val coreKtx = "androidx.core:core-ktx:${Versions.coreKtx}"
const val appcompat = "androidx.appcompat:appcompat:${Versions.appcompat}"
const val material = "com.google.android.material:material:${Versions.material}"

object Hilt {
const val hiltPlugin = "com.google.dagger:hilt-android-gradle-plugin:${Versions.hilt}"
const val hiltAndroid = "com.google.dagger:hilt-android:${Versions.hilt}"
const val hiltCompiler = "com.google.dagger:hilt-compiler:${Versions.hilt}"
}

object Lifecycle {
const val viewModel =
"androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.lifecycle_version}"
const val liveData =
"androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycle_version}"
const val lifecycleCompiler =
"androidx.lifecycle:lifecycle-common-java8:${Versions.lifecycle_version}"
}

object Kotlin {
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
const val coroutine =
"org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutine}"
}
}

object TestLib {
const val junit = "junit:junit:${Versions.junit}"
const val extJunit = "androidx.test.ext:junit:${Versions.extJunit}"
const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}"
}
26 changes: 26 additions & 0 deletions buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
object Versions {
// gradle
const val gradle = "7.0.2"

// androidx
const val coreKtx = "1.6.0"
const val appcompat = "1.3.1"

// material
const val material = "1.4.0"

// hilt
const val hilt = "2.39.1"

// lifecycle
const val lifecycle_version = "2.4.0-rc01"

// kotlin
const val kotlin = "1.5.31"
const val coroutine = "1.3.9"

// test
const val junit = "4.13.2"
const val extJunit = "1.1.3"
const val espresso = "3.4.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package place.pic.android.plus.scripts

import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

class CommonConfig : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
plugins.apply("kotlin-android")

configAndroidBlock()
configDependencies()
configTestDependencies()
}
}

private fun Project.configAndroidBlock() = this.extensions.getByType<BaseExtension>()
.run {
compileSdkVersion(Android.targetSdk)

defaultConfig {
minSdkVersion(Android.minSdk)
targetSdkVersion(Android.targetSdk)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFile("consumer-rules.pro")
}

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

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
}

private fun Project.configDependencies() = this.extensions.getByType<BaseExtension>()
.run {
dependencies {
add("implementation", Libs.coreKtx)
add("implementation", Libs.appcompat)
add("implementation", Libs.material)
}
}

private fun Project.configTestDependencies() = this.extensions.getByType<BaseExtension>()
.run {
dependencies {
add("testImplementation", TestLib.junit)
add("androidTestImplementation", TestLib.extJunit)
add("androidTestImplementation", TestLib.espresso)
}
}
}
2 changes: 1 addition & 1 deletion settings.gradle → settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = "AssignmentMVVM"
include ':app'
include(":app")