summaryrefslogtreecommitdiff
path: root/simulator/buildSrc
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-02-23 12:05:59 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-02-23 12:12:36 +0100
commit90de768b8bfb3acc222f508d2e602ef3b7f1ff91 (patch)
tree577a96ec45e245d1a1184a5158495c2289ae004c /simulator/buildSrc
parent0b092b352dc29ce69f6f126eb7857a1243a6ef62 (diff)
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.
Diffstat (limited to 'simulator/buildSrc')
-rw-r--r--simulator/buildSrc/build.gradle.kts4
-rw-r--r--simulator/buildSrc/src/main/kotlin/ProjectExtensions.kt34
-rw-r--r--simulator/buildSrc/src/main/kotlin/Versions.kt41
-rw-r--r--simulator/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts4
-rw-r--r--simulator/buildSrc/src/main/kotlin/testing-conventions.gradle.kts4
5 files changed, 69 insertions, 18 deletions
diff --git a/simulator/buildSrc/build.gradle.kts b/simulator/buildSrc/build.gradle.kts
index 452c07cd..4cc1958a 100644
--- a/simulator/buildSrc/build.gradle.kts
+++ b/simulator/buildSrc/build.gradle.kts
@@ -38,6 +38,10 @@ dependencies {
implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1")
}
+kotlinDslPluginOptions {
+ experimentalWarning.set(false)
+}
+
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
allWarningsAsErrors = true
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<Versions, String> =
+ 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<KotlinCompile>().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}")
}