From 344bc0aea65fd272b151beb27cc01c1e95d23a65 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Fri, 1 Feb 2019 15:26:58 +0100 Subject: [PATCH] Move architecture/mvi code to separate gradle module. --- app/build.gradle | 3 +- architecture/build.gradle | 40 +++++++++++++++++++ architecture/proguard-rules.pro | 21 ++++++++++ architecture/src/main/AndroidManifest.xml | 5 +++ .../org/mozilla/fenix/mvi/ActionBusFactory.kt | 0 .../java/org/mozilla/fenix/mvi/Concepts.kt | 1 - .../java/org/mozilla/fenix/mvi/UIComponent.kt | 0 .../main/java/org/mozilla/fenix/mvi/UIView.kt | 0 build.gradle | 4 +- buildSrc/src/main/java/Dependencies.kt | 13 ++++-- settings.gradle | 2 +- 11 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 architecture/build.gradle create mode 100644 architecture/proguard-rules.pro create mode 100644 architecture/src/main/AndroidManifest.xml rename {app => architecture}/src/main/java/org/mozilla/fenix/mvi/ActionBusFactory.kt (100%) rename {app => architecture}/src/main/java/org/mozilla/fenix/mvi/Concepts.kt (97%) rename {app => architecture}/src/main/java/org/mozilla/fenix/mvi/UIComponent.kt (100%) rename {app => architecture}/src/main/java/org/mozilla/fenix/mvi/UIView.kt (100%) diff --git a/app/build.gradle b/app/build.gradle index 28a9ef1a5b80..aac8dc78a4de 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -89,7 +89,8 @@ androidExtensions { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(':architecture') + implementation Deps.kotlin_stdlib implementation Deps.androidx_appcompat implementation Deps.androidx_constraintlayout diff --git a/architecture/build.gradle b/architecture/build.gradle new file mode 100644 index 000000000000..80978e14854a --- /dev/null +++ b/architecture/build.gradle @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 28 + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 28 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +androidExtensions { + experimental = true +} + +dependencies { + implementation Deps.kotlin_stdlib + + implementation Deps.androidx_annotation + implementation Deps.androidx_lifecycle_runtime + + implementation Deps.mozilla_support_base + + implementation Deps.rxAndroid + implementation Deps.rxKotlin +} diff --git a/architecture/proguard-rules.pro b/architecture/proguard-rules.pro new file mode 100644 index 000000000000..f1b424510da5 --- /dev/null +++ b/architecture/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/architecture/src/main/AndroidManifest.xml b/architecture/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..888b439e1b84 --- /dev/null +++ b/architecture/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + diff --git a/app/src/main/java/org/mozilla/fenix/mvi/ActionBusFactory.kt b/architecture/src/main/java/org/mozilla/fenix/mvi/ActionBusFactory.kt similarity index 100% rename from app/src/main/java/org/mozilla/fenix/mvi/ActionBusFactory.kt rename to architecture/src/main/java/org/mozilla/fenix/mvi/ActionBusFactory.kt diff --git a/app/src/main/java/org/mozilla/fenix/mvi/Concepts.kt b/architecture/src/main/java/org/mozilla/fenix/mvi/Concepts.kt similarity index 97% rename from app/src/main/java/org/mozilla/fenix/mvi/Concepts.kt rename to architecture/src/main/java/org/mozilla/fenix/mvi/Concepts.kt index b6fc050dba42..f7d604db81a3 100644 --- a/app/src/main/java/org/mozilla/fenix/mvi/Concepts.kt +++ b/architecture/src/main/java/org/mozilla/fenix/mvi/Concepts.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.mvi import io.reactivex.ObservableTransformer import io.reactivex.subjects.Subject import mozilla.components.support.base.log.logger.Logger -import org.mozilla.fenix.BuildConfig /** * An action is a command or intent the user performed diff --git a/app/src/main/java/org/mozilla/fenix/mvi/UIComponent.kt b/architecture/src/main/java/org/mozilla/fenix/mvi/UIComponent.kt similarity index 100% rename from app/src/main/java/org/mozilla/fenix/mvi/UIComponent.kt rename to architecture/src/main/java/org/mozilla/fenix/mvi/UIComponent.kt diff --git a/app/src/main/java/org/mozilla/fenix/mvi/UIView.kt b/architecture/src/main/java/org/mozilla/fenix/mvi/UIView.kt similarity index 100% rename from app/src/main/java/org/mozilla/fenix/mvi/UIView.kt rename to architecture/src/main/java/org/mozilla/fenix/mvi/UIView.kt diff --git a/build.gradle b/build.gradle index 40c9119654d2..e313ac6970dc 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ task clean(type: Delete) { detekt { // The version number is duplicated, please refer to plugins block for more details version = "1.0.0.RC9.2" - input = files("$projectDir/app") + input = files("$projectDir/app", "$projectDir/architecture") config = files("$projectDir/config/detekt.yml") filters = ".*test.*,.*/resources/.*,.*/tmp/.*" @@ -62,5 +62,5 @@ task ktlint(type: JavaExec, group: "verification") { description = "Check Kotlin code style." classpath = configurations.ktlint main = "com.github.shyiko.ktlint.Main" - args "app/**/*.kt" + args "app/**/*.kt", "architecture/**/*.kt" } \ No newline at end of file diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 546cf46cd23a..aa35dc7a0ffa 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -14,6 +14,9 @@ private object Versions { const val androidx_appcompat = "1.0.2" const val androidx_constraint_layout = "2.0.0-alpha3" const val androidx_preference = "1.1.0-alpha02" + const val androidx_legacy = "1.0.0" + const val androidx_annotation = "1.0.1" + const val androidx_lifecycle = "2.0.0" const val mozilla_android_components = "0.41.0-SNAPSHOT" @@ -21,7 +24,6 @@ private object Versions { const val test_tools = "1.0.2" const val espresso_core = "2.2.2" - const val androidx_legacy = "1.0.0" const val android_arch_navigation = "1.0.0-alpha11" } @@ -42,9 +44,6 @@ object Deps { const val geckoview_nightly_arm = "org.mozilla.geckoview:geckoview-nightly-armeabi-v7a:${Versions.geckoNightly}" const val geckoview_nightly_x86 = "org.mozilla.geckoview:geckoview-nightly-x86:${Versions.geckoNightly}" - const val androidx_appcompat = "androidx.appcompat:appcompat:${Versions.androidx_appcompat}" - const val androidx_constraintlayout = "androidx.constraintlayout:constraintlayout:${Versions.androidx_constraint_layout}" - const val mozilla_concept_engine = "org.mozilla.components:concept-engine:${Versions.mozilla_android_components}" const val mozilla_concept_tabstray = "org.mozilla.components:concept-tabstray:${Versions.mozilla_android_components}" const val mozilla_concept_toolbar = "org.mozilla.components:concept-toolbar:${Versions.mozilla_android_components}" @@ -79,6 +78,7 @@ object Deps { const val mozilla_lib_crash = "org.mozilla.components:lib-crash:${Versions.mozilla_android_components}" + const val mozilla_support_base = "org.mozilla.components:support-base:${Versions.mozilla_android_components}" const val mozilla_support_ktx = "org.mozilla.components:support-ktx:${Versions.mozilla_android_components}" const val sentry = "io.sentry:sentry-android:${Versions.sentry}" @@ -87,8 +87,13 @@ object Deps { const val tools_test_runner = "com.android.support.test:runner:${Versions.test_tools}" const val tools_espresso_core = "com.android.support.test.espresso:espresso-core:${Versions.espresso_core}" + const val androidx_annotation = "androidx.annotation:annotation:${Versions.androidx_annotation}" + const val androidx_appcompat = "androidx.appcompat:appcompat:${Versions.androidx_appcompat}" + const val androidx_constraintlayout = "androidx.constraintlayout:constraintlayout:${Versions.androidx_constraint_layout}" const val androidx_legacy = "androidx.legacy:legacy-support-v4:${Versions.androidx_legacy}" + const val androidx_lifecycle_runtime = "androidx.lifecycle:lifecycle-runtime:${Versions.androidx_lifecycle}" const val androidx_preference = "androidx.preference:preference-ktx:${Versions.androidx_preference}" const val android_arch_navigation = "android.arch.navigation:navigation-fragment:${Versions.android_arch_navigation}" + } diff --git a/settings.gradle b/settings.gradle index e7b4def49cb5..4e84dceafd09 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app' +include ':app', ':architecture'