summaryrefslogtreecommitdiff
path: root/simulator/buildSrc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'simulator/buildSrc/src/main')
-rw-r--r--simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt (renamed from simulator/buildSrc/src/main/kotlin/library.kt)37
-rw-r--r--simulator/buildSrc/src/main/kotlin/Versions.kt63
-rw-r--r--simulator/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts (renamed from simulator/buildSrc/src/main/kotlin/dokka-convention.gradle.kts)0
-rw-r--r--simulator/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts40
-rw-r--r--simulator/buildSrc/src/main/kotlin/jacoco-conventions.gradle.kts58
-rw-r--r--simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts (renamed from simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts)21
-rw-r--r--simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts38
7 files changed, 212 insertions, 45 deletions
diff --git a/simulator/buildSrc/src/main/kotlin/library.kt b/simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt
index a66e5f46..ddf643f6 100644
--- a/simulator/buildSrc/src/main/kotlin/library.kt
+++ b/simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt
@@ -1,7 +1,5 @@
/*
- * MIT License
- *
- * Copyright (c) 2019 atlarge-research
+ * 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
@@ -22,28 +20,15 @@
* SOFTWARE.
*/
+import org.gradle.api.Project
+import org.gradle.kotlin.dsl.extra
+import org.gradle.kotlin.dsl.provideDelegate
+
/**
- * This object contains the versions of the dependencies shared by the different
- * subprojects.
+ * Obtain the [Versions] object for the specified [Project] instance.
*/
-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"
-}
+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
new file mode 100644
index 00000000..fcf3c778
--- /dev/null
+++ b/simulator/buildSrc/src/main/kotlin/Versions.kt
@@ -0,0 +1,63 @@
+/*
+ * 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.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 class Versions(private val project: Project) {
+ /**
+ * A delegate for obtaining configuration values from a [Project] instance.
+ */
+ private fun version(name: String? = null): ReadOnlyProperty<Versions, String> =
+ ReadOnlyProperty { _, property -> get(name ?: property.name) }
+
+ 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")
+
+
+ /**
+ * Obtain the version for the specified [dependency][name].
+ */
+ 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/dokka-convention.gradle.kts b/simulator/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts
index 95183df2..95183df2 100644
--- a/simulator/buildSrc/src/main/kotlin/dokka-convention.gradle.kts
+++ b/simulator/buildSrc/src/main/kotlin/dokka-conventions.gradle.kts
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<Test>("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
+}
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-conventions.gradle.kts
index f9d8a966..8d6420be 100644
--- a/simulator/buildSrc/src/main/kotlin/kotlin-library-convention.gradle.kts
+++ b/simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts
@@ -28,7 +28,6 @@ plugins {
`java-library`
kotlin("jvm")
id("org.jlleitschuh.gradle.ktlint")
- jacoco
}
/* Project configuration */
@@ -38,30 +37,14 @@ repositories {
}
java {
- sourceCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = Versions.jvmTarget
}
kotlin {
explicitApi()
}
-jacoco {
- toolVersion = "0.8.6"
-}
-
tasks.withType<KotlinCompile>().configureEach {
- kotlinOptions.jvmTarget = "1.8"
+ kotlinOptions.jvmTarget = Versions.jvmTarget.toString()
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
-
-tasks.test {
- useJUnitPlatform()
- reports.html.isEnabled = true
-}
-
-
-tasks.jacocoTestReport {
- reports {
- html.isEnabled = true
- }
-}
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..22ea7905
--- /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.junitJupiter}")
+ testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junitJupiter}")
+}