Skip to content

Commit

Permalink
Migrate Gradle scripts to Kotlin DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPushkin committed May 17, 2024
1 parent 4c17a65 commit 71d6a09
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 133 deletions.
105 changes: 0 additions & 105 deletions app/build.gradle

This file was deleted.

116 changes: 116 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.androidx.room)
alias(libs.plugins.google.dagger.hilt.android)
alias(libs.plugins.google.devtools.ksp)
}

object Version {
private const val MAJOR = 1
private const val MINOR = 4
private const val PATCH = 0

const val CODE = MAJOR * 10000 + MINOR * 100 + PATCH
const val NAME = "$MAJOR.$MINOR.$PATCH"
}

kotlin {
jvmToolchain(17)
compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}

android {
namespace = "ru.spbu.depnav"
compileSdk = 34

defaultConfig {
applicationId = "ru.spbu.depnav"
minSdk = 21
targetSdk = 34
versionCode = Version.CODE
versionName = Version.NAME

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
val keystorePropertiesFile = rootProject.file("keystore.properties")
if (keystorePropertiesFile.exists()) {
val keystoreProperties = Properties().apply {
load(keystorePropertiesFile.inputStream())
}
create("release") {
storeFile = file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
}
}
}

buildTypes {
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.findByName("release")
}
}

buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
implementation(libs.androidx.lifecycle.runtimeKtx)
implementation(libs.androidx.lifecycle.runtimeCompose)
implementation(libs.androidx.lifecycle.viewmodelCompose)

implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
annotationProcessor(libs.androidx.room.compiler)
ksp(libs.androidx.room.compiler)

implementation(libs.google.dagger.hilt)
ksp(libs.google.dagger.hiltCompiler)

implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.tooling)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.plrapps.mapcompose)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.androidx.test.rules)
androidTestImplementation(libs.androidx.test.extJunit)
}

ksp {
arg("room.incremental", "true")
arg("room.generateKotlin", "true")
}

room {
schemaDirectory("$projectDir/schemas")
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
9 changes: 0 additions & 9 deletions build.gradle

This file was deleted.

9 changes: 9 additions & 0 deletions build.gradle.kts
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.jetbrains.kotlin.android) apply false

// Must be declared in the same scope as AGP to fix https://github.com/google/dagger/issues/3068
alias(libs.plugins.google.dagger.hilt.android) apply false
// Must be declared in the same scope as Hilt
alias(libs.plugins.google.devtools.ksp) apply false
}
18 changes: 0 additions & 18 deletions settings.gradle

This file was deleted.

24 changes: 24 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pluginManagement {
repositories {
google {
content {
includeGroupAndSubgroups("com.android")
includeGroupAndSubgroups("com.google")
includeGroupAndSubgroups("androidx")
}
}
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories {
google()
mavenCentral()
}
}

rootProject.name = "DepNav"
include(":app")

0 comments on commit 71d6a09

Please sign in to comment.