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 --- .../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 ---------------- 9 files changed, 204 insertions(+), 267 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 (limited to 'buildSrc/src') 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 -- cgit v1.2.3