Skip to content

Commit

Permalink
[maintenance] migration to kts (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrzegorzBobryk authored Oct 20, 2023
1 parent 63d9b97 commit e339306
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 184 deletions.
60 changes: 0 additions & 60 deletions build.gradle

This file was deleted.

56 changes: 56 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import pl.beavercoding.viewbindingdelegate.buildsrc.detektPlugins

buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath(Libs.androidGradlePlugin)
classpath(Libs.Kotlin.gradlePlugin)
classpath(Libs.Androidx.Navigation.safeArgsPlugin)
classpath(Libs.Ktlint.ktlintGradlePlugin)
classpath(Libs.Detekt.detektGradlePlugin)
}
}

allprojects {
apply(plugin = Libs.Ktlint.ktlintPlugin)
apply(plugin = Libs.Detekt.detektPlugin)

dependencies {
detektPlugins(Libs.Detekt.detektFormatting)
}

configure<KtlintExtension> {
debug.set(true)
}

configure<DetektExtension> {
debug = true
allRules = false
parallel = true
config.setFrom(files("$rootDir/config/detekt.yml"))
buildUponDefaultConfig = true
ignoredBuildTypes = listOf("release")
}
}

tasks.withType<Detekt>().configureEach {
reports {
html.required.set(true)
xml.required.set(false)
txt.required.set(false)
sarif.required.set(false)
md.required.set(false)
}
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
6 changes: 6 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ plugins {
}

repositories {
google()
mavenCentral()
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
implementation("com.android.tools.build:gradle:8.1.2")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pl.beavercoding.viewbindingdelegate.buildsrc

import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.DependencyHandlerScope

fun DependencyHandler.implementation(dependency: Dependency) {
add("implementation", dependency)
}

// https://github.com/detekt/detekt/issues/6555
fun DependencyHandlerScope.detektPlugins(dependencyNotation: Any) {
add("detektPlugins", dependencyNotation)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
@file:Suppress("unused")

package pl.beavercoding.viewbindingdelegate.buildsrc
import org.gradle.api.JavaVersion
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.project
import pl.beavercoding.viewbindingdelegate.buildsrc.implementation

object Libs {
private const val androidGradlePluginVersion = "8.1.2"
const val androidGradlePlugin = "com.android.tools.build:gradle:$androidGradlePluginVersion"
const val junit = "junit:junit:4.13.2"
val java = JavaVersion.VERSION_17

object Androidx {
const val core = "androidx.core:core-ktx:1.12.0"
Expand Down Expand Up @@ -60,3 +64,7 @@ object Libs {
}

}

fun DependencyHandler.viewBinder() {
implementation(project(":view-binder"))
}
69 changes: 0 additions & 69 deletions sample/build.gradle

This file was deleted.

68 changes: 68 additions & 0 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import pl.beavercoding.viewbindingdelegate.buildsrc.Config

plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
id("androidx.navigation.safeargs.kotlin")
}

android {
namespace = "pl.beavercoding.viewbindingdelegate"
compileSdk = Config.compileSdk

defaultConfig {
applicationId = "pl.beavercoding.viewbindingdelegate"
minSdk = Config.minSdk
targetSdk = Config.targetSdk
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = Config.testInstrumentationRunner
}

buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = Libs.java
targetCompatibility = Libs.java
}
kotlinOptions {
jvmTarget = Libs.java.toString()
}
buildFeatures {
viewBinding = true
dataBinding = true
}
}

dependencies {
viewBinder()

// core
implementation(Libs.Androidx.core)
implementation(Libs.Androidx.appcompat)

// views
implementation(Libs.Google.material)
implementation(Libs.Androidx.constraintLayout)
implementation(Libs.Androidx.recyclerView)

// navigation
implementation(Libs.Androidx.Navigation.ui)
implementation(Libs.Androidx.Navigation.fragment)

// leakcanary
debugImplementation(Libs.CanaryLeak.android)
androidTestImplementation(Libs.CanaryLeak.androidTests)

// tests
testImplementation(Libs.junit)
androidTestImplementation(Libs.Androidx.Test.junitExt)
androidTestImplementation(Libs.Androidx.Test.espresso)
}
4 changes: 2 additions & 2 deletions sample/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 All @@ -18,4 +18,4 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
3 changes: 0 additions & 3 deletions settings.gradle

This file was deleted.

19 changes: 19 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rootProject.name = "ViewBindingDelegate"

pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

include(":sample")
include(":view-binder")
Loading

0 comments on commit e339306

Please sign in to comment.