From 2c20c8bd36589e96388a0bfe851e7229d7f7cf58 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 14:13:28 -0400 Subject: Remove project plugin and use objects --- buildSrc/build.gradle.kts | 9 --- .../kotlin/ca/allanwang/kau/ChangelogGenerator.kt | 6 +- .../main/kotlin/ca/allanwang/kau/Dependencies.kt | 15 +++-- .../src/main/kotlin/ca/allanwang/kau/KauPlugin.kt | 17 ------ .../src/main/kotlin/ca/allanwang/kau/Plugins.kt | 17 +++--- .../src/main/kotlin/ca/allanwang/kau/Versions.kt | 64 +++++++++++----------- 6 files changed, 49 insertions(+), 79 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/ca/allanwang/kau/KauPlugin.kt diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 83a3370..9bd5e13 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -5,15 +5,6 @@ plugins { group = "ca.allanwang" -gradlePlugin { - plugins { - register("kau-plugin") { - id = "ca.allanwang.kau" - implementationClass = "ca.allanwang.kau.KauPlugin" - } - } -} - repositories { mavenCentral() } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt index 5e21b7e..66f28f9 100644 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt +++ b/buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt @@ -3,7 +3,6 @@ package ca.allanwang.kau import groovy.util.Node import groovy.util.XmlParser import org.gradle.api.GradleException -import org.gradle.api.Project import java.io.File /** @@ -20,7 +19,7 @@ import java.io.File * * Outputs a changelog in markdown format */ -open class ChangelogGenerator(private val project: Project) { +object ChangelogGenerator { class ChangelogException(message: String) : GradleException(message) @@ -71,8 +70,7 @@ open class ChangelogGenerator(private val project: Project) { return entries } - @JvmOverloads - fun generate(inputUri: String, outputUri: String = "${project.rootDir}/docs/Changelog.md"): List { + fun generate(inputUri: String, outputUri: String): List { val entries = read(inputUri) val output = File(outputUri) if (output.exists()) { diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt index 9e23ac4..74f482f 100644 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt +++ b/buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt @@ -3,12 +3,11 @@ package ca.allanwang.kau /** * Some common dependencies, backed by the supplied versions */ -open class Dependencies { - private val v = Versions() - val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${v.kotlin}" - val kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${v.kotlin}" - val junit = "junit:junit:${v.junit}" - val espresso = "androidx.test.espresso:espresso-core:${v.espresso}" - val testRunner = "androidx.test.ext:junit:${v.testRunner}" - val testRules = "androidx.test:rules:${v.testRules}" +object Dependencies { + const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}" + const val kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" + const val junit = "junit:junit:${Versions.junit}" + const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" + const val testRunner = "androidx.test.ext:junit:${Versions.testRunner}" + const val testRules = "androidx.test:rules:${Versions.testRules}" } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/KauPlugin.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/KauPlugin.kt deleted file mode 100644 index 6be15e5..0000000 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/KauPlugin.kt +++ /dev/null @@ -1,17 +0,0 @@ -package ca.allanwang.kau - -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.create - -class KauPlugin : Plugin { - - override fun apply(project: Project) { - project.extensions.run { - create("kau") - create("kauDependency") - create("kauPlugin") - create("kauChangelog", project) - } - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt index 30caad7..2be0a59 100644 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt +++ b/buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt @@ -3,13 +3,12 @@ package ca.allanwang.kau /** * Some common buildscript plugins, backed by the supplied versions */ -open class Plugins { - private val v = Versions() - val android = "com.android.tools.build:gradle:${v.gradlePlugin}" - val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${v.kotlin}" - val androidMaven = "com.github.dcendents:android-maven-gradle-plugin:${v.mavenPlugin}" - val playPublisher = "com.github.triplet.gradle:play-publisher:${v.playPublishPlugin}" - val dexCount = "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${v.dexCountPlugin}" - val gitVersion = "com.gladed.androidgitversion:gradle-android-git-version:${v.gitVersionPlugin}" - val spotless = "com.diffplug.spotless:spotless-plugin-gradle:${v.spotless}" +object Plugins { + const val android = "com.android.tools.build:gradle:${Versions.gradlePlugin}" + const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" + const val androidMaven = "com.github.dcendents:android-maven-gradle-plugin:${Versions.mavenPlugin}" + const val playPublisher = "com.github.triplet.gradle:play-publisher:${Versions.playPublishPlugin}" + const val dexCount = "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${Versions.dexCountPlugin}" + const val gitVersion = "com.gladed.androidgitversion:gradle-android-git-version:${Versions.gitVersionPlugin}" + const val spotless = "com.diffplug.spotless:spotless-plugin-gradle:${Versions.spotless}" } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt index d48e236..93cb25e 100644 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt +++ b/buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt @@ -1,80 +1,80 @@ package ca.allanwang.kau -open class Versions { - val coreMinSdk = 19 - val minSdk = 21 - val targetSdk = 28 +object Versions { + const val coreMinSdk = 19 + const val minSdk = 21 + const val targetSdk = 28 // https://developer.android.com/studio/releases/build-tools - val buildTools = "28.0.3" + const val buildTools = "28.0.3" // https://mvnrepository.com/artifact/androidx.appcompat/appcompat?repo=google - val appcompat = "1.0.2" + const val appcompat = "1.0.2" // https://mvnrepository.com/artifact/com.google.android.material/material - val googleMaterial = "1.0.0" + const val googleMaterial = "1.0.0" // https://mvnrepository.com/artifact/androidx.recyclerview/recyclerview - val recyclerView = "1.0.0" + const val recyclerView = "1.0.0" // https://mvnrepository.com/artifact/androidx.cardview/cardview - val cardView = "1.0.0" + const val cardView = "1.0.0" // https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout - val constraintLayout = "1.1.3" + const val constraintLayout = "1.1.3" // https://kotlinlang.org/docs/reference/using-gradle.html - val kotlin = "1.3.31" + const val kotlin = "1.3.31" // https://github.com/Kotlin/kotlinx.coroutines/releases - val coroutines = "1.3.0-M1" + const val coroutines = "1.3.0-M1" // https://github.com/mikepenz/AboutLibraries/releases - val aboutLibraries = "6.2.3" + const val aboutLibraries = "6.2.3" // https://github.com/wasabeef/Blurry/releases - val blurry = "3.0.0" + const val blurry = "3.0.0" // https://github.com/mikepenz/FastAdapter#using-maven - val fastAdapter = "3.3.1" - val fastAdapterCommons = fastAdapter + const val fastAdapter = "3.3.1" + const val fastAdapterCommons = fastAdapter // https://github.com/bumptech/glide/releases - val glide = "4.9.0" + const val glide = "4.9.0" // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency - val iconics = "3.2.5" - val iconicsGoogle = "3.0.1.3" - val iconicsMaterial = "2.2.0.5" - val iconicsCommunity = "3.5.95.1" + const val iconics = "3.2.5" + const val iconicsGoogle = "3.0.1.3" + const val iconicsMaterial = "2.2.0.5" + const val iconicsCommunity = "3.5.95.1" // https://github.com/afollestad/material-dialogs/releases - val materialDialog = "3.0.0-rc2" + const val materialDialog = "3.0.0-rc2" // https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core?repo=google - val espresso = "3.1.1" + const val espresso = "3.1.1" // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api - val junit = "4.12" + const val junit = "4.12" - val testRunner = "1.1.0" + const val testRunner = "1.1.0" // https://mvnrepository.com/artifact/androidx.test/rules?repo=google - val testRules = "1.1.1" + const val testRules = "1.1.1" // https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md - val spotless = "3.18.0" + const val spotless = "3.18.0" // https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google - val gradlePlugin = "3.4.1" + const val gradlePlugin = "3.4.1" // https://github.com/dcendents/android-maven-gradle-plugin/releases - val mavenPlugin = "2.1" + const val mavenPlugin = "2.1" // https://github.com/Triple-T/gradle-play-publisher/releases - val playPublishPlugin = "2.2.1" + const val playPublishPlugin = "2.2.1" // https://github.com/KeepSafe/dexcount-gradle-plugin/releases - val dexCountPlugin = "0.8.6" + const val dexCountPlugin = "0.8.6" // https://github.com/gladed/gradle-android-git-version/releases - val gitVersionPlugin = "0.4.9" + const val gitVersionPlugin = "0.4.9" } \ No newline at end of file -- cgit v1.2.3 From 6fedbcdbc51e3cbc93b920f3fda573e1d2ec780b Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 14:21:53 -0400 Subject: Remove package name --- about/build.gradle | 2 +- adapter/build.gradle | 6 +- android-lib.gradle | 20 ++-- build.gradle | 20 ++-- buildSrc/README.md | 4 +- .../main/groovy/ca/allanwang/kau/Versions.groovy | 57 ------------ buildSrc/src/main/kotlin/ChangelogGenerator.kt | 103 +++++++++++++++++++++ buildSrc/src/main/kotlin/Dependencies.kt | 11 +++ buildSrc/src/main/kotlin/Plugins.kt | 12 +++ buildSrc/src/main/kotlin/Versions.kt | 78 ++++++++++++++++ .../kotlin/ca/allanwang/kau/ChangelogGenerator.kt | 103 --------------------- .../main/kotlin/ca/allanwang/kau/Dependencies.kt | 13 --- .../src/main/kotlin/ca/allanwang/kau/Plugins.kt | 14 --- .../src/main/kotlin/ca/allanwang/kau/Versions.kt | 80 ---------------- colorpicker/build.gradle | 4 +- core-ui/build.gradle | 2 +- core/build.gradle | 22 ++--- kpref-activity/build.gradle | 2 +- mediapicker/build.gradle | 6 +- sample/build.gradle | 26 +++--- 20 files changed, 259 insertions(+), 326 deletions(-) delete mode 100644 buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy create mode 100644 buildSrc/src/main/kotlin/ChangelogGenerator.kt create mode 100644 buildSrc/src/main/kotlin/Dependencies.kt create mode 100644 buildSrc/src/main/kotlin/Plugins.kt create mode 100644 buildSrc/src/main/kotlin/Versions.kt delete mode 100644 buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt delete mode 100644 buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt delete mode 100644 buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt delete mode 100644 buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt diff --git a/about/build.gradle b/about/build.gradle index 29f77c0..3aa9ef2 100644 --- a/about/build.gradle +++ b/about/build.gradle @@ -10,7 +10,7 @@ dependencies { implementation project(':core-ui') implementation project(':adapter') - api("com.mikepenz:aboutlibraries:${kau.aboutLibraries}@aar") { + api("com.mikepenz:aboutlibraries:${Versions.aboutLibraries}@aar") { transitive = false } } diff --git a/adapter/build.gradle b/adapter/build.gradle index a4f2583..8826c7d 100644 --- a/adapter/build.gradle +++ b/adapter/build.gradle @@ -1,12 +1,12 @@ -ext.kauSubModuleMinSdk = kau.coreMinSdk +ext.kauSubModuleMinSdk = Versions.coreMinSdk apply from: '../android-lib.gradle' dependencies { implementation project(':core') - api "com.mikepenz:fastadapter-commons:${kau.fastAdapterCommons}@aar" - api "com.mikepenz:fastadapter:${kau.fastAdapter}@aar" + api "com.mikepenz:fastadapter-commons:${Versions.fastAdapterCommons}@aar" + api "com.mikepenz:fastadapter:${Versions.fastAdapter}@aar" } apply from: '../artifacts.gradle' diff --git a/android-lib.gradle b/android-lib.gradle index e8a4c6d..fd691b2 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -6,15 +6,15 @@ apply plugin: 'com.getkeepsafe.dexcount' group = "ca.allanwang" android { - compileSdkVersion kau.targetSdk - buildToolsVersion kau.buildTools + compileSdkVersion Versions.targetSdk + buildToolsVersion Versions.buildTools androidGitVersion { codeFormat = 'MMNNPPXX' format = '%tag%%.count%%-commit%' } - def kauMinSdk = kau.minSdk + def kauMinSdk = Versions.minSdk if (project.hasProperty('kauSubModuleMinSdk')) kauMinSdk = kauSubModuleMinSdk @@ -26,7 +26,7 @@ android { defaultConfig { minSdkVersion kauMinSdk - targetSdkVersion kau.targetSdk + targetSdkVersion Versions.targetSdk versionName androidGitVersion.name() versionCode androidGitVersion.code() consumerProguardFiles 'progress-proguard.txt' @@ -82,11 +82,11 @@ android { } dependencies { - testImplementation kauDependency.kotlinTest - testImplementation kauDependency.junit + testImplementation Dependencies.kotlinTest + testImplementation Dependencies.junit - androidTestImplementation kauDependency.kotlinTest - androidTestImplementation kauDependency.espresso - androidTestImplementation kauDependency.testRules - androidTestImplementation kauDependency.testRunner + androidTestImplementation Dependencies.kotlinTest + androidTestImplementation Dependencies.espresso + androidTestImplementation Dependencies.testRules + androidTestImplementation Dependencies.testRunner } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 39aba6f..bcdff15 100644 --- a/build.gradle +++ b/build.gradle @@ -6,29 +6,25 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } - apply plugin: "ca.allanwang.kau" - dependencies { - classpath kauPlugin.android - classpath kauPlugin.kotlin - classpath kauPlugin.androidMaven - classpath kauPlugin.playPublisher - classpath kauPlugin.dexCount - classpath kauPlugin.gitVersion - classpath kauPlugin.spotless + classpath Plugins.android + classpath Plugins.kotlin + classpath Plugins.androidMaven + classpath Plugins.playPublisher + classpath Plugins.dexCount + classpath Plugins.gitVersion + classpath Plugins.spotless } wrapper.setDistributionType(Wrapper.DistributionType.ALL) } -apply plugin: "ca.allanwang.kau" - task clean(type: Delete) { delete rootProject.buildDir } task generateChangelogMd { - kauChangelog.generate("${project.rootDir}/sample/src/main/res/xml/kau_changelog.xml") + ChangelogGenerator.generate("${project.rootDir}/sample/src/main/res/xml/kau_changelog.xml", "${project.rootDir}/docs/Changelog.md") } subprojects { diff --git a/buildSrc/README.md b/buildSrc/README.md index 91a60ac..abb6b41 100644 --- a/buildSrc/README.md +++ b/buildSrc/README.md @@ -65,12 +65,12 @@ The versions are taken from `Versions.groovy`, so it is always in sync. > [Dependencies.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy) Contains the dependency string for common libraries. -You are free to use the values through `kauDependency.[tagName]`. +You are free to use the values through `Dependencies..[tagName]`. As an example, adding junit can be done through ```gradle -testImplementation kauDependency.junit +testImplementation Dependencies..junit ``` # Changelog Generator diff --git a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy deleted file mode 100644 index d767a8a..0000000 --- a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy +++ /dev/null @@ -1,57 +0,0 @@ -package ca.allanwang.kau - -class Versions { - static def coreMinSdk = 19 - static def minSdk = 21 - static def targetSdk = 28 - - // https://developer.android.com/studio/releases/build-tools - static def buildTools = '28.0.3' - - // https://developer.android.com/topic/libraries/support-library/revisions - static def supportLibs = '28.0.0' - - // https://kotlinlang.org/docs/reference/using-gradle.html - static def kotlin = '1.2.71' - - // https://github.com/mikepenz/AboutLibraries/releases - static def aboutLibraries = '6.1.1' - - // https://github.com/Kotlin/anko/releases - static def anko = '0.10.5' - - // https://github.com/wasabeef/Blurry/releases - static def blurry = '2.1.1' - - // https://dl.google.com/dl/android/maven2/com/android/support/constraint/group-index.xml - static def constraintLayout = '1.1.3' - - // https://github.com/mikepenz/FastAdapter#using-maven - static def fastAdapter = '3.2.9' - static def fastAdapterCommons = fastAdapter - - // https://github.com/bumptech/glide/releases - static def glide = '4.8.0' - - // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency - static def iconics = '3.0.4' - static def iconicsGoogle = '3.0.1.2' - static def iconicsMaterial = '2.2.0.4' - static def iconicsCommunity = '2.0.46.1' - - // https://github.com/afollestad/material-dialogs/releases - static def materialDialog = '0.9.6.0' - - static def espresso = '3.0.1' - static def junit = '4.12' - static def testRunner = '1.0.1' - - static def gradlePlugin = '3.2.1' - static def mavenPlugin = '2.1' - static def playPublishPlugin = '1.2.2' - - // https://github.com/KeepSafe/dexcount-gradle-plugin/releases - static def dexCountPlugin = '0.8.4' - // https://github.com/gladed/gradle-android-git-version/releases - static def gitVersionPlugin = '0.4.5' -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ChangelogGenerator.kt b/buildSrc/src/main/kotlin/ChangelogGenerator.kt new file mode 100644 index 0000000..4be3ecf --- /dev/null +++ b/buildSrc/src/main/kotlin/ChangelogGenerator.kt @@ -0,0 +1,103 @@ +import groovy.util.Node +import groovy.util.XmlParser +import org.gradle.api.GradleException +import java.io.File + +/** + * Given an xml of the format + * + * + * + * + * + * + * + * + * + * + * Outputs a changelog in markdown format + */ +object ChangelogGenerator { + + class ChangelogException(message: String) : GradleException(message) + + private fun fail(message: String): Nothing = + throw ChangelogException(message) + + class ChangelogEntry(val version: String, val items: Array) + + private fun Node.forEachNode(action: (Node) -> Unit) { + children().forEach { + action(it as Node) + } + } + + @JvmStatic + fun read(inputUri: String): List { + val input = File(inputUri) + if (!input.exists()) { + fail("Could not generate changelog from ${input.absolutePath}") + } + + val parser = XmlParser().parse(inputUri) + + val entries: MutableList = mutableListOf() + var version: String? = null + val items: MutableList = mutableListOf() + + fun addEntry() { + version?.also { v -> + entries.add(ChangelogEntry(v, items.toTypedArray())) + items.clear() + } + } + + parser.depthFirst().mapNotNull { it as? Node }.forEach { n -> + when (n.name()) { + "version" -> { + addEntry() + version = n.attribute("title")?.toString() ?: "" + } + "item" -> { + n.attribute("text")?.toString()?.takeIf(String::isNotBlank)?.let { + items.add(it) + } + } + } + } + addEntry() + return entries + } + + @JvmStatic + fun generate(inputUri: String, outputUri: String): List { + val entries = read(inputUri) + val output = File(outputUri) + if (output.exists()) { + if (output.isDirectory) { + fail("Cannot save changelog at directory ${output.absolutePath}") + } + if (output.isFile && !output.delete()) { + fail("Could not delete changelog at ${output.absolutePath}") + } + } else { + output.parentFile.mkdirs() + } + + if (!output.createNewFile()) { + fail("Could not create changelog file at ${output.absolutePath}") + } + val markdown = buildString { + append("# Changelog\n") + entries.forEach { e -> + append("\n## ${e.version}\n") + e.items.forEach { + append("* $it\n") + } + } + } + output.writeText(markdown) + println("Generated changelog at ${output.absolutePath}") + return entries + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt new file mode 100644 index 0000000..3fd40ed --- /dev/null +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -0,0 +1,11 @@ +/** + * Some common dependencies, backed by the supplied versions + */ +object Dependencies { + const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}" + const val kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" + const val junit = "junit:junit:${Versions.junit}" + const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" + const val testRunner = "androidx.test.ext:junit:${Versions.testRunner}" + const val testRules = "androidx.test:rules:${Versions.testRules}" +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Plugins.kt b/buildSrc/src/main/kotlin/Plugins.kt new file mode 100644 index 0000000..e321628 --- /dev/null +++ b/buildSrc/src/main/kotlin/Plugins.kt @@ -0,0 +1,12 @@ +/** + * Some common buildscript plugins, backed by the supplied versions + */ +object Plugins { + const val android = "com.android.tools.build:gradle:${Versions.gradlePlugin}" + const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" + const val androidMaven = "com.github.dcendents:android-maven-gradle-plugin:${Versions.mavenPlugin}" + const val playPublisher = "com.github.triplet.gradle:play-publisher:${Versions.playPublishPlugin}" + const val dexCount = "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${Versions.dexCountPlugin}" + const val gitVersion = "com.gladed.androidgitversion:gradle-android-git-version:${Versions.gitVersionPlugin}" + const val spotless = "com.diffplug.spotless:spotless-plugin-gradle:${Versions.spotless}" +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt new file mode 100644 index 0000000..7f4cdca --- /dev/null +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -0,0 +1,78 @@ +object Versions { + const val coreMinSdk = 19 + const val minSdk = 21 + const val targetSdk = 28 + + // https://developer.android.com/studio/releases/build-tools + const val buildTools = "28.0.3" + + // https://mvnrepository.com/artifact/androidx.appcompat/appcompat?repo=google + const val appcompat = "1.0.2" + + // https://mvnrepository.com/artifact/com.google.android.material/material + const val googleMaterial = "1.0.0" + + // https://mvnrepository.com/artifact/androidx.recyclerview/recyclerview + const val recyclerView = "1.0.0" + + // https://mvnrepository.com/artifact/androidx.cardview/cardview + const val cardView = "1.0.0" + + // https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout + const val constraintLayout = "1.1.3" + + // https://kotlinlang.org/docs/reference/using-gradle.html + const val kotlin = "1.3.31" + + // https://github.com/Kotlin/kotlinx.coroutines/releases + const val coroutines = "1.3.0-M1" + + // https://github.com/mikepenz/AboutLibraries/releases + const val aboutLibraries = "6.2.3" + + // https://github.com/wasabeef/Blurry/releases + const val blurry = "3.0.0" + + // https://github.com/mikepenz/FastAdapter#using-maven + const val fastAdapter = "3.3.1" + const val fastAdapterCommons = fastAdapter + + // https://github.com/bumptech/glide/releases + const val glide = "4.9.0" + + // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency + const val iconics = "3.2.5" + const val iconicsGoogle = "3.0.1.3" + const val iconicsMaterial = "2.2.0.5" + const val iconicsCommunity = "3.5.95.1" + + // https://github.com/afollestad/material-dialogs/releases + const val materialDialog = "3.0.0-rc2" + + // https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core?repo=google + const val espresso = "3.1.1" + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api + const val junit = "4.12" + + const val testRunner = "1.1.0" + + // https://mvnrepository.com/artifact/androidx.test/rules?repo=google + const val testRules = "1.1.1" + + // https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md + const val spotless = "3.18.0" + + // https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google + const val gradlePlugin = "3.4.1" + // https://github.com/dcendents/android-maven-gradle-plugin/releases + const val mavenPlugin = "2.1" + // https://github.com/Triple-T/gradle-play-publisher/releases + const val playPublishPlugin = "2.2.1" + + // https://github.com/KeepSafe/dexcount-gradle-plugin/releases + const val dexCountPlugin = "0.8.6" + + // https://github.com/gladed/gradle-android-git-version/releases + const val gitVersionPlugin = "0.4.9" +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt deleted file mode 100644 index 66f28f9..0000000 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/ChangelogGenerator.kt +++ /dev/null @@ -1,103 +0,0 @@ -package ca.allanwang.kau - -import groovy.util.Node -import groovy.util.XmlParser -import org.gradle.api.GradleException -import java.io.File - -/** - * Given an xml of the format - * - * - * - * - * - * - * - * - * - * - * Outputs a changelog in markdown format - */ -object ChangelogGenerator { - - class ChangelogException(message: String) : GradleException(message) - - private fun fail(message: String): Nothing = - throw ChangelogException(message) - - class ChangelogEntry(val version: String, val items: Array) - - private fun Node.forEachNode(action: (Node) -> Unit) { - children().forEach { - action(it as Node) - } - } - - fun read(inputUri: String): List { - val input = File(inputUri) - if (!input.exists()) { - fail("Could not generate changelog from ${input.absolutePath}") - } - - val parser = XmlParser().parse(inputUri) - - val entries: MutableList = mutableListOf() - var version: String? = null - val items: MutableList = mutableListOf() - - fun addEntry() { - version?.also { v -> - entries.add(ChangelogEntry(v, items.toTypedArray())) - items.clear() - } - } - - parser.depthFirst().mapNotNull { it as? Node }.forEach { n -> - when (n.name()) { - "version" -> { - addEntry() - version = n.attribute("title")?.toString() ?: "" - } - "item" -> { - n.attribute("text")?.toString()?.takeIf(String::isNotBlank)?.let { - items.add(it) - } - } - } - } - addEntry() - return entries - } - - fun generate(inputUri: String, outputUri: String): List { - val entries = read(inputUri) - val output = File(outputUri) - if (output.exists()) { - if (output.isDirectory) { - fail("Cannot save changelog at directory ${output.absolutePath}") - } - if (output.isFile && !output.delete()) { - fail("Could not delete changelog at ${output.absolutePath}") - } - } else { - output.parentFile.mkdirs() - } - - if (!output.createNewFile()) { - fail("Could not create changelog file at ${output.absolutePath}") - } - val markdown = buildString { - append("# Changelog\n") - entries.forEach { e -> - append("\n## ${e.version}\n") - e.items.forEach { - append("* $it\n") - } - } - } - output.writeText(markdown) - println("Generated changelog at ${output.absolutePath}") - return entries - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt deleted file mode 100644 index 74f482f..0000000 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/Dependencies.kt +++ /dev/null @@ -1,13 +0,0 @@ -package ca.allanwang.kau - -/** - * Some common dependencies, backed by the supplied versions - */ -object Dependencies { - const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}" - const val kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" - const val junit = "junit:junit:${Versions.junit}" - const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" - const val testRunner = "androidx.test.ext:junit:${Versions.testRunner}" - const val testRules = "androidx.test:rules:${Versions.testRules}" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt deleted file mode 100644 index 2be0a59..0000000 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/Plugins.kt +++ /dev/null @@ -1,14 +0,0 @@ -package ca.allanwang.kau - -/** - * Some common buildscript plugins, backed by the supplied versions - */ -object Plugins { - const val android = "com.android.tools.build:gradle:${Versions.gradlePlugin}" - const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" - const val androidMaven = "com.github.dcendents:android-maven-gradle-plugin:${Versions.mavenPlugin}" - const val playPublisher = "com.github.triplet.gradle:play-publisher:${Versions.playPublishPlugin}" - const val dexCount = "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${Versions.dexCountPlugin}" - const val gitVersion = "com.gladed.androidgitversion:gradle-android-git-version:${Versions.gitVersionPlugin}" - const val spotless = "com.diffplug.spotless:spotless-plugin-gradle:${Versions.spotless}" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt b/buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt deleted file mode 100644 index 93cb25e..0000000 --- a/buildSrc/src/main/kotlin/ca/allanwang/kau/Versions.kt +++ /dev/null @@ -1,80 +0,0 @@ -package ca.allanwang.kau - -object Versions { - const val coreMinSdk = 19 - const val minSdk = 21 - const val targetSdk = 28 - - // https://developer.android.com/studio/releases/build-tools - const val buildTools = "28.0.3" - - // https://mvnrepository.com/artifact/androidx.appcompat/appcompat?repo=google - const val appcompat = "1.0.2" - - // https://mvnrepository.com/artifact/com.google.android.material/material - const val googleMaterial = "1.0.0" - - // https://mvnrepository.com/artifact/androidx.recyclerview/recyclerview - const val recyclerView = "1.0.0" - - // https://mvnrepository.com/artifact/androidx.cardview/cardview - const val cardView = "1.0.0" - - // https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout - const val constraintLayout = "1.1.3" - - // https://kotlinlang.org/docs/reference/using-gradle.html - const val kotlin = "1.3.31" - - // https://github.com/Kotlin/kotlinx.coroutines/releases - const val coroutines = "1.3.0-M1" - - // https://github.com/mikepenz/AboutLibraries/releases - const val aboutLibraries = "6.2.3" - - // https://github.com/wasabeef/Blurry/releases - const val blurry = "3.0.0" - - // https://github.com/mikepenz/FastAdapter#using-maven - const val fastAdapter = "3.3.1" - const val fastAdapterCommons = fastAdapter - - // https://github.com/bumptech/glide/releases - const val glide = "4.9.0" - - // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency - const val iconics = "3.2.5" - const val iconicsGoogle = "3.0.1.3" - const val iconicsMaterial = "2.2.0.5" - const val iconicsCommunity = "3.5.95.1" - - // https://github.com/afollestad/material-dialogs/releases - const val materialDialog = "3.0.0-rc2" - - // https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core?repo=google - const val espresso = "3.1.1" - - // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api - const val junit = "4.12" - - const val testRunner = "1.1.0" - - // https://mvnrepository.com/artifact/androidx.test/rules?repo=google - const val testRules = "1.1.1" - - // https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md - const val spotless = "3.18.0" - - // https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google - const val gradlePlugin = "3.4.1" - // https://github.com/dcendents/android-maven-gradle-plugin/releases - const val mavenPlugin = "2.1" - // https://github.com/Triple-T/gradle-play-publisher/releases - const val playPublishPlugin = "2.2.1" - - // https://github.com/KeepSafe/dexcount-gradle-plugin/releases - const val dexCountPlugin = "0.8.6" - - // https://github.com/gladed/gradle-android-git-version/releases - const val gitVersionPlugin = "0.4.9" -} \ No newline at end of file diff --git a/colorpicker/build.gradle b/colorpicker/build.gradle index 4b89e10..33e73cc 100644 --- a/colorpicker/build.gradle +++ b/colorpicker/build.gradle @@ -1,13 +1,13 @@ ext.kauSubModuleResourcePrefix = "kau_color_" -ext.kauSubModuleMinSdk = kau.coreMinSdk +ext.kauSubModuleMinSdk = Versions.coreMinSdk apply from: '../android-lib.gradle' dependencies { implementation project(':core') - implementation "com.afollestad.material-dialogs:color:${kau.materialDialog}" + implementation "com.afollestad.material-dialogs:color:${Versions.materialDialog}" } apply from: '../artifacts.gradle' diff --git a/core-ui/build.gradle b/core-ui/build.gradle index 397d4ab..816e53a 100644 --- a/core-ui/build.gradle +++ b/core-ui/build.gradle @@ -1,4 +1,4 @@ -ext.kauSubModuleMinSdk = kau.coreMinSdk +ext.kauSubModuleMinSdk = Versions.coreMinSdk apply from: '../android-lib.gradle' diff --git a/core/build.gradle b/core/build.gradle index 3ac4f36..7ffd789 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,22 +1,22 @@ -ext.kauSubModuleMinSdk = kau.coreMinSdk +ext.kauSubModuleMinSdk = Versions.coreMinSdk apply from: '../android-lib.gradle' dependencies { - api kauDependency.kotlin + api Dependencies..kotlin - api "androidx.appcompat:appcompat:${kau.appcompat}" - api "androidx.recyclerview:recyclerview:${kau.recyclerView}" - api "androidx.cardview:cardview:${kau.cardView}" - api "androidx.constraintlayout:constraintlayout:${kau.constraintLayout}" - api "com.google.android.material:material:${kau.googleMaterial}" + api "androidx.appcompat:appcompat:${Versions.appcompat}" + api "androidx.recyclerview:recyclerview:${Versions.recyclerView}" + api "androidx.cardview:cardview:${Versions.cardView}" + api "androidx.constraintlayout:constraintlayout:${Versions.constraintLayout}" + api "com.google.android.material:material:${Versions.googleMaterial}" - api "org.jetbrains.kotlinx:kotlinx-coroutines-android:${kau.coroutines}" + api "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" - api "com.mikepenz:iconics-core:${kau.iconics}@aar" - api "com.mikepenz:google-material-typeface:${kau.iconicsGoogle}.original@aar" + api "com.mikepenz:iconics-core:${Versions.iconics}@aar" + api "com.mikepenz:google-material-typeface:${Versions.iconicsGoogle}.original@aar" - api "com.afollestad.material-dialogs:core:${kau.materialDialog}" + api "com.afollestad.material-dialogs:core:${Versions.materialDialog}" } apply from: '../artifacts.gradle' diff --git a/kpref-activity/build.gradle b/kpref-activity/build.gradle index ef91e2b..f22a4a0 100644 --- a/kpref-activity/build.gradle +++ b/kpref-activity/build.gradle @@ -1,4 +1,4 @@ -ext.kauSubModuleMinSdk = kau.coreMinSdk +ext.kauSubModuleMinSdk = Versions.coreMinSdk ext.kauSubModuleResourcePrefix = "kau_pref_" diff --git a/mediapicker/build.gradle b/mediapicker/build.gradle index 20d7750..3d4819a 100644 --- a/mediapicker/build.gradle +++ b/mediapicker/build.gradle @@ -1,4 +1,4 @@ -ext.kauSubModuleMinSdk = kau.coreMinSdk +ext.kauSubModuleMinSdk = Versions.coreMinSdk apply from: '../android-lib.gradle' apply plugin: 'kotlin-kapt' @@ -8,8 +8,8 @@ dependencies { implementation project(':adapter') //noinspection GradleDependency - api "com.github.bumptech.glide:glide:${kau.glide}" - implementation "jp.wasabeef:blurry:${kau.blurry}" + api "com.github.bumptech.glide:glide:${Versions.glide}" + implementation "jp.wasabeef:blurry:${Versions.blurry}" } apply from: '../artifacts.gradle' diff --git a/sample/build.gradle b/sample/build.gradle index bb7cab0..b443f51 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -9,8 +9,8 @@ play { } android { - compileSdkVersion kau.targetSdk - buildToolsVersion kau.buildTools + compileSdkVersion Versions.targetSdk + buildToolsVersion Versions.buildTools androidGitVersion { codeFormat = 'MMNNPPXX' @@ -19,8 +19,8 @@ android { defaultConfig { applicationId "ca.allanwang.kau.sample" - minSdkVersion kau.minSdk - targetSdkVersion kau.targetSdk + minSdkVersion Versions.minSdk + targetSdkVersion Versions.targetSdk versionName androidGitVersion.name() versionCode androidGitVersion.code() multiDexEnabled true @@ -122,15 +122,15 @@ dependencies { implementation project(':searchview') implementation project(':mediapicker') - implementation "com.afollestad.material-dialogs:input:${kau.materialDialog}" + implementation "com.afollestad.material-dialogs:input:${Versions.materialDialog}" - testImplementation kauDependency.kotlinTest - testImplementation kauDependency.junit + testImplementation Dependencies..kotlinTest + testImplementation Dependencies..junit - androidTestImplementation kauDependency.kotlinTest - androidTestImplementation kauDependency.espresso - androidTestImplementation "androidx.test.espresso:espresso-intents:${kau.espresso}" - androidTestImplementation "androidx.test.espresso:espresso-contrib:${kau.espresso}" - androidTestImplementation kauDependency.testRules - androidTestImplementation kauDependency.testRunner + androidTestImplementation Dependencies..kotlinTest + androidTestImplementation Dependencies..espresso + androidTestImplementation "androidx.test.espresso:espresso-intents:${Versions.espresso}" + androidTestImplementation "androidx.test.espresso:espresso-contrib:${Versions.espresso}" + androidTestImplementation Dependencies..testRules + androidTestImplementation Dependencies..testRunner } -- cgit v1.2.3 From 940b3142f0a1364ba56e5117e16da51207c44d44 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 14:23:07 -0400 Subject: Remove extra period --- buildSrc/README.md | 4 ++-- core/build.gradle | 2 +- sample/build.gradle | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/buildSrc/README.md b/buildSrc/README.md index abb6b41..8889675 100644 --- a/buildSrc/README.md +++ b/buildSrc/README.md @@ -65,12 +65,12 @@ The versions are taken from `Versions.groovy`, so it is always in sync. > [Dependencies.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy) Contains the dependency string for common libraries. -You are free to use the values through `Dependencies..[tagName]`. +You are free to use the values through `Dependencies.[tagName]`. As an example, adding junit can be done through ```gradle -testImplementation Dependencies..junit +testImplementation Dependencies.junit ``` # Changelog Generator diff --git a/core/build.gradle b/core/build.gradle index 7ffd789..0cba076 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,7 +3,7 @@ ext.kauSubModuleMinSdk = Versions.coreMinSdk apply from: '../android-lib.gradle' dependencies { - api Dependencies..kotlin + api Dependencies.kotlin api "androidx.appcompat:appcompat:${Versions.appcompat}" api "androidx.recyclerview:recyclerview:${Versions.recyclerView}" diff --git a/sample/build.gradle b/sample/build.gradle index b443f51..8f408be 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -124,13 +124,13 @@ dependencies { implementation "com.afollestad.material-dialogs:input:${Versions.materialDialog}" - testImplementation Dependencies..kotlinTest - testImplementation Dependencies..junit + testImplementation Dependencies.kotlinTest + testImplementation Dependencies.junit - androidTestImplementation Dependencies..kotlinTest - androidTestImplementation Dependencies..espresso + androidTestImplementation Dependencies.kotlinTest + androidTestImplementation Dependencies.espresso androidTestImplementation "androidx.test.espresso:espresso-intents:${Versions.espresso}" androidTestImplementation "androidx.test.espresso:espresso-contrib:${Versions.espresso}" - androidTestImplementation Dependencies..testRules - androidTestImplementation Dependencies..testRunner + androidTestImplementation Dependencies.testRules + androidTestImplementation Dependencies.testRunner } -- cgit v1.2.3 From df94b2f706c25514afc447c2cd37ea01dd821cf1 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 14:46:08 -0400 Subject: Add short namespace for plugin --- about/build.gradle | 2 +- adapter/build.gradle | 6 +- android-lib.gradle | 20 ++-- build.gradle | 16 ++-- buildSrc/README.md | 24 ++--- buildSrc/build.gradle.kts | 2 +- buildSrc/src/main/kotlin/ChangelogGenerator.kt | 103 -------------------- buildSrc/src/main/kotlin/Dependencies.kt | 11 --- buildSrc/src/main/kotlin/Plugins.kt | 12 --- buildSrc/src/main/kotlin/Versions.kt | 78 --------------- buildSrc/src/main/kotlin/kau/ChangelogGenerator.kt | 105 +++++++++++++++++++++ buildSrc/src/main/kotlin/kau/Dependencies.kt | 13 +++ buildSrc/src/main/kotlin/kau/Plugins.kt | 14 +++ buildSrc/src/main/kotlin/kau/Versions.kt | 80 ++++++++++++++++ colorpicker/build.gradle | 4 +- core-ui/build.gradle | 2 +- core/build.gradle | 22 ++--- kpref-activity/build.gradle | 2 +- mediapicker/build.gradle | 6 +- sample/build.gradle | 26 ++--- 20 files changed, 278 insertions(+), 270 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/ChangelogGenerator.kt delete mode 100644 buildSrc/src/main/kotlin/Dependencies.kt delete mode 100644 buildSrc/src/main/kotlin/Plugins.kt delete mode 100644 buildSrc/src/main/kotlin/Versions.kt create mode 100644 buildSrc/src/main/kotlin/kau/ChangelogGenerator.kt create mode 100644 buildSrc/src/main/kotlin/kau/Dependencies.kt create mode 100644 buildSrc/src/main/kotlin/kau/Plugins.kt create mode 100644 buildSrc/src/main/kotlin/kau/Versions.kt diff --git a/about/build.gradle b/about/build.gradle index 3aa9ef2..7578ce0 100644 --- a/about/build.gradle +++ b/about/build.gradle @@ -10,7 +10,7 @@ dependencies { implementation project(':core-ui') implementation project(':adapter') - api("com.mikepenz:aboutlibraries:${Versions.aboutLibraries}@aar") { + api("com.mikepenz:aboutlibraries:${kau.Versions.aboutLibraries}@aar") { transitive = false } } diff --git a/adapter/build.gradle b/adapter/build.gradle index 8826c7d..a37330e 100644 --- a/adapter/build.gradle +++ b/adapter/build.gradle @@ -1,12 +1,12 @@ -ext.kauSubModuleMinSdk = Versions.coreMinSdk +ext.kauSubModuleMinSdk = kau.Versions.coreMinSdk apply from: '../android-lib.gradle' dependencies { implementation project(':core') - api "com.mikepenz:fastadapter-commons:${Versions.fastAdapterCommons}@aar" - api "com.mikepenz:fastadapter:${Versions.fastAdapter}@aar" + api "com.mikepenz:fastadapter-commons:${kau.Versions.fastAdapterCommons}@aar" + api "com.mikepenz:fastadapter:${kau.Versions.fastAdapter}@aar" } apply from: '../artifacts.gradle' diff --git a/android-lib.gradle b/android-lib.gradle index 598ddcb..2d44be1 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -6,15 +6,15 @@ apply plugin: 'com.getkeepsafe.dexcount' group = "ca.allanwang" android { - compileSdkVersion Versions.targetSdk - buildToolsVersion Versions.buildTools + compileSdkVersion kau.Versions.targetSdk + buildToolsVersion kau.Versions.buildTools androidGitVersion { codeFormat = 'MMNNPPXX' format = '%tag%%.count%%-commit%' } - def kauMinSdk = Versions.minSdk + def kauMinSdk = kau.Versions.minSdk if (project.hasProperty('kauSubModuleMinSdk')) kauMinSdk = kauSubModuleMinSdk @@ -26,7 +26,7 @@ android { defaultConfig { minSdkVersion kauMinSdk - targetSdkVersion Versions.targetSdk + targetSdkVersion kau.Versions.targetSdk versionName androidGitVersion.name() versionCode androidGitVersion.code() consumerProguardFiles 'progress-proguard.txt' @@ -87,11 +87,11 @@ android { } dependencies { - testImplementation Dependencies.kotlinTest - testImplementation Dependencies.junit + testImplementation kau.Dependencies.kotlinTest + testImplementation kau.Dependencies.junit - androidTestImplementation Dependencies.kotlinTest - androidTestImplementation Dependencies.espresso - androidTestImplementation Dependencies.testRules - androidTestImplementation Dependencies.testRunner + androidTestImplementation kau.Dependencies.kotlinTest + androidTestImplementation kau.Dependencies.espresso + androidTestImplementation kau.Dependencies.testRules + androidTestImplementation kau.Dependencies.testRunner } \ No newline at end of file diff --git a/build.gradle b/build.gradle index bcdff15..81655fb 100644 --- a/build.gradle +++ b/build.gradle @@ -7,13 +7,13 @@ buildscript { } dependencies { - classpath Plugins.android - classpath Plugins.kotlin - classpath Plugins.androidMaven - classpath Plugins.playPublisher - classpath Plugins.dexCount - classpath Plugins.gitVersion - classpath Plugins.spotless + classpath kau.Plugins.android + classpath kau.Plugins.kotlin + classpath kau.Plugins.androidMaven + classpath kau.Plugins.playPublisher + classpath kau.Plugins.dexCount + classpath kau.Plugins.gitVersion + classpath kau.Plugins.spotless } wrapper.setDistributionType(Wrapper.DistributionType.ALL) @@ -24,7 +24,7 @@ task clean(type: Delete) { } task generateChangelogMd { - ChangelogGenerator.generate("${project.rootDir}/sample/src/main/res/xml/kau_changelog.xml", "${project.rootDir}/docs/Changelog.md") + kau.ChangelogGenerator.generate("${project.rootDir}/sample/src/main/res/xml/kau_changelog.xml", "${project.rootDir}/docs/Changelog.md") } subprojects { diff --git a/buildSrc/README.md b/buildSrc/README.md index 8889675..f79303c 100644 --- a/buildSrc/README.md +++ b/buildSrc/README.md @@ -9,9 +9,9 @@ As a note, this is located under `buildSrc` as it is automatically included when Everything here is used when generating the library, so it's always tested. ## Contents -* [Versions](#versions) -* [Plugins](#plugins) -* [Dependencies](#dependencies) +* [kau.Versions](#versions) +* [kau.Plugins](#plugins) +* [kau.Dependencies](#dependencies) * [Changelog Generator](#changelog-generator) ## Usage @@ -38,9 +38,9 @@ Then where necessary, apply the plugin using apply plugin: 'ca.allanwang.kau' ``` -# Versions +# kau.Versions -> [Versions.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy) +> [kau.Versions.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy) Contains the version code for any external library used in KAU. You are free to use the values through `kau.[tagName]`. @@ -51,26 +51,26 @@ As an example, AppCompat is imported in KAU using api "androidx.appcompat:appcompat:${kau.appcompat}" ``` -# Plugins +# kau.Plugins -> [Plugins.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Plugins.groovy) +> [kau.Plugins.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Plugins.groovy) Unfortunately, it seems like you can't use the plugin directly in the buildscript, so this is mainly internal. The plugins data, found using `kauPlugins.[tagName]` contains a collection of useful plugin classpaths. -The versions are taken from `Versions.groovy`, so it is always in sync. +The versions are taken from `kau.Versions.groovy`, so it is always in sync. -# Dependencies +# kau.Dependencies -> [Dependencies.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy) +> [kau.Dependencies.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy) Contains the dependency string for common libraries. -You are free to use the values through `Dependencies.[tagName]`. +You are free to use the values through `kau.Dependencies.[tagName]`. As an example, adding junit can be done through ```gradle -testImplementation Dependencies.junit +testImplementation kau.Dependencies.junit ``` # Changelog Generator diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 9bd5e13..89cba29 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -6,5 +6,5 @@ plugins { group = "ca.allanwang" repositories { - mavenCentral() + jcenter() } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ChangelogGenerator.kt b/buildSrc/src/main/kotlin/ChangelogGenerator.kt deleted file mode 100644 index 4be3ecf..0000000 --- a/buildSrc/src/main/kotlin/ChangelogGenerator.kt +++ /dev/null @@ -1,103 +0,0 @@ -import groovy.util.Node -import groovy.util.XmlParser -import org.gradle.api.GradleException -import java.io.File - -/** - * Given an xml of the format - * - * - * - * - * - * - * - * - * - * - * Outputs a changelog in markdown format - */ -object ChangelogGenerator { - - class ChangelogException(message: String) : GradleException(message) - - private fun fail(message: String): Nothing = - throw ChangelogException(message) - - class ChangelogEntry(val version: String, val items: Array) - - private fun Node.forEachNode(action: (Node) -> Unit) { - children().forEach { - action(it as Node) - } - } - - @JvmStatic - fun read(inputUri: String): List { - val input = File(inputUri) - if (!input.exists()) { - fail("Could not generate changelog from ${input.absolutePath}") - } - - val parser = XmlParser().parse(inputUri) - - val entries: MutableList = mutableListOf() - var version: String? = null - val items: MutableList = mutableListOf() - - fun addEntry() { - version?.also { v -> - entries.add(ChangelogEntry(v, items.toTypedArray())) - items.clear() - } - } - - parser.depthFirst().mapNotNull { it as? Node }.forEach { n -> - when (n.name()) { - "version" -> { - addEntry() - version = n.attribute("title")?.toString() ?: "" - } - "item" -> { - n.attribute("text")?.toString()?.takeIf(String::isNotBlank)?.let { - items.add(it) - } - } - } - } - addEntry() - return entries - } - - @JvmStatic - fun generate(inputUri: String, outputUri: String): List { - val entries = read(inputUri) - val output = File(outputUri) - if (output.exists()) { - if (output.isDirectory) { - fail("Cannot save changelog at directory ${output.absolutePath}") - } - if (output.isFile && !output.delete()) { - fail("Could not delete changelog at ${output.absolutePath}") - } - } else { - output.parentFile.mkdirs() - } - - if (!output.createNewFile()) { - fail("Could not create changelog file at ${output.absolutePath}") - } - val markdown = buildString { - append("# Changelog\n") - entries.forEach { e -> - append("\n## ${e.version}\n") - e.items.forEach { - append("* $it\n") - } - } - } - output.writeText(markdown) - println("Generated changelog at ${output.absolutePath}") - return entries - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt deleted file mode 100644 index 3fd40ed..0000000 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Some common dependencies, backed by the supplied versions - */ -object Dependencies { - const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}" - const val kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" - const val junit = "junit:junit:${Versions.junit}" - const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" - const val testRunner = "androidx.test.ext:junit:${Versions.testRunner}" - const val testRules = "androidx.test:rules:${Versions.testRules}" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Plugins.kt b/buildSrc/src/main/kotlin/Plugins.kt deleted file mode 100644 index e321628..0000000 --- a/buildSrc/src/main/kotlin/Plugins.kt +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Some common buildscript plugins, backed by the supplied versions - */ -object Plugins { - const val android = "com.android.tools.build:gradle:${Versions.gradlePlugin}" - const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" - const val androidMaven = "com.github.dcendents:android-maven-gradle-plugin:${Versions.mavenPlugin}" - const val playPublisher = "com.github.triplet.gradle:play-publisher:${Versions.playPublishPlugin}" - const val dexCount = "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${Versions.dexCountPlugin}" - const val gitVersion = "com.gladed.androidgitversion:gradle-android-git-version:${Versions.gitVersionPlugin}" - const val spotless = "com.diffplug.spotless:spotless-plugin-gradle:${Versions.spotless}" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt deleted file mode 100644 index 7f4cdca..0000000 --- a/buildSrc/src/main/kotlin/Versions.kt +++ /dev/null @@ -1,78 +0,0 @@ -object Versions { - const val coreMinSdk = 19 - const val minSdk = 21 - const val targetSdk = 28 - - // https://developer.android.com/studio/releases/build-tools - const val buildTools = "28.0.3" - - // https://mvnrepository.com/artifact/androidx.appcompat/appcompat?repo=google - const val appcompat = "1.0.2" - - // https://mvnrepository.com/artifact/com.google.android.material/material - const val googleMaterial = "1.0.0" - - // https://mvnrepository.com/artifact/androidx.recyclerview/recyclerview - const val recyclerView = "1.0.0" - - // https://mvnrepository.com/artifact/androidx.cardview/cardview - const val cardView = "1.0.0" - - // https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout - const val constraintLayout = "1.1.3" - - // https://kotlinlang.org/docs/reference/using-gradle.html - const val kotlin = "1.3.31" - - // https://github.com/Kotlin/kotlinx.coroutines/releases - const val coroutines = "1.3.0-M1" - - // https://github.com/mikepenz/AboutLibraries/releases - const val aboutLibraries = "6.2.3" - - // https://github.com/wasabeef/Blurry/releases - const val blurry = "3.0.0" - - // https://github.com/mikepenz/FastAdapter#using-maven - const val fastAdapter = "3.3.1" - const val fastAdapterCommons = fastAdapter - - // https://github.com/bumptech/glide/releases - const val glide = "4.9.0" - - // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency - const val iconics = "3.2.5" - const val iconicsGoogle = "3.0.1.3" - const val iconicsMaterial = "2.2.0.5" - const val iconicsCommunity = "3.5.95.1" - - // https://github.com/afollestad/material-dialogs/releases - const val materialDialog = "3.0.0-rc2" - - // https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core?repo=google - const val espresso = "3.1.1" - - // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api - const val junit = "4.12" - - const val testRunner = "1.1.0" - - // https://mvnrepository.com/artifact/androidx.test/rules?repo=google - const val testRules = "1.1.1" - - // https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md - const val spotless = "3.18.0" - - // https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google - const val gradlePlugin = "3.4.1" - // https://github.com/dcendents/android-maven-gradle-plugin/releases - const val mavenPlugin = "2.1" - // https://github.com/Triple-T/gradle-play-publisher/releases - const val playPublishPlugin = "2.2.1" - - // https://github.com/KeepSafe/dexcount-gradle-plugin/releases - const val dexCountPlugin = "0.8.6" - - // https://github.com/gladed/gradle-android-git-version/releases - const val gitVersionPlugin = "0.4.9" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/kau/ChangelogGenerator.kt b/buildSrc/src/main/kotlin/kau/ChangelogGenerator.kt new file mode 100644 index 0000000..20e8eef --- /dev/null +++ b/buildSrc/src/main/kotlin/kau/ChangelogGenerator.kt @@ -0,0 +1,105 @@ +package kau + +import groovy.util.Node +import groovy.util.XmlParser +import org.gradle.api.GradleException +import java.io.File + +/** + * Given an xml of the format + * + * + * + * + * + * + * + * + * + * + * Outputs a changelog in markdown format + */ +object ChangelogGenerator { + + class ChangelogException(message: String) : GradleException(message) + + private fun fail(message: String): Nothing = + throw ChangelogException(message) + + class ChangelogEntry(val version: String, val items: Array) + + private fun Node.forEachNode(action: (Node) -> Unit) { + children().forEach { + action(it as Node) + } + } + + @JvmStatic + fun read(inputUri: String): List { + val input = File(inputUri) + if (!input.exists()) { + fail("Could not generate changelog from ${input.absolutePath}") + } + + val parser = XmlParser().parse(inputUri) + + val entries: MutableList = mutableListOf() + var version: String? = null + val items: MutableList = mutableListOf() + + fun addEntry() { + version?.also { v -> + entries.add(ChangelogEntry(v, items.toTypedArray())) + items.clear() + } + } + + parser.depthFirst().mapNotNull { it as? Node }.forEach { n -> + when (n.name()) { + "version" -> { + addEntry() + version = n.attribute("title")?.toString() ?: "" + } + "item" -> { + n.attribute("text")?.toString()?.takeIf(String::isNotBlank)?.let { + items.add(it) + } + } + } + } + addEntry() + return entries + } + + @JvmStatic + fun generate(inputUri: String, outputUri: String): List { + val entries = read(inputUri) + val output = File(outputUri) + if (output.exists()) { + if (output.isDirectory) { + fail("Cannot save changelog at directory ${output.absolutePath}") + } + if (output.isFile && !output.delete()) { + fail("Could not delete changelog at ${output.absolutePath}") + } + } else { + output.parentFile.mkdirs() + } + + if (!output.createNewFile()) { + fail("Could not create changelog file at ${output.absolutePath}") + } + val markdown = buildString { + append("# Changelog\n") + entries.forEach { e -> + append("\n## ${e.version}\n") + e.items.forEach { + append("* $it\n") + } + } + } + output.writeText(markdown) + println("Generated changelog at ${output.absolutePath}") + return entries + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/kau/Dependencies.kt b/buildSrc/src/main/kotlin/kau/Dependencies.kt new file mode 100644 index 0000000..62c938c --- /dev/null +++ b/buildSrc/src/main/kotlin/kau/Dependencies.kt @@ -0,0 +1,13 @@ +package kau + +/** + * Some common dependencies, backed by the supplied versions + */ +object Dependencies { + const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}" + const val kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" + const val junit = "junit:junit:${Versions.junit}" + const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" + const val testRunner = "androidx.test.ext:junit:${Versions.testRunner}" + const val testRules = "androidx.test:rules:${Versions.testRules}" +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/kau/Plugins.kt b/buildSrc/src/main/kotlin/kau/Plugins.kt new file mode 100644 index 0000000..cdee364 --- /dev/null +++ b/buildSrc/src/main/kotlin/kau/Plugins.kt @@ -0,0 +1,14 @@ +package kau + +/** + * Some common buildscript plugins, backed by the supplied versions + */ +object Plugins { + const val android = "com.android.tools.build:gradle:${Versions.gradlePlugin}" + const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" + const val androidMaven = "com.github.dcendents:android-maven-gradle-plugin:${Versions.mavenPlugin}" + const val playPublisher = "com.github.triplet.gradle:play-publisher:${Versions.playPublishPlugin}" + const val dexCount = "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${Versions.dexCountPlugin}" + const val gitVersion = "com.gladed.androidgitversion:gradle-android-git-version:${Versions.gitVersionPlugin}" + const val spotless = "com.diffplug.spotless:spotless-plugin-gradle:${Versions.spotless}" +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/kau/Versions.kt b/buildSrc/src/main/kotlin/kau/Versions.kt new file mode 100644 index 0000000..32db3a5 --- /dev/null +++ b/buildSrc/src/main/kotlin/kau/Versions.kt @@ -0,0 +1,80 @@ +package kau + +object Versions { + const val coreMinSdk = 19 + const val minSdk = 21 + const val targetSdk = 28 + + // https://developer.android.com/studio/releases/build-tools + const val buildTools = "28.0.3" + + // https://mvnrepository.com/artifact/androidx.appcompat/appcompat?repo=google + const val appcompat = "1.0.2" + + // https://mvnrepository.com/artifact/com.google.android.material/material + const val googleMaterial = "1.0.0" + + // https://mvnrepository.com/artifact/androidx.recyclerview/recyclerview + const val recyclerView = "1.0.0" + + // https://mvnrepository.com/artifact/androidx.cardview/cardview + const val cardView = "1.0.0" + + // https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout + const val constraintLayout = "1.1.3" + + // https://kotlinlang.org/docs/reference/using-gradle.html + const val kotlin = "1.3.31" + + // https://github.com/Kotlin/kotlinx.coroutines/releases + const val coroutines = "1.3.0-M1" + + // https://github.com/mikepenz/AboutLibraries/releases + const val aboutLibraries = "6.2.3" + + // https://github.com/wasabeef/Blurry/releases + const val blurry = "3.0.0" + + // https://github.com/mikepenz/FastAdapter#using-maven + const val fastAdapter = "3.3.1" + const val fastAdapterCommons = fastAdapter + + // https://github.com/bumptech/glide/releases + const val glide = "4.9.0" + + // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency + const val iconics = "3.2.5" + const val iconicsGoogle = "3.0.1.3" + const val iconicsMaterial = "2.2.0.5" + const val iconicsCommunity = "3.5.95.1" + + // https://github.com/afollestad/material-dialogs/releases + const val materialDialog = "3.0.0-rc2" + + // https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core?repo=google + const val espresso = "3.1.1" + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api + const val junit = "4.12" + + const val testRunner = "1.1.0" + + // https://mvnrepository.com/artifact/androidx.test/rules?repo=google + const val testRules = "1.1.1" + + // https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md + const val spotless = "3.18.0" + + // https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google + const val gradlePlugin = "3.4.1" + // https://github.com/dcendents/android-maven-gradle-plugin/releases + const val mavenPlugin = "2.1" + // https://github.com/Triple-T/gradle-play-publisher/releases + const val playPublishPlugin = "2.2.1" + + // https://github.com/KeepSafe/dexcount-gradle-plugin/releases + const val dexCountPlugin = "0.8.6" + + // https://github.com/gladed/gradle-android-git-version/releases + const val gitVersionPlugin = "0.4.9" +} \ No newline at end of file diff --git a/colorpicker/build.gradle b/colorpicker/build.gradle index 33e73cc..0b58996 100644 --- a/colorpicker/build.gradle +++ b/colorpicker/build.gradle @@ -1,13 +1,13 @@ ext.kauSubModuleResourcePrefix = "kau_color_" -ext.kauSubModuleMinSdk = Versions.coreMinSdk +ext.kauSubModuleMinSdk = kau.Versions.coreMinSdk apply from: '../android-lib.gradle' dependencies { implementation project(':core') - implementation "com.afollestad.material-dialogs:color:${Versions.materialDialog}" + implementation "com.afollestad.material-dialogs:color:${kau.Versions.materialDialog}" } apply from: '../artifacts.gradle' diff --git a/core-ui/build.gradle b/core-ui/build.gradle index 816e53a..c2732c6 100644 --- a/core-ui/build.gradle +++ b/core-ui/build.gradle @@ -1,4 +1,4 @@ -ext.kauSubModuleMinSdk = Versions.coreMinSdk +ext.kauSubModuleMinSdk = kau.Versions.coreMinSdk apply from: '../android-lib.gradle' diff --git a/core/build.gradle b/core/build.gradle index 0cba076..43cdc6d 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,22 +1,22 @@ -ext.kauSubModuleMinSdk = Versions.coreMinSdk +ext.kauSubModuleMinSdk = kau.Versions.coreMinSdk apply from: '../android-lib.gradle' dependencies { - api Dependencies.kotlin + api kau.Dependencies.kotlin - api "androidx.appcompat:appcompat:${Versions.appcompat}" - api "androidx.recyclerview:recyclerview:${Versions.recyclerView}" - api "androidx.cardview:cardview:${Versions.cardView}" - api "androidx.constraintlayout:constraintlayout:${Versions.constraintLayout}" - api "com.google.android.material:material:${Versions.googleMaterial}" + api "androidx.appcompat:appcompat:${kau.Versions.appcompat}" + api "androidx.recyclerview:recyclerview:${kau.Versions.recyclerView}" + api "androidx.cardview:cardview:${kau.Versions.cardView}" + api "androidx.constraintlayout:constraintlayout:${kau.Versions.constraintLayout}" + api "com.google.android.material:material:${kau.Versions.googleMaterial}" - api "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" + api "org.jetbrains.kotlinx:kotlinx-coroutines-android:${kau.Versions.coroutines}" - api "com.mikepenz:iconics-core:${Versions.iconics}@aar" - api "com.mikepenz:google-material-typeface:${Versions.iconicsGoogle}.original@aar" + api "com.mikepenz:iconics-core:${kau.Versions.iconics}@aar" + api "com.mikepenz:google-material-typeface:${kau.Versions.iconicsGoogle}.original@aar" - api "com.afollestad.material-dialogs:core:${Versions.materialDialog}" + api "com.afollestad.material-dialogs:core:${kau.Versions.materialDialog}" } apply from: '../artifacts.gradle' diff --git a/kpref-activity/build.gradle b/kpref-activity/build.gradle index f22a4a0..e2e2771 100644 --- a/kpref-activity/build.gradle +++ b/kpref-activity/build.gradle @@ -1,4 +1,4 @@ -ext.kauSubModuleMinSdk = Versions.coreMinSdk +ext.kauSubModuleMinSdk = kau.Versions.coreMinSdk ext.kauSubModuleResourcePrefix = "kau_pref_" diff --git a/mediapicker/build.gradle b/mediapicker/build.gradle index 3d4819a..5f4e6a7 100644 --- a/mediapicker/build.gradle +++ b/mediapicker/build.gradle @@ -1,4 +1,4 @@ -ext.kauSubModuleMinSdk = Versions.coreMinSdk +ext.kauSubModuleMinSdk = kau.Versions.coreMinSdk apply from: '../android-lib.gradle' apply plugin: 'kotlin-kapt' @@ -8,8 +8,8 @@ dependencies { implementation project(':adapter') //noinspection GradleDependency - api "com.github.bumptech.glide:glide:${Versions.glide}" - implementation "jp.wasabeef:blurry:${Versions.blurry}" + api "com.github.bumptech.glide:glide:${kau.Versions.glide}" + implementation "jp.wasabeef:blurry:${kau.Versions.blurry}" } apply from: '../artifacts.gradle' diff --git a/sample/build.gradle b/sample/build.gradle index 5f795db..e31a312 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -9,8 +9,8 @@ play { } android { - compileSdkVersion Versions.targetSdk - buildToolsVersion Versions.buildTools + compileSdkVersion kau.Versions.targetSdk + buildToolsVersion kau.Versions.buildTools androidGitVersion { codeFormat = 'MMNNPPXX' @@ -19,8 +19,8 @@ android { defaultConfig { applicationId "ca.allanwang.kau.sample" - minSdkVersion Versions.minSdk - targetSdkVersion Versions.targetSdk + minSdkVersion kau.Versions.minSdk + targetSdkVersion kau.Versions.targetSdk versionName androidGitVersion.name() versionCode androidGitVersion.code() multiDexEnabled true @@ -127,15 +127,15 @@ dependencies { implementation project(':searchview') implementation project(':mediapicker') - implementation "com.afollestad.material-dialogs:input:${Versions.materialDialog}" + implementation "com.afollestad.material-dialogs:input:${kau.Versions.materialDialog}" - testImplementation Dependencies.kotlinTest - testImplementation Dependencies.junit + testImplementation kau.Dependencies.kotlinTest + testImplementation kau.Dependencies.junit - androidTestImplementation Dependencies.kotlinTest - androidTestImplementation Dependencies.espresso - androidTestImplementation "androidx.test.espresso:espresso-intents:${Versions.espresso}" - androidTestImplementation "androidx.test.espresso:espresso-contrib:${Versions.espresso}" - androidTestImplementation Dependencies.testRules - androidTestImplementation Dependencies.testRunner + androidTestImplementation kau.Dependencies.kotlinTest + androidTestImplementation kau.Dependencies.espresso + androidTestImplementation "androidx.test.espresso:espresso-intents:${kau.Versions.espresso}" + androidTestImplementation "androidx.test.espresso:espresso-contrib:${kau.Versions.espresso}" + androidTestImplementation kau.Dependencies.testRules + androidTestImplementation kau.Dependencies.testRunner } -- cgit v1.2.3 From 7809e09bab7ce7ed17d8236892674d662dc6b8af Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 15:04:33 -0400 Subject: Update gradle plugin docs --- buildSrc/README.md | 72 +++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/buildSrc/README.md b/buildSrc/README.md index f79303c..14ae3d6 100644 --- a/buildSrc/README.md +++ b/buildSrc/README.md @@ -5,75 +5,47 @@ KAU holds quite a big collection of projects, with the intent on making it easy to reuse complex features, and also to update. This plugin aims to help maintain version updates straight from the source, and also adds on a few nice functions. -As a note, this is located under `buildSrc` as it is automatically included when building KAU. +As a note, this is located under `buildSrc` as it is automatically included when building Everything here is used when generating the library, so it's always tested. ## Contents -* [kau.Versions](#versions) -* [kau.Plugins](#plugins) -* [kau.Dependencies](#dependencies) +* [Usage](#usage) +* [Constants](#constants) * [Changelog Generator](#changelog-generator) ## Usage -Firstly, add KAU to the buildscript: +The easiest way to use this is to create your own `buildSrc` folder, and include `ca.allanwang.kau:gradle-plugin:${KAU}` as a dependency. +This way, you can also use items in your buildscript. +You can also add your own classes to manage versions in your app. -```gradle -buildscript { - repositories { - ... - maven { url "https://jitpack.io" } - } - - dependencies { - ... - classpath "ca.allanwang:kau:${KAU}" - } -} -``` - -Then where necessary, apply the plugin using - -```gradle -apply plugin: 'ca.allanwang.kau' -``` - -# kau.Versions - -> [kau.Versions.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy) - -Contains the version code for any external library used in KAU. -You are free to use the values through `kau.[tagName]`. - -As an example, AppCompat is imported in KAU using +When making your own `buildSrc`, make sure you add the jitpack repository: ```gradle -api "androidx.appcompat:appcompat:${kau.appcompat}" +repositories { + ... + maven { url "https://jitpack.io" } +} ``` -# kau.Plugins +--- -> [kau.Plugins.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Plugins.groovy) +Currently, the plugin is a collection of simple classes. -Unfortunately, it seems like you can't use the plugin directly in the buildscript, so this is mainly internal. +## Constants -The plugins data, found using `kauPlugins.[tagName]` contains a collection of useful plugin classpaths. -The versions are taken from `kau.Versions.groovy`, so it is always in sync. +`Versions`, `Plugins`, and `Dependencies` supply constants you can use for your classpath and dependencies -# kau.Dependencies - -> [kau.Dependencies.groovy](/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy) - -Contains the dependency string for common libraries. -You are free to use the values through `kau.Dependencies.[tagName]`. - -As an example, adding junit can be done through +Eg ```gradle -testImplementation kau.Dependencies.junit +dependencies { + ... + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${kau.Versions.coroutines}" +} ``` -# Changelog Generator +## Changelog Generator In conjunction with [core](/core#changelog-xml), the xml changelog can be converted to markdown. @@ -82,7 +54,7 @@ To allow for compilation per build, add your own task: ```gradle task generateChangelogMd() { - kauChangelog.generate([inputPath], [outputPath]) + kau.ChangelogGenerator.generate([inputPath], [outputPath]) } ``` -- cgit v1.2.3 From 29dcfc378bfd1466578a15c5f3b039a4a2d28927 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 15:06:21 -0400 Subject: Update migration --- docs/Migration.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/Migration.md b/docs/Migration.md index 203dc1d..a7162fa 100644 --- a/docs/Migration.md +++ b/docs/Migration.md @@ -15,12 +15,20 @@ Alongside such changes, `:colorpicker` is no longer as necessary. It exists main After Material Dialog 2.x, a decision was made to enforce theming through xml styles only to avoid reflection. As a result, options to supply custom dialog colors are now removed (ie in the changelog dialog and color picker kprefs). -## Update ProgressAnimator +## ProgressAnimator `ProgressAnimator` has been completely rewritten to be an extension of `ValueAnimator`. This for the most part is not a breaking change, apart from the fact that creating an animator will not start it immediately. Make sure to call `.start()` to begin the animation. +## Gradle Plugin + +The plugin has been converted to kotlin objects. +Now, usage is done through the classes directly, and no extensions are provided within the project. +For instance, instead of using `kauDependencies`, we now use `kau.Dependencies`. +There is also no longer a need to use `apply plugin 'ca.allanwang.kau'`; +adding the plugin to the classpath suffices. + # v4.0.1-alpha02 * `kauParseFaq` is now synchronous. -- cgit v1.2.3 From db3b6c08b42470bd77b1e8d867a708ca3466baef Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 15:29:53 -0400 Subject: Return md from materialDialog func --- core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index 82d5608..e8680dc 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -203,12 +203,15 @@ fun Context.resolveString(@AttrRes attr: Int, fallback: String = ""): String { inline fun Context.materialDialog( dialogBehavior: DialogBehavior = ModalDialog, action: MaterialDialog.() -> Unit -) { +): MaterialDialog { val dialog = MaterialDialog(this, dialogBehavior) + dialog.action() if (isFinishing) { - return KL.d { "Material Dialog triggered from finishing context; did not show" } + KL.d { "Material Dialog triggered from finishing context; did not show" } + } else { + dialog.show() } - dialog.show(action) + return dialog } fun Context.getDip(value: Float): Float = -- cgit v1.2.3 From d30cdac9ca74ca5e202c681af228fa4ca3a8e389 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jun 2019 15:39:28 -0400 Subject: Use javaversion constants for compile options --- android-lib.gradle | 4 ++-- sample/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android-lib.gradle b/android-lib.gradle index 2d44be1..90ec6bf 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -62,8 +62,8 @@ android { } compileOptions { - sourceCompatibility '1.8' - targetCompatibility '1.8' + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } sourceSets { diff --git a/sample/build.gradle b/sample/build.gradle index e31a312..11be396 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -81,8 +81,8 @@ android { } compileOptions { - sourceCompatibility '1.8' - targetCompatibility '1.8' + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } sourceSets { -- cgit v1.2.3