From 129a86fa562b50c9ca43579dfd598596567dae53 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 23 Feb 2021 11:15:04 +0100 Subject: Extract Jacoco convention from Kotlin library convention This commit extracts the configuration for Jacoco into a separate convention file. --- .../src/main/kotlin/jacoco-convention.gradle.kts | 58 ++++++++++++++++++++++ .../kotlin/kotlin-library-convention.gradle.kts | 12 ----- 2 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts (limited to 'simulator/buildSrc/src/main') diff --git a/simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts b/simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts new file mode 100644 index 00000000..544e34bf --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts @@ -0,0 +1,58 @@ +import org.gradle.kotlin.dsl.`java-library` +import org.gradle.kotlin.dsl.jacoco +import org.gradle.kotlin.dsl.kotlin + +/* + * Copyright (c) 2021 AtLarge Research + * + * 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. + */ + +/* + * Copyright (c) 2021 AtLarge Research + * + * 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 { + `java-library` + jacoco +} + +tasks.jacocoTestReport { + reports { + html.isEnabled = true + } +} diff --git a/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts b/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts index f9d8a966..405235f0 100644 --- a/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts +++ b/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts @@ -28,7 +28,6 @@ plugins { `java-library` kotlin("jvm") id("org.jlleitschuh.gradle.ktlint") - jacoco } /* Project configuration */ @@ -45,10 +44,6 @@ kotlin { explicitApi() } -jacoco { - toolVersion = "0.8.6" -} - tasks.withType().configureEach { kotlinOptions.jvmTarget = "1.8" kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" @@ -58,10 +53,3 @@ tasks.test { useJUnitPlatform() reports.html.isEnabled = true } - - -tasks.jacocoTestReport { - reports { - html.isEnabled = true - } -} -- cgit v1.2.3 From 0b092b352dc29ce69f6f126eb7857a1243a6ef62 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 23 Feb 2021 11:46:06 +0100 Subject: Extract testing conventions from Kotlin conventions This change extracts the configuration for test from the Kotlin library conventions. --- simulator/buildSrc/src/main/kotlin/Versions.kt | 50 +++++++++++++++++++ .../src/main/kotlin/dokka-convention.gradle.kts | 33 ------------ .../src/main/kotlin/dokka-conventions.gradle.kts | 33 ++++++++++++ .../src/main/kotlin/jacoco-convention.gradle.kts | 58 ---------------------- .../src/main/kotlin/jacoco-conventions.gradle.kts | 58 ++++++++++++++++++++++ .../kotlin/kotlin-library-convention.gradle.kts | 55 -------------------- .../kotlin/kotlin-library-conventions.gradle.kts | 50 +++++++++++++++++++ simulator/buildSrc/src/main/kotlin/library.kt | 49 ------------------ .../src/main/kotlin/testing-conventions.gradle.kts | 38 ++++++++++++++ 9 files changed, 229 insertions(+), 195 deletions(-) create mode 100644 simulator/buildSrc/src/main/kotlin/Versions.kt delete mode 100644 simulator/buildSrc/src/main/kotlin/dokka-convention.gradle.kts create mode 100644 simulator/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts delete mode 100644 simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts create mode 100644 simulator/buildSrc/src/main/kotlin/jacoco-conventions.gradle.kts delete mode 100644 simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts create mode 100644 simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts delete mode 100644 simulator/buildSrc/src/main/kotlin/library.kt create mode 100644 simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts (limited to 'simulator/buildSrc/src/main') diff --git a/simulator/buildSrc/src/main/kotlin/Versions.kt b/simulator/buildSrc/src/main/kotlin/Versions.kt new file mode 100644 index 00000000..d845c4bd --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/Versions.kt @@ -0,0 +1,50 @@ +/* + * MIT License + * + * Copyright (c) 2019 atlarge-research + * + * 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. + */ + +/** + * This class contains the versions of the dependencies shared by the different + * subprojects. + */ +public object Versions { + + /** + * The library for testing the projects. + */ + val JUNIT_JUPITER = "5.7.1" + + /** + * The library for hosting the tests. + */ + val JUNIT_PLATFORM = "1.7.1" + + /** + * Logging facade. + */ + val SLF4J = "1.7.30" + + /** + * Kotlin coroutines support + */ + val KOTLINX_COROUTINES = "1.4.2" +} diff --git a/simulator/buildSrc/src/main/kotlin/dokka-convention.gradle.kts b/simulator/buildSrc/src/main/kotlin/dokka-convention.gradle.kts deleted file mode 100644 index 95183df2..00000000 --- a/simulator/buildSrc/src/main/kotlin/dokka-convention.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2019 atlarge-research - * - * 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. - */ - -import org.jetbrains.dokka.gradle.DokkaTask - -plugins { - id("org.jetbrains.dokka") -} - -tasks.getting(DokkaTask::class) { - outputFormat = "html" -} diff --git a/simulator/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts new file mode 100644 index 00000000..95183df2 --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2019 atlarge-research + * + * 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. + */ + +import org.jetbrains.dokka.gradle.DokkaTask + +plugins { + id("org.jetbrains.dokka") +} + +tasks.getting(DokkaTask::class) { + outputFormat = "html" +} diff --git a/simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts b/simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts deleted file mode 100644 index 544e34bf..00000000 --- a/simulator/buildSrc/src/main/kotlin/jacoco-convention.gradle.kts +++ /dev/null @@ -1,58 +0,0 @@ -import org.gradle.kotlin.dsl.`java-library` -import org.gradle.kotlin.dsl.jacoco -import org.gradle.kotlin.dsl.kotlin - -/* - * Copyright (c) 2021 AtLarge Research - * - * 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. - */ - -/* - * Copyright (c) 2021 AtLarge Research - * - * 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 { - `java-library` - jacoco -} - -tasks.jacocoTestReport { - reports { - html.isEnabled = true - } -} diff --git a/simulator/buildSrc/src/main/kotlin/jacoco-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/jacoco-conventions.gradle.kts new file mode 100644 index 00000000..544e34bf --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/jacoco-conventions.gradle.kts @@ -0,0 +1,58 @@ +import org.gradle.kotlin.dsl.`java-library` +import org.gradle.kotlin.dsl.jacoco +import org.gradle.kotlin.dsl.kotlin + +/* + * Copyright (c) 2021 AtLarge Research + * + * 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. + */ + +/* + * Copyright (c) 2021 AtLarge Research + * + * 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 { + `java-library` + jacoco +} + +tasks.jacocoTestReport { + reports { + html.isEnabled = true + } +} diff --git a/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts b/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts deleted file mode 100644 index 405235f0..00000000 --- a/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2019 atlarge-research - * - * 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. - */ - -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - `java-library` - kotlin("jvm") - id("org.jlleitschuh.gradle.ktlint") -} - -/* Project configuration */ -repositories { - mavenCentral() - jcenter() -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 -} - -kotlin { - explicitApi() -} - -tasks.withType().configureEach { - kotlinOptions.jvmTarget = "1.8" - kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" -} - -tasks.test { - useJUnitPlatform() - reports.html.isEnabled = true -} diff --git a/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts new file mode 100644 index 00000000..b07267d2 --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts @@ -0,0 +1,50 @@ +/* + * MIT License + * + * Copyright (c) 2019 atlarge-research + * + * 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. + */ + +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + `java-library` + kotlin("jvm") + id("org.jlleitschuh.gradle.ktlint") +} + +/* Project configuration */ +repositories { + mavenCentral() + jcenter() +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 +} + +kotlin { + explicitApi() +} + +tasks.withType().configureEach { + kotlinOptions.jvmTarget = "1.8" + kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" +} diff --git a/simulator/buildSrc/src/main/kotlin/library.kt b/simulator/buildSrc/src/main/kotlin/library.kt deleted file mode 100644 index a66e5f46..00000000 --- a/simulator/buildSrc/src/main/kotlin/library.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2019 atlarge-research - * - * 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. - */ - -/** - * This object contains the versions of the dependencies shared by the different - * subprojects. - */ -object Library { - /** - * The library for testing the projects. - */ - val JUNIT_JUPITER = "5.7.1" - - /** - * The library for hosting the tests. - */ - val JUNIT_PLATFORM = "1.7.1" - - /** - * Logging facade. - */ - val SLF4J = "1.7.30" - - /** - * Kotlin coroutines support - */ - val KOTLINX_COROUTINES = "1.4.2" -} diff --git a/simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts new file mode 100644 index 00000000..5a19bfe0 --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts @@ -0,0 +1,38 @@ +import org.gradle.kotlin.dsl.`java-library` +import org.gradle.kotlin.dsl.kotlin +import org.gradle.platform.base.Library + +/* + * Copyright (c) 2021 AtLarge Research + * + * 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 { + `java-library` +} + +tasks.test { + useJUnitPlatform() +} + +dependencies { + testImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT_JUPITER}") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT_JUPITER}") +} -- cgit v1.2.3 From 90de768b8bfb3acc222f508d2e602ef3b7f1ff91 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 23 Feb 2021 12:05:59 +0100 Subject: Move dependency versions to gradle.properties This change moves the version of the dependencies from buildSrc to gradle.properties to prevent recompilation when changing dependency versions. --- .../buildSrc/src/main/kotlin/ProjectExtensions.kt | 34 ++++++++++++++++++ simulator/buildSrc/src/main/kotlin/Versions.kt | 41 ++++++++++++++-------- .../kotlin/kotlin-library-conventions.gradle.kts | 4 +-- .../src/main/kotlin/testing-conventions.gradle.kts | 4 +-- 4 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt (limited to 'simulator/buildSrc/src/main') diff --git a/simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt b/simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt new file mode 100644 index 00000000..ddf643f6 --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 AtLarge Research + * + * 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. + */ + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.extra +import org.gradle.kotlin.dsl.provideDelegate + +/** + * Obtain the [Versions] object for the specified [Project] instance. + */ +val Project.versions: Versions + get() { + var versions: Versions? by rootProject.extra + return versions ?: Versions(rootProject).also { versions = it } + } diff --git a/simulator/buildSrc/src/main/kotlin/Versions.kt b/simulator/buildSrc/src/main/kotlin/Versions.kt index d845c4bd..fcf3c778 100644 --- a/simulator/buildSrc/src/main/kotlin/Versions.kt +++ b/simulator/buildSrc/src/main/kotlin/Versions.kt @@ -22,29 +22,42 @@ * SOFTWARE. */ +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.kotlin.dsl.extra +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + /** * This class contains the versions of the dependencies shared by the different * subprojects. */ -public object Versions { - +public class Versions(private val project: Project) { /** - * The library for testing the projects. + * A delegate for obtaining configuration values from a [Project] instance. */ - val JUNIT_JUPITER = "5.7.1" + private fun version(name: String? = null): ReadOnlyProperty = + ReadOnlyProperty { _, property -> get(name ?: property.name) } - /** - * The library for hosting the tests. - */ - val JUNIT_PLATFORM = "1.7.1" + val junitJupiter by version(name = "junit-jupiter") + val junitPlatform by version(name = "junit-platform") + + val slf4j by version() + val kotlinLogging by version(name = "kotlin-logging") + val log4j by version() + + val kotlinxCoroutines by version(name = "kotlinx-coroutines") - /** - * Logging facade. - */ - val SLF4J = "1.7.30" /** - * Kotlin coroutines support + * Obtain the version for the specified [dependency][name]. */ - val KOTLINX_COROUTINES = "1.4.2" + operator fun get(name: String) = project.extra.get("$name.version") as String + + companion object { + /** + * The JVM version to target. + */ + val jvmTarget = JavaVersion.VERSION_1_8 + } } diff --git a/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts index b07267d2..8d6420be 100644 --- a/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts +++ b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts @@ -37,7 +37,7 @@ repositories { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = Versions.jvmTarget } kotlin { @@ -45,6 +45,6 @@ kotlin { } tasks.withType().configureEach { - kotlinOptions.jvmTarget = "1.8" + kotlinOptions.jvmTarget = Versions.jvmTarget.toString() kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } diff --git a/simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts index 5a19bfe0..22ea7905 100644 --- a/simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts +++ b/simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts @@ -33,6 +33,6 @@ tasks.test { } dependencies { - testImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT_JUPITER}") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT_JUPITER}") + testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junitJupiter}") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junitJupiter}") } -- cgit v1.2.3 From 2119427fe6f7874867c6985cacda28befc53436b Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 23 Feb 2021 12:37:31 +0100 Subject: Utilize version constraints for shared versions This change updates the Gradle configuration to utilize version constraints to force the same dependency version across modules. --- .../main/kotlin/dependency-conventions.gradle.kts | 43 ++++++++++++++++++++++ .../kotlin/kotlin-library-conventions.gradle.kts | 7 +--- 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts (limited to 'simulator/buildSrc/src/main') diff --git a/simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts new file mode 100644 index 00000000..ee9ea793 --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts @@ -0,0 +1,43 @@ +import org.gradle.kotlin.dsl.`java-library` +import org.gradle.kotlin.dsl.kotlin +import org.gradle.kotlin.dsl.repositories + +/* + * Copyright (c) 2021 AtLarge Research + * + * 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 { + `java-library` +} + +repositories { + mavenCentral() + jcenter() +} + +/* Dependency constraints across modules */ +dependencies { + constraints { + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.kotlinxCoroutines}") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${versions.kotlinxCoroutines}") + implementation("io.github.microutils:kotlin-logging:${versions.kotlinLogging}") + } +} diff --git a/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts index 8d6420be..e9fee735 100644 --- a/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts +++ b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts @@ -28,12 +28,7 @@ plugins { `java-library` kotlin("jvm") id("org.jlleitschuh.gradle.ktlint") -} - -/* Project configuration */ -repositories { - mavenCentral() - jcenter() + id("dependency-conventions") } java { -- cgit v1.2.3 From e99ceb1575f50d98ad61f5101b7b69ab69453d70 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 23 Feb 2021 20:38:31 +0100 Subject: exp: Support running SC18 experiment from within IntelliJ --- .../main/kotlin/experiment-conventions.gradle.kts | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 simulator/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts (limited to 'simulator/buildSrc/src/main') diff --git a/simulator/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts new file mode 100644 index 00000000..4745ff1a --- /dev/null +++ b/simulator/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 AtLarge Research + * + * 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 { + `java-library` +} + +dependencies { + implementation(project(":opendc-harness")) +} + +tasks.register("experiment") { + // Ensure JUnit Platform is used for resolving tests + useJUnitPlatform() + + description = "Runs OpenDC experiments" + group = "application" + + testClassesDirs = sourceSets["main"].output.classesDirs + classpath = sourceSets["main"].runtimeClasspath +} -- cgit v1.2.3 From 15fcd1a10018605f59ca7a644b8f3b3960e7b6b0 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 23 Feb 2021 21:40:53 +0100 Subject: Use Java Platform for shared dependency constraints This change uses the Java Platform functionality from Gradle to enable shared dependency constraints across modules. --- .../main/kotlin/dependency-conventions.gradle.kts | 43 ---------------------- .../kotlin/kotlin-library-conventions.gradle.kts | 7 +++- 2 files changed, 6 insertions(+), 44 deletions(-) delete mode 100644 simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts (limited to 'simulator/buildSrc/src/main') diff --git a/simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts deleted file mode 100644 index ee9ea793..00000000 --- a/simulator/buildSrc/src/main/kotlin/dependency-conventions.gradle.kts +++ /dev/null @@ -1,43 +0,0 @@ -import org.gradle.kotlin.dsl.`java-library` -import org.gradle.kotlin.dsl.kotlin -import org.gradle.kotlin.dsl.repositories - -/* - * Copyright (c) 2021 AtLarge Research - * - * 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 { - `java-library` -} - -repositories { - mavenCentral() - jcenter() -} - -/* Dependency constraints across modules */ -dependencies { - constraints { - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.kotlinxCoroutines}") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${versions.kotlinxCoroutines}") - implementation("io.github.microutils:kotlin-logging:${versions.kotlinLogging}") - } -} diff --git a/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts index e9fee735..8d6420be 100644 --- a/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts +++ b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts @@ -28,7 +28,12 @@ plugins { `java-library` kotlin("jvm") id("org.jlleitschuh.gradle.ktlint") - id("dependency-conventions") +} + +/* Project configuration */ +repositories { + mavenCentral() + jcenter() } java { -- cgit v1.2.3