From c00ab1009aa512fe89b8965cb0bee3827c64fd98 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Wed, 28 Apr 2021 14:17:57 +0530 Subject: Initialize kotlin flow based mvi library --- .idea/misc.xml | 10 +- build.gradle | 26 +++- dependencies.gradle | 2 +- flow-mvi/.gitignore | 1 + flow-mvi/build.gradle | 30 +++++ .../src/main/java/foundation/e/flowmvi/MyClass.kt | 20 +++ gradle/dependencyGraph.gradle | 140 +++++++++++++++++++++ settings.gradle | 1 + 8 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 flow-mvi/.gitignore create mode 100644 flow-mvi/build.gradle create mode 100644 flow-mvi/src/main/java/foundation/e/flowmvi/MyClass.kt create mode 100644 gradle/dependencyGraph.gradle diff --git a/.idea/misc.xml b/.idea/misc.xml index af6eff4..2f6c31d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ diff --git a/build.gradle b/build.gradle index 8dba9aa..f4952ba 100644 --- a/build.gradle +++ b/build.gradle @@ -4,8 +4,26 @@ buildscript { 'compileSdk': 30, 'minSdk' : 24, 'targetSdk' : 30, + 'version': [ + 'major': 1, + 'minor': 0, + 'patch': 0, + 'build': "alpha", + ], ] + ext.buildConfig.version['name'] = "${buildConfig.version.major}.${buildConfig.version.minor}.${buildConfig.version.patch}" + ext.buildConfig.version['fullName'] = "${buildConfig.version.name}.${buildConfig.version.build}" + def buildNumber + if(buildConfig.version.build == 'alpha') { + buildNumber = -2 + } else if (buildConfig.version.build == 'beta') { + buildNumber = -1 + } else { + buildNumber = 0 + } + ext.buildConfig.version['code'] = buildConfig.version.major * 1000000 + buildConfig.version.minor * 10000 + buildConfig.version.patch * 100 + buildNumber + apply from: rootProject.file('dependencies.gradle') repositories { google() @@ -23,8 +41,8 @@ buildscript { } plugins { - id 'com.diffplug.spotless' version '5.12.1' - id 'com.github.ben-manes.versions' version '0.36.0' + id 'com.diffplug.spotless' version '5.12.4' + id 'com.github.ben-manes.versions' version '0.38.0' } allprojects { @@ -87,4 +105,6 @@ tasks.named("dependencyUpdates").configure { Object propOrDef(String propertyName, Object defaultValue) { def propertyValue = project.properties[propertyName] return propertyValue != null ? propertyValue : defaultValue -} \ No newline at end of file +} + +apply from: file('gradle/dependencyGraph.gradle') diff --git a/dependencies.gradle b/dependencies.gradle index 23d3f02..1787d22 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -19,7 +19,7 @@ libs.leakCanary = "com.squareup.leakcanary:leakcanary-android:2.6" libs.truth = "com.google.truth:truth:1.1" -versions.kotlin = "1.4.32" +versions.kotlin = "1.5.0" libs.Kotlin = [ stdlib: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin", gradlePlugin: "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin", diff --git a/flow-mvi/.gitignore b/flow-mvi/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/flow-mvi/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/flow-mvi/build.gradle b/flow-mvi/build.gradle new file mode 100644 index 0000000..52478d7 --- /dev/null +++ b/flow-mvi/build.gradle @@ -0,0 +1,30 @@ +/* +* Copyright (C) 2021 E FOUNDATION +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +plugins { + id 'java-library' + id 'kotlin' +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +dependencies { + implementation Libs.Kotlin.stdlib +} diff --git a/flow-mvi/src/main/java/foundation/e/flowmvi/MyClass.kt b/flow-mvi/src/main/java/foundation/e/flowmvi/MyClass.kt new file mode 100644 index 0000000..32b47a1 --- /dev/null +++ b/flow-mvi/src/main/java/foundation/e/flowmvi/MyClass.kt @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2021 E FOUNDATION + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package foundation.e.flowmvi + +class MyClass diff --git a/gradle/dependencyGraph.gradle b/gradle/dependencyGraph.gradle new file mode 100644 index 0000000..29eafa4 --- /dev/null +++ b/gradle/dependencyGraph.gradle @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2021 E FOUNDATION + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Taken from https://github.com/JakeWharton/SdkSearch/blob/master/gradle/projectDependencyGraph.gradle + */ + +def font = "Helvetica" + +task projectDependencyGraph { + doLast { + def dot = new File(rootProject.buildDir, 'reports/dependency-graph/project.dot') + dot.parentFile.mkdirs() + dot.delete() + + dot << 'digraph {\n' + dot << " graph [label=\"${rootProject.name}\\n \",labelloc=t,fontsize=30,ranksep=1.4,fontname=\"$font\"];\n" + dot << " node [style=filled, fillcolor=\"#bbbbbb\", fontname=\"$font\"];\n" + dot << " edge [fontname = \"$font\"];" + dot << ' rankdir=TB;\n' + + def rootProjects = [] + def queue = [rootProject] + while (!queue.isEmpty()) { + def project = queue.remove(0) + rootProjects.add(project) + queue.addAll(project.childProjects.values()) + } + + def projects = new LinkedHashSet() + def dependencies = new LinkedHashMap, List>() + def multiplatformProjects = [] + def jsProjects = [] + def androidProjects = [] + def javaProjects = [] + + queue = [rootProject] + while (!queue.isEmpty()) { + def project = queue.remove(0) + queue.addAll(project.childProjects.values()) + + if (project.plugins.hasPlugin('org.jetbrains.kotlin.multiplatform')) { + multiplatformProjects.add(project) + } + if (project.plugins.hasPlugin('org.jetbrains.kotlin.js')) { + jsProjects.add(project) + } + if (project.plugins.hasPlugin('com.android.library') || project.plugins.hasPlugin('com.android.application')) { + androidProjects.add(project) + } + if (project.plugins.hasPlugin('java-library') || project.plugins.hasPlugin('java')) { + javaProjects.add(project) + } + + project.configurations.all { config -> + config.dependencies + .withType(ProjectDependency) + .collect { it.dependencyProject } + .each { dependency -> + projects.add(project) + projects.add(dependency) + rootProjects.remove(dependency) + + def graphKey = new Tuple2(project, dependency) + def traits = dependencies.computeIfAbsent(graphKey) { new ArrayList() } + + if (config.name.toLowerCase().endsWith('implementation')) { + traits.add('style=dotted') + } + } + } + } + + projects = projects.sort { it.path } + + dot << '\n # Projects\n\n' + for (project in projects) { + def traits = [] + + if (rootProjects.contains(project)) { + traits.add('shape=box') + } + + if (multiplatformProjects.contains(project)) { + traits.add('fillcolor="#ffd2b3"') + } else if (jsProjects.contains(project)) { + traits.add('fillcolor="#ffffba"') + } else if (androidProjects.contains(project)) { + traits.add('fillcolor="#baffc9"') + } else if (javaProjects.contains(project)) { + traits.add('fillcolor="#ffb3ba"') + } else { + traits.add('fillcolor="#eeeeee"') + } + + dot << " \"${project.path}\" [${traits.join(", ")}];\n" + } + + dot << '\n {rank = same;' + for (project in projects) { + if (rootProjects.contains(project)) { + dot << " \"${project.path}\";" + } + } + dot << '}\n' + + dot << '\n # Dependencies\n\n' + dependencies.forEach { key, traits -> + dot << " \"${key.first.path}\" -> \"${key.second.path}\"" + if (!traits.isEmpty()) { + dot << " [${traits.join(", ")}]" + } + dot << '\n' + } + + dot << '}\n' + + def p = 'dot -Tpng -O project.dot'.execute([], dot.parentFile) + p.waitFor() + if (p.exitValue() != 0) { + throw new RuntimeException(p.errorStream.text) + } + + println("Project module dependency graph created at ${dot.absolutePath}.png") + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index e39b561..dca731c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ +include ':flow-mvi' include ':app' rootProject.name = "PrivacyCentralApp" \ No newline at end of file -- cgit v1.2.1