summaryrefslogtreecommitdiff
path: root/build.gradle
diff options
context:
space:
mode:
Diffstat (limited to 'build.gradle')
-rw-r--r--build.gradle90
1 files changed, 90 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..8dba9aa
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,90 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ ext.buildConfig = [
+ 'compileSdk': 30,
+ 'minSdk' : 24,
+ 'targetSdk' : 30,
+ ]
+
+ apply from: rootProject.file('dependencies.gradle')
+ repositories {
+ google()
+ mavenCentral()
+ jcenter()
+ }
+
+ dependencies {
+ classpath Libs.androidGradlePlugin
+ classpath Libs.Kotlin.gradlePlugin
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+plugins {
+ id 'com.diffplug.spotless' version '5.12.1'
+ id 'com.github.ben-manes.versions' version '0.36.0'
+}
+
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ jcenter()
+ }
+}
+
+subprojects {
+ apply plugin: 'com.diffplug.spotless'
+ spotless {
+ kotlin {
+ target '**/*.kt'
+ targetExclude("$buildDir/**/*.kt")
+ targetExclude('bin/**/*.kt')
+
+ ktlint(Versions.ktlint)
+ licenseHeaderFile rootProject.file('spotless/copyright.kt')
+ }
+ format 'misc', {
+ // define the files to apply `misc` to
+ target '*.gradle', '*.md', '.gitignore'
+
+ // define the steps to apply to those files
+ trimTrailingWhitespace()
+ indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
+ endWithNewline()
+ }
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
+ kotlinOptions {
+ // Treat all Kotlin warnings as errors
+ allWarningsAsErrors = true
+
+ // Set JVM target to 1.8
+ jvmTarget = "1.8"
+ }
+ }
+}
+
+/**
+ * Update dependencyUpdates task to reject versions which are more 'unstable' than our
+ * current version.
+ */
+tasks.named("dependencyUpdates").configure {
+ rejectVersionIf {
+ def current = DependencyUpdates.versionToRelease(it.currentVersion)
+ // If we're using a SNAPSHOT, ignore since we must be doing so for a reason.
+ if (current == ReleaseType.SNAPSHOT) return true
+
+ // Otherwise we reject if the candidate is more 'unstable' than our version
+ def candidate = DependencyUpdates.versionToRelease(it.candidate.version)
+ return candidate.isLessStableThan(current)
+ }
+}
+
+Object propOrDef(String propertyName, Object defaultValue) {
+ def propertyValue = project.properties[propertyName]
+ return propertyValue != null ? propertyValue : defaultValue
+} \ No newline at end of file