Revert back to Groovy DSL

The Kotlin DSL's API is extremely terrible and makes the simplest tasks annoying. It also introduces a very noticeable build overhead that I'd rather not have.

Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
Harsh Shandilya 2019-11-06 19:41:15 +05:30
parent 3fcf242c07
commit b2d352e3ea
No known key found for this signature in database
GPG key ID: C2E74282C2133D62
11 changed files with 265 additions and 238 deletions

106
app/build.gradle Normal file
View file

@ -0,0 +1,106 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
}
android {
defaultConfig {
applicationId 'com.zeapo.pwdstore'
}
lintOptions {
abortOnError = true // make sure build fails with lint errors!
disable 'MissingTranslation', 'PluralsCandidate'
}
packagingOptions {
exclude '.readme'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
release {
minifyEnabled = true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix = '.debug'
versionNameSuffix = '-debug'
minifyEnabled = false
}
}
/*
* To sign release builds, create the file `gradle.properties` in
* $HOME/.gradle or in your project directory with this content:
*
* mStoreFile=/path/to/key.store
* mStorePassword=xxx
* mKeyAlias=alias
* mKeyPassword=xxx
*/
if (project.hasProperty('mStoreFile') &&
project.hasProperty('mStorePassword') &&
project.hasProperty('mKeyAlias') &&
project.hasProperty('mKeyPassword')) {
signingConfigs {
release {
storeFile = file(project.properties['mStoreFile'] as String)
storePassword = project.properties['mStorePassword'] as String
keyAlias = project.properties['mKeyAlias'] as String
keyPassword = project.properties['mKeyPassword'] as String
}
}
buildTypes.release.signingConfig = signingConfigs.release
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:' + versions.appcompat
implementation 'androidx.cardview:cardview:' + versions.cardview
implementation 'androidx.core:core-ktx:' + versions.coreKtx
implementation 'androidx.constraintlayout:constraintlayout:' + versions.constraintLayout
implementation 'androidx.documentfile:documentfile:' + versions.documentfile
implementation 'androidx.preference:preference:' + versions.preference
implementation ('androidx.recyclerview:recyclerview:' + versions.recyclerview) {
force = true
}
implementation 'com.google.android.material:material:' + versions.material
implementation 'androidx.annotation:annotation:' + versions.annotation
implementation 'androidx.biometric:biometric:' + versions.biometric
implementation 'org.sufficientlysecure:openpgp-api:' + versions.openpgp
implementation('org.eclipse.jgit:org.eclipse.jgit:' + versions.jgit) {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation 'com.jcraft:jsch:' + versions.jsch
implementation 'commons-io:commons-io:' + versions.commons_io
implementation 'commons-codec:commons-codec:' + versions.commons_codec
implementation 'org.sufficientlysecure:sshauthentication-api:' + versions.sshauth
// Testing-only dependencies
androidTestImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'org.mockito:mockito-core:3.1.0'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test:rules:1.3.0-alpha02'
androidTestImplementation 'androidx.test.ext:junit:1.1.2-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0-alpha02'
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked'
options.deprecation = true
}
tasks.withType(KotlinCompile) {
kotlinOptions {
jvmTarget = '1.8'
}
}

View file

@ -1,114 +0,0 @@
import org.gradle.api.JavaVersion.VERSION_1_8
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-android-extensions")
id("eclipse")
}
android {
compileSdkVersion(29)
defaultConfig {
applicationId = "com.zeapo.pwdstore"
minSdkVersion(21)
targetSdkVersion(29)
versionCode = 10303
versionName = "1.3.3"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
getByName("debug") {
applicationIdSuffix = ".debug"
}
}
compileOptions {
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
}
lintOptions {
isAbortOnError = true // make sure build fails with lint errors!
disable("MissingTranslation", "PluralsCandidate")
}
packagingOptions {
exclude(".readme")
exclude("META-INF/LICENSE.txt")
exclude("META-INF/NOTICE.txt")
}
/*
* To sign release builds, create the file `gradle.properties` in
* $HOME/.gradle or in your project directory with this content:
*
* mStoreFile=/path/to/key.store
* mStorePassword=xxx
* mKeyAlias=alias
* mKeyPassword=xxx
*/
if (project.hasProperty("mStoreFile") &&
project.hasProperty("mStorePassword") &&
project.hasProperty("mKeyAlias") &&
project.hasProperty("mKeyPassword")) {
signingConfigs {
getByName("release") {
storeFile = file(project.properties["mStoreFile"] as String)
storePassword = project.properties["mStorePassword"] as String
keyAlias = project.properties["mKeyAlias"] as String
keyPassword = project.properties["mKeyPassword"] as String
}
}
buildTypes.getByName("release").signingConfig = signingConfigs.getByName("release")
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.core:core-ktx:1.2.0-beta01")
implementation("androidx.constraintlayout:constraintlayout:2.0.0-beta3")
implementation("androidx.documentfile:documentfile:1.0.1")
implementation("androidx.preference:preference:1.1.0")
implementation("androidx.recyclerview:recyclerview:1.1.0-rc01")
implementation("com.google.android.material:material:1.1.0-alpha10")
implementation("androidx.annotation:annotation:1.1.0")
implementation("androidx.biometric:biometric:1.0.0-rc02")
implementation("org.sufficientlysecure:openpgp-api:12.0")
implementation("org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r") {
exclude(group = "org.apache.httpcomponents", module = "httpclient")
}
implementation("com.jcraft:jsch:0.1.55")
implementation("commons-io:commons-io:2.5")
implementation("commons-codec:commons-codec:1.13")
implementation("com.jayway.android.robotium:robotium-solo:5.6.3")
implementation(kotlin("stdlib-jdk8", KotlinCompilerVersion.VERSION))
implementation("org.sufficientlysecure:sshauthentication-api:1.0")
// Testing-only dependencies
androidTestImplementation("junit:junit:4.13-beta-3")
androidTestImplementation("org.mockito:mockito-core:3.1.0")
androidTestImplementation("androidx.test:runner:1.3.0-alpha02")
androidTestImplementation("androidx.test:rules:1.3.0-alpha02")
androidTestImplementation("androidx.test.ext:junit:1.1.2-alpha02")
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0-alpha02")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.3.0-alpha02")
}
tasks {
withType<JavaCompile> {
options.compilerArgs.add("-Xlint:unchecked")
options.isDeprecation = true
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xnew-inference"
}
}
}

67
build.gradle Normal file
View file

@ -0,0 +1,67 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
buildscript {
apply from: rootProject.file('versions.gradle')
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:' + versions.gradlePlugin
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:' + versions.kotlin
classpath 'com.diffplug.spotless:spotless-plugin-gradle:' + versions.spotless
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
subprojects {
apply from: rootProject.file('versions.gradle')
apply from: rootProject.file('spotless.gradle')
repositories {
google()
jcenter()
}
if (plugins.hasPlugin('kotlin-android')) {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:' + versions.kotlin
}
}
if (it.name == 'app') {
apply plugin: 'com.android.application'
} else {
apply plugin: 'com.android.library'
}
android {
compileSdkVersion versions.compileSdk
buildToolsVersion = versions.buildTools
defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
versionCode versions.versionCode
versionName versions.versionName
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
}
apply from: rootProject.file('spotless.root.gradle')
tasks {
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
}

View file

@ -1,53 +0,0 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.0")
classpath(kotlin("gradle-plugin", "1.3.50"))
}
}
plugins {
id("com.github.ben-manes.versions") version "0.27.0"
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
tasks {
named<DependencyUpdatesTask>("dependencyUpdates") {
resolutionStrategy {
componentSelection {
all {
if (listOf("commons-io", "org.eclipse.jgit").contains(candidate.group)) {
reject("Blacklisted package")
}
}
}
}
checkForGradleUpdate = true
outputFormatter = "json"
outputDir = "build/dependencyUpdates"
reportfileName = "report"
}
named<Wrapper>("wrapper") {
gradleVersion = "5.6.3"
distributionType = Wrapper.DistributionType.ALL
}
}
configureSpotless()

View file

@ -1,20 +0,0 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
plugins {
`kotlin-dsl`
}
repositories {
maven("https://plugins.gradle.org/m2/")
jcenter()
}
kotlinDslPluginOptions {
experimentalWarning.set(false)
}
dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:3.24.3")
}

View file

@ -1,51 +0,0 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
val kotlinLicenseHeader = """/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
""".trimIndent()
fun Project.configureSpotless() {
apply<SpotlessPlugin>()
configure<SpotlessExtension> {
java {
target("**/src/main/**/*.java")
trimTrailingWhitespace()
@Suppress("INACCESSIBLE_TYPE")
licenseHeader(kotlinLicenseHeader)
removeUnusedImports()
googleJavaFormat().aosp()
endWithNewline()
}
kotlinGradle {
target("*.gradle.kts", "gradle/*.gradle.kts", "buildSrc/*.gradle.kts")
ktlint("0.31.0").userData(mapOf("indent_size" to "4", "continuation_indent_size" to "4"))
@Suppress("INACCESSIBLE_TYPE")
licenseHeader(kotlinLicenseHeader, "import|tasks|apply|plugins|include|buildscript")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
kotlin {
target("**/src/main/**/*.kt", "buildSrc/**/*.kt")
ktlint("0.31.0").userData(mapOf("indent_size" to "4", "continuation_indent_size" to "4"))
@Suppress("INACCESSIBLE_TYPE")
licenseHeader(kotlinLicenseHeader, "import|package|class|object|@file")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
}

32
spotless.gradle Normal file
View file

@ -0,0 +1,32 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
format 'xml', {
target '**/src/**/*.xml'
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
java {
target '**/src/**/*.java'
trimTrailingWhitespace()
licenseHeaderFile rootProject.file('spotless.license')
removeUnusedImports()
googleJavaFormat().aosp()
endWithNewline()
}
kotlin {
target '**/src/**/*.kt'
ktlint('0.35.0').userData(['indent_size': '4', 'continuation_indent_size': '8'])
licenseHeaderFile rootProject.file('spotless.license')
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}

4
spotless.license Normal file
View file

@ -0,0 +1,4 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/

15
spotless.root.gradle Normal file
View file

@ -0,0 +1,15 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
groovyGradle {
target '**/*.gradle', '*.gradle'
licenseHeaderFile 'spotless.license', 'import|tasks|apply|plugins|include|buildscript|ext|android'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}

41
versions.gradle Normal file
View file

@ -0,0 +1,41 @@
/*
* Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
ext {
versions = [
// Project
minSdk: 21,
targetSdk: 29,
compileSdk: 29,
versionCode: 10303,
versionName: '1.3.3',
buildTools: '29.0.2',
// Plugins
gradlePlugin: '3.5.1',
kotlin: '1.3.50',
spotless: '3.25.0',
// AndroidX
annotation: '1.1.0',
appcompat: '1.1.0',
biometric: '1.0.0-rc01',
cardview: '1.0.0',
constraintLayout: '2.0.0-beta3',
coreKtx: '1.2.0-beta01',
documentfile: '1.0.1',
fragmentKtx: '1.2.0-beta01',
material: '1.2.0-alpha01',
preference: '1.1.0',
recyclerview: '1.0.0',
// Third party
commons_io: '2.5',
commons_codec: '1.13',
jgit: '3.7.1.201504261725-r',
jsch: '0.1.55',
openpgp: '12.0',
sshauth: '1.0'
]
}