Skip to content
Permalink
Browse files

Rewrite gradle configuration using Kotlin DSL (#90)

  • Loading branch information...
msfjarvis committed Dec 7, 2018
1 parent e9f3070 commit c16d11a816c3c7e3f7bab51ef2f32569b6b657bf
Showing with 161 additions and 159 deletions.
  1. +0 −118 app/build.gradle
  2. +113 −0 app/build.gradle.kts
  3. +0 −39 build.gradle
  4. +46 −0 build.gradle.kts
  5. +1 −1 gradle/wrapper/gradle-wrapper.properties
  6. +0 −1 settings.gradle
  7. +1 −0 settings.gradle.kts

This file was deleted.

@@ -0,0 +1,113 @@
import java.io.FileInputStream
import java.util.Properties
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

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

// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
val keystorePropertiesFile = rootProject.file("keystore.properties")

fun gitHash(): String {
try {
return Runtime.getRuntime().exec("git rev-parse --short HEAD").inputStream.reader().use { it.readText() }.trim()
} catch (e: Exception) {
}
return ""
}

android {
compileSdkVersion(28)
dataBinding.isEnabled = true
defaultConfig {
applicationId = "me.msfjarvis.wgandroid"
minSdkVersion(21)
targetSdkVersion(28)
versionCode = 1001
versionName = "1.0.1"
buildConfigField("int", "MIN_SDK_VERSION", "21")
setProperty("archivesBaseName", "wg-android_${gitHash()}")
}
compileOptions {
setSourceCompatibility(JavaVersion.VERSION_1_8)
setTargetCompatibility(JavaVersion.VERSION_1_8)
}
// If the keystore file exists
if (keystorePropertiesFile.exists()) {
// Initialize a new Properties() object called keystoreProperties.
val keystoreProperties = Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(FileInputStream(keystorePropertiesFile))

signingConfigs {
create("release") {
keyAlias = keystoreProperties["keyAlias"].toString()
keyPassword = keystoreProperties["keyPassword"].toString()
storeFile = rootProject.file(keystoreProperties["storeFile"].toString())
storePassword = keystoreProperties["storePassword"].toString()
}
}
}
buildTypes {
getByName("release") {
if (keystorePropertiesFile.exists()) signingConfig = signingConfigs.getByName("release")
externalNativeBuild {
cmake {
arguments.add("-DANDROID_PACKAGE_NAME=${android.defaultConfig.applicationId}")
}
}
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
getByName("debug") {
applicationIdSuffix = ".debug"
versionNameSuffix = "-debug"
externalNativeBuild {
cmake {
arguments.add("-DANDROID_PACKAGE_NAME=${android.defaultConfig.applicationId}")
}
}
isMinifyEnabled = false
}
}
externalNativeBuild.cmake {
path = rootProject.file("app/tools/CMakeLists.txt")
}
lintOptions.isAbortOnError = false
}

dependencies {
implementation("androidx.annotation:annotation:1.0.1")
implementation("androidx.appcompat:appcompat:1.0.2")
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.core:core-ktx:1.0.1")
implementation("androidx.databinding:databinding-adapters:3.2.1")
implementation("androidx.databinding:databinding-runtime:3.2.1")
implementation("androidx.fragment:fragment-ktx:1.0.0")
implementation("androidx.preference:preference:1.0.0")
implementation("com.google.android.material:material:1.0.0")
implementation("com.jakewharton.timber:timber:4.7.1")
implementation("com.journeyapps:zxing-android-embedded:3.6.0")
implementation("net.sourceforge.streamsupport:android-retrofuture:1.7.0")
implementation("net.sourceforge.streamsupport:android-retrostreams:1.7.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.10")
}

repositories {
mavenCentral()
}

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:unchecked")
options.isDeprecation = true
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

This file was deleted.

@@ -0,0 +1,46 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.2.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11")
}
}

plugins {
id("com.github.ben-manes.versions") version "0.20.0"
}

allprojects {
repositories {
google()
jcenter()
}
}

tasks.named<DependencyUpdatesTask>("dependencyUpdates") {
checkForGradleUpdate = true
resolutionStrategy {
componentSelection {
all {
val rejected = listOf("alpha", "beta", "rc", "cr", "m", "preview")
.map { qualifier -> Regex("(?i).*[.-]$qualifier[.\\d-]*") }
.any { it.matches(candidate.version)
}
if (rejected) {
reject("Release candidate")
}
}
}
}
}

tasks {
register("clean", Delete::class) {
delete(rootProject.buildDir)
}
}
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

This file was deleted.

@@ -0,0 +1 @@
include(":app")

0 comments on commit c16d11a

Please sign in to comment.
You can’t perform that action at this time.