Skip to content

Commit

Permalink
Chore: migrate gradle scripts to kotlin dsl (#58)
Browse files Browse the repository at this point in the history
* chore: migration from .gradle to .gradle.kts

* chore: migration from .gradle to .gradle.kts

* chore: rebase from master
  • Loading branch information
programadorthi authored Oct 15, 2020
1 parent c9a0343 commit c9fe4de
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 214 deletions.
118 changes: 0 additions & 118 deletions app/build.gradle

This file was deleted.

111 changes: 111 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import org.jetbrains.kotlin.gradle.internal.AndroidExtensionsExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.android.application")
kotlin("android")
id("kotlin-android-extensions")
}

android {
compileSdkVersion(AndroidConfig.compileSdk)

val currentVersion = Versioning.getVersion()

defaultConfig {
applicationId = AndroidConfig.applicationId
minSdkVersion(AndroidConfig.minSdk)
targetSdkVersion(AndroidConfig.targetSdk)
versionCode = currentVersion.code
versionName = currentVersion.name
testInstrumentationRunner = AndroidConfig.instrumentationTestRunner

// archivesBaseName = "app-${currentVersion.name}"

resConfigs("pt-rBR")

vectorDrawables.apply {
useSupportLibrary = true
setGeneratedDensities(emptyList())
}
}

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

buildTypes {
getByName("debug") {
isCrunchPngs = false
isMinifyEnabled = false

applicationIdSuffix = ".dev"
// lintOptions { tasks.lint.enabled = false }

defaultConfig {
resConfigs("xxxhdpi")
}

// https://stackoverflow.com/a/55745719
(this@getByName as ExtensionAware).apply {
extra["alwaysUpdateBuildId"] = false
extra["enableCrashlytics"] = false
}
}

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

packagingOptions {
exclude("LICENSE.txt")
exclude("META-INF/DEPENDENCIES")
exclude("META-INF/ASL2.0")
exclude("META-INF/NOTICE")
exclude("META-INF/LICENSE")
exclude("META-INF/main.kotlin_module")
exclude("**/*.properties")
}

lintOptions {
isAbortOnError = false
isIgnoreWarnings = true
isQuiet = true
disable("InvalidPackage", "OldTargetApi")
}

testOptions {
unitTests.apply {
isIncludeAndroidResources = true
}
}
}

dependencies {
implementation(project(":domain"))
implementation(project(":presentation"))
implementation(project(":data"))

implementation(Dependencies.okhttp)
implementation(Dependencies.okhttpInterceptor)

AndroidModule.main.forEach(::implementation)
AndroidModule.unitTesting.forEach(::testImplementation)
AndroidModule.androidTesting.forEach(::androidTestImplementation)
}

extensions.getByType<AndroidExtensionsExtension>().apply {
isExperimental = true
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "${JavaVersion.VERSION_1_8}"
freeCompilerArgs = listOf("-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check")
}
}
45 changes: 0 additions & 45 deletions build.gradle

This file was deleted.

50 changes: 50 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import io.gitlab.arturbosch.detekt.extensions.DetektExtension

buildscript {

repositories {
google()
jcenter()
mavenLocal()
maven(url = "https://kotlin.bintray.com/kotlinx")
maven(url = "https://jitpack.io")
maven(url = "https://maven.fabric.io/public")
maven(url = "https://dl.bintray.com/android/android-tools")
maven(url = "https://plugins.gradle.org/m2/")
}

dependencies {
classpath(BuildPlugins.androidGradlePlugin)
classpath(BuildPlugins.kotlinGradlePlugin)
classpath(BuildPlugins.kotlinxSerializiationPlugin)
classpath(BuildPlugins.ktlint)
classpath(BuildPlugins.detekt)
}
}

allprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "io.gitlab.arturbosch.detekt")

repositories {
google()
jcenter()
mavenLocal()
maven(url = "https://kotlin.bintray.com/kotlinx")
maven(url = "https://jitpack.io")
}

configure<DetektExtension> {
config = files("$rootDir/detekt.yml")
}

configurations.all {
resolutionStrategy {
force("androidx.constraintlayout:constraintlayout:1.1.3")
}
}
}

tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}
15 changes: 0 additions & 15 deletions data/build.gradle

This file was deleted.

18 changes: 18 additions & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apply(from = "../kotlin-module.gradle")

plugins {
kotlin("jvm")
kotlin("plugin.serialization")
}

dependencies {
implementation(project(":domain"))
implementation(Dependencies.coroutines)
implementation(Dependencies.kotlinxSerialization)

StandaloneModule.main.forEach(::implementation)
StandaloneModule.unitTesting.forEach(::testImplementation)

NetworkingDependencies.main.forEach(::implementation)
NetworkingDependencies.testing.forEach(::testImplementation)
}
7 changes: 0 additions & 7 deletions domain/build.gradle

This file was deleted.

11 changes: 11 additions & 0 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply(from = "../kotlin-module.gradle")

plugins {
kotlin("jvm")
}

dependencies {
implementation(Dependencies.coroutines)
StandaloneModule.main.forEach(::implementation)
StandaloneModule.unitTesting.forEach(::testImplementation)
}
2 changes: 0 additions & 2 deletions kotlin-module.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
apply plugin: 'kotlin'

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
Expand Down
Loading

0 comments on commit c9fe4de

Please sign in to comment.