summaryrefslogtreecommitdiff
path: root/buildSrc/src/main/kotlin/Libs.kt
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-13 18:16:19 +0000
committerGitHub <noreply@github.com>2022-11-13 18:16:19 +0000
commit52eed48441693149993db79b63431b99e0973027 (patch)
treeba267db531bc3d81409ddfe9caeb6d3b5a65e8c8 /buildSrc/src/main/kotlin/Libs.kt
parent183cfa96910ebb74c668dea7ef98071966f8fcb9 (diff)
parent33d91ef30ad7bcb73365934fe536461210d1082a (diff)
merge: Increase minimum Java version to 17 (#115)
This pull request increases the minimum version of Java required by OpenDC to 17. This new version of Java introduces several new features compared to our old minimum version (11), which we attempt to apply in this conversion. ## Implementation Notes :hammer_and_pick: * Increase minimum Java version to Java 17 * Use RandomGenerator as randomness source * Add common dispatcher interface * Add compatibility with Kotlin coroutines * Use InstantSource as time source * Re-implement SimulationScheduler as Dispatcher * Replace use of CoroutineContext by Dispatcher ## External Dependencies :four_leaf_clover: * Java 17 ## Breaking API Changes :warning: * The use of `CoroutineContext` and `Clock` as parameters of classes has been replaced by the `Dispatcher` interface. * The use of `Clock` has been replaced by `InstantSource` which does not carry time zone info. * The use of `Random` and `SplittableRandom` as parameter type has been replaced by `RandomGenerator`
Diffstat (limited to 'buildSrc/src/main/kotlin/Libs.kt')
-rw-r--r--buildSrc/src/main/kotlin/Libs.kt37
1 files changed, 16 insertions, 21 deletions
diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt
index 6a73e1b9..09432b06 100644
--- a/buildSrc/src/main/kotlin/Libs.kt
+++ b/buildSrc/src/main/kotlin/Libs.kt
@@ -24,32 +24,27 @@
import org.gradle.api.JavaVersion
import org.gradle.api.Project
+import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.getByType
/**
- * This class makes the version catalog accessible for the build scripts until Gradle adds support for it.
- *
- * See https://github.com/gradle/gradle/issues/15383
+ * Obtain the default [VersionCatalog] of the project.
*/
-public class Libs(project: Project) {
- /**
- * The version catalog of the project.
- */
- private val versionCatalog = project.extensions.getByType(VersionCatalogsExtension::class).named("libs")
+public val Project.defaultVersionCatalog: VersionCatalog
+ get() = project.extensions.getByType(VersionCatalogsExtension::class).named("libs")
- /**
- * Obtain the version for the specified [dependency][name].
- */
- operator fun get(name: String): String {
- val dep = versionCatalog.findLibrary(name).get().get()
- return "${dep.module.group}:${dep.module.name}:${dep.versionConstraint.displayName}"
- }
+/**
+ * Obtain the dependency string for the specified [name].
+ */
+public operator fun VersionCatalog.get(name: String): String {
+ val dep = findLibrary(name).get().get()
+ return "${dep.module.group}:${dep.module.name}:${dep.versionConstraint.displayName}"
+}
- companion object {
- /**
- * The JVM version to target.
- */
- val jvmTarget = JavaVersion.VERSION_11
- }
+/**
+ * Obtain the string representation of the version with the given [name].
+ */
+public fun VersionCatalog.getVersion(name: String): String {
+ return findVersion(name).get().displayName
}