aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2019-11-06 19:41:15 +0530
committerHarsh Shandilya <msfjarvis@gmail.com>2019-11-06 19:41:15 +0530
commitb2d352e3ea671e84cc4f356a49786d1d3b2eaef6 (patch)
treee33d23a825d3eaa81bc2ce0bd6a621894a36adcc
parent3fcf242c0770eb043b85d9d0a16e408780cf7527 (diff)
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>
-rw-r--r--app/build.gradle106
-rw-r--r--app/build.gradle.kts114
-rw-r--r--build.gradle67
-rw-r--r--build.gradle.kts53
-rw-r--r--buildSrc/build.gradle.kts20
-rw-r--r--buildSrc/src/main/kotlin/SpotlessConfiguration.kt51
-rw-r--r--settings.gradle (renamed from settings.gradle.kts)0
-rw-r--r--spotless.gradle32
-rw-r--r--spotless.license4
-rw-r--r--spotless.root.gradle15
-rw-r--r--versions.gradle41
11 files changed, 265 insertions, 238 deletions
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 00000000..a97ebab7
--- /dev/null
+++ b/app/build.gradle
@@ -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'
+ }
+}
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
deleted file mode 100644
index 1d0955c2..00000000
--- a/app/build.gradle.kts
+++ /dev/null
@@ -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"
- }
- }
-}
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 00000000..a8e3e30b
--- /dev/null
+++ b/build.gradle
@@ -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
+ }
+}
diff --git a/build.gradle.kts b/build.gradle.kts
deleted file mode 100644
index e22b4678..00000000
--- a/build.gradle.kts
+++ /dev/null
@@ -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()
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
deleted file mode 100644
index 24b366c0..00000000
--- a/buildSrc/build.gradle.kts
+++ /dev/null
@@ -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")
-}
diff --git a/buildSrc/src/main/kotlin/SpotlessConfiguration.kt b/buildSrc/src/main/kotlin/SpotlessConfiguration.kt
deleted file mode 100644
index ff8ce05b..00000000
--- a/buildSrc/src/main/kotlin/SpotlessConfiguration.kt
+++ /dev/null
@@ -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()
- }
- }
-}
diff --git a/settings.gradle.kts b/settings.gradle
index d596f738..d596f738 100644
--- a/settings.gradle.kts
+++ b/settings.gradle
diff --git a/spotless.gradle b/spotless.gradle
new file mode 100644
index 00000000..301c4dd7
--- /dev/null
+++ b/spotless.gradle
@@ -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()
+ }
+}
diff --git a/spotless.license b/spotless.license
new file mode 100644
index 00000000..082cdb2e
--- /dev/null
+++ b/spotless.license
@@ -0,0 +1,4 @@
+/*
+ * Copyright © 2014-2019 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
diff --git a/spotless.root.gradle b/spotless.root.gradle
new file mode 100644
index 00000000..9d5b3a86
--- /dev/null
+++ b/spotless.root.gradle
@@ -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()
+ }
+}
diff --git a/versions.gradle b/versions.gradle
new file mode 100644
index 00000000..9670d26b
--- /dev/null
+++ b/versions.gradle
@@ -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'
+ ]
+}