diff --git a/build.gradle.kts b/build.gradle.kts index c7737e7..501302a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,10 +7,6 @@ plugins { group = "norangebit" version = "0.0.1" -val arrowVersion = "0.8.2" -val kluentVersion = "1.48" -val koinVersion = "1.0.2" - repositories { mavenCentral() jcenter() @@ -18,13 +14,19 @@ repositories { dependencies { implementation(kotlin("stdlib-jdk8")) - implementation("io.arrow-kt:arrow-core:$arrowVersion") - implementation("org.koin:koin-core:$koinVersion") + implementation(Config.Libs.arrowCore) + implementation(Config.Libs.koin) - testImplementation("org.junit.jupiter:junit-jupiter-api:5.1.0") - testImplementation("org.amshove.kluent:kluent:$kluentVersion") + testImplementation(Config.Libs.junit) + testImplementation(Config.Libs.kluent) + // testImplementation(Config.Libs.spekDsl) + + // testRuntimeOnly(Config.Libs.kotlinReflect) + // testRuntimeOnly(Config.Libs.spekRunner) } tasks.withType { kotlinOptions.jvmTarget = "1.8" -} \ No newline at end of file +} + +tasks.register("ktlint", Ktlint::class) \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..81089aa --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,32 @@ +/* + * MIT License + * + * Copyright (c) 2019 norangebit + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +plugins { + `kotlin-dsl` +} + +repositories { + jcenter() +} diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt new file mode 100644 index 0000000..18f2e2c --- /dev/null +++ b/buildSrc/src/main/java/Config.kt @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) 2019 norangebit + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +object Config { + object Versions { + val arrow = "0.8.2" + val kluent = "1.48" + val koin = "1.0.2" + val junit = "5.1.0" + val spek = "2.0.1" + val kotlin = "1.3.21." + } + + object Libs { + val arrowCore = "io.arrow-kt:arrow-core:${Versions.arrow}" + val koin = "org.koin:koin-core:${Versions.koin}" + val junit = "org.junit.jupiter:junit-jupiter-api:${Versions.junit}" + val kluent = "org.amshove.kluent:kluent:${Versions.kluent}" + val spekDsl = "org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}" + val kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin}" + val spekRunner = "org.spekframework.spek2:spek-runner-junit5:${Versions.spek}" + } +} \ No newline at end of file diff --git a/buildSrc/src/main/java/Ktlint.kt b/buildSrc/src/main/java/Ktlint.kt new file mode 100644 index 0000000..cd4f19b --- /dev/null +++ b/buildSrc/src/main/java/Ktlint.kt @@ -0,0 +1,41 @@ +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.TaskAction + +/* + * MIT License + * + * Copyright (c) 2019 norangebit + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +open class Ktlint : DefaultTask() { + + @TaskAction + fun run() { + val input = Runtime.getRuntime().exec("ktlint").inputStream + + input.reader().readLines().forEach { + println(it) + } + + Runtime.getRuntime().exec("ktlint -F") + } +} \ No newline at end of file