Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Revamp build configuration (#1156)
Browse files Browse the repository at this point in the history
* release: move scripts to scripts directory

Signed-off-by: Harsh Shandilya <[email protected]>

* Move CI secrets to secrets directory

Signed-off-by: Harsh Shandilya <[email protected]>

* gradle: uprev to 6.7

Signed-off-by: Harsh Shandilya <[email protected]>

* gradle: suppress warnings about unsupported options

Signed-off-by: Harsh Shandilya <[email protected]>

* build: update dependencies

Signed-off-by: Harsh Shandilya <[email protected]>

* build: move Gradle plugins to ext

Signed-off-by: Harsh Shandilya <[email protected]>

* build: move configuration tasks to buildSrc

Signed-off-by: Harsh Shandilya <[email protected]>

* CHANGELOG: add entry for #1137

Signed-off-by: Harsh Shandilya <[email protected]>

* Fix lint warnings

Signed-off-by: Harsh Shandilya <[email protected]>
  • Loading branch information
msfjarvis authored Oct 16, 2020
1 parent 92f1aab commit 6c1e41b
Show file tree
Hide file tree
Showing 24 changed files with 222 additions and 97 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v2

- name: Decrypt secrets
run: release/signing-setup.sh "$ENCRYPT_KEY"
run: scripts/signing-setup.sh "$ENCRYPT_KEY"
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}

Expand All @@ -28,10 +28,10 @@ jobs:
arguments: :app:assembleFreeRelease :app:assembleNonFreeRelease

- name: Clean secrets
run: release/signing-cleanup.sh
run: scripts/signing-cleanup.sh

- name: Deploy snapshot
run: release/deploy-snapshot.sh
run: scripts/deploy-snapshot.sh
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v2

- name: Decrypt secrets
run: release/signing-setup.sh "$ENCRYPT_KEY"
run: scripts/signing-setup.sh "$ENCRYPT_KEY"
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}

Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Clean secrets
if: always()
run: release/signing-cleanup.sh
run: scripts/signing-cleanup.sh

create_github_release:
name: Create GitHub Release
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Created by https://www.gitignore.io/api/androidstudio,gradle
# Edit at https://www.gitignore.io/?templates=androidstudio,gradle

Expand Down Expand Up @@ -44,7 +43,7 @@ out/

# Signing files
.signing/
keystore.*
/keystore.*

# Local configuration file (sdk path, etc)
local.properties
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.

- Add GPG key selection step to onboarding flow
- Allow configuring an app-wide HTTP(S) proxy
- Add option to automatically sync repository on app launch

## [1.12.1] - 2020-10-13

Expand Down
16 changes: 7 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import com.android.build.gradle.internal.api.BaseVariantOutputImpl
import java.util.Properties

plugins {
id("com.android.application")
kotlin("android")
`aps-plugin`
}

val keystorePropertiesFile = rootProject.file("keystore.properties")
Expand All @@ -26,13 +28,16 @@ android {

adbOptions.installOptions("--user 0")

buildFeatures.viewBinding = true
buildFeatures.buildConfig = true
buildFeatures {
viewBinding = true
buildConfig = true
}

defaultConfig {
applicationId = "dev.msfjarvis.aps"
versionCode = 11211
versionName = "1.13.0-SNAPSHOT"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

lintOptions {
Expand All @@ -41,13 +46,6 @@ android {
disable("MissingTranslation", "PluralsCandidate", "ImpliedQuantity")
}

packagingOptions {
exclude("**/*.version")
exclude("**/*.txt")
exclude("**/*.kotlin_module")
exclude("**/plugin.properties")
}

buildTypes {
named("release") {
isMinifyEnabled = true
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/oreo_autofill_dataset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -22,7 +23,7 @@
android:adjustViewBounds="true"
android:maxWidth="20dp"
android:maxHeight="20dp"
android:tint="@color/secondary_color"
app:tint="@color/secondary_color"
tools:src="@mipmap/ic_launcher" />

<LinearLayout
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/oreo_autofill_filter_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
android:layout_marginStart="8dp"
android:alpha="0.5"
android:src="@drawable/ic_person_black_24dp"
android:tint="?colorOnPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/title"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorOnPrimary" />

<TextView
android:id="@+id/title"
Expand Down
6 changes: 4 additions & 2 deletions autofill-parser/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
kotlin("android")
id("maven-publish")
id("com.android.library")
id("maven-publish")
kotlin("android")
`aps-plugin`
}

// Type safety can sometimes suck
Expand Down
66 changes: 7 additions & 59 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,24 @@
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.android.build.gradle.BaseExtension
import kotlinx.validation.ApiValidationExtension

buildscript {
apply(from = "buildSrc/buildDependencies.gradle")
val build: Map<Any, Any> by extra
repositories {
google()
jcenter()
// For binary compatibility validator.
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}
dependencies {
classpath(Plugins.agp)
classpath(Plugins.binaryCompatibilityValidator)
classpath(Plugins.kotlin)
classpath(build.getValue("androidGradlePlugin"))
classpath(build.getValue("binaryCompatibilityValidator"))
classpath(build.getValue("kotlinGradlePlugin"))
}
}

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

apply(plugin = "binary-compatibility-validator")

extensions.configure<ApiValidationExtension> {
ignoredProjects = mutableSetOf(
"app"
)
}

subprojects {
repositories {
google()
jcenter()
maven {
setUrl("https://jitpack.io")
}
}
if (name == "app") {
apply(plugin = "com.android.application")
} else {
apply(plugin = "com.android.library")
}
configure<BaseExtension> {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(23)
targetSdkVersion(29)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:unchecked")
options.isDeprecation = true
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn", "-Xallow-result-return-type")
languageVersion = "1.4"
}
}
}

tasks.wrapper {
gradleVersion = "6.6.1"
distributionType = Wrapper.DistributionType.ALL
distributionSha256Sum = "11657af6356b7587bfb37287b5992e94a9686d5c8a0a1b60b87b9928a2decde5"
`binary-compatibility-validator`
`aps-plugin`
}
21 changes: 20 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
apply(from = "buildDependencies.gradle")
val build: Map<Any, Any> by extra

plugins {
`kotlin-dsl`
}

repositories {
jcenter()
google()
gradlePluginPortal()
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}

gradlePlugin {
plugins {
register("aps") {
id = "aps-plugin"
implementationClass = "PasswordStorePlugin"
}
}
}

dependencies {
implementation(build.getValue("kotlinGradlePlugin"))
implementation(build.getValue("androidGradlePlugin"))
implementation(build.getValue("binaryCompatibilityValidator"))
}
11 changes: 11 additions & 0 deletions buildSrc/buildDependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
rootProject.ext.versions = [
agp : '4.1.0',
kotlin : '1.4.10',
binary_compatibility_validator : '0.2.3',
]

rootProject.ext.build = [
androidGradlePlugin : "com.android.tools.build:gradle:${versions.agp}",
kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",
binaryCompatibilityValidator : "org.jetbrains.kotlinx:binary-compatibility-validator:${versions.binary_compatibility_validator}",
]
83 changes: 83 additions & 0 deletions buildSrc/src/main/java/BaseProjectConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/

import com.android.build.gradle.TestedExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.wrapper.Wrapper
import org.gradle.kotlin.dsl.repositories
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/**
* Configure root project.
* Note that classpath dependencies still need to be defined in the `buildscript` block in the top-level build.gradle.kts file.
*/
internal fun Project.configureForRootProject() {
// register task for cleaning the build directory in the root project
tasks.register("clean", Delete::class.java) {
delete(rootProject.buildDir)
}
tasks.withType<Wrapper> {
gradleVersion = "6.7"
distributionType = Wrapper.DistributionType.ALL
distributionSha256Sum = "0080de8491f0918e4f529a6db6820fa0b9e818ee2386117f4394f95feb1d5583"
}
configureBinaryCompatibilityValidator()
}

/**
* Configure all projects including the root project
*/
internal fun Project.configureForAllProjects() {
repositories {
google()
jcenter()
maven { setUrl("https://jitpack.io") }
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs = freeCompilerArgs + additionalCompilerArgs
languageVersion = "1.4"
}
}
tasks.withType<Test> {
maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
testLogging {
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}
}

/**
* Apply baseline configurations for all Android projects (Application and Library).
*/
@Suppress("UnstableApiUsage")
internal fun TestedExtension.configureCommonAndroidOptions() {
compileSdkVersion(29)

defaultConfig {
minSdkVersion(23)
targetSdkVersion(29)
}

packagingOptions {
exclude("**/*.version")
exclude("**/*.txt")
exclude("**/*.kotlin_module")
exclude("**/plugin.properties")
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

testOptions.animationsDisabled = true
}
16 changes: 16 additions & 0 deletions buildSrc/src/main/java/BinaryCompatibilityValidator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/

import kotlinx.validation.ApiValidationExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

internal fun Project.configureBinaryCompatibilityValidator() {
extensions.configure<ApiValidationExtension> {
ignoredProjects = mutableSetOf(
"app"
)
}
}
Loading

0 comments on commit 6c1e41b

Please sign in to comment.