From 14c6a67b384ea11fd5b06a0189bac56cfae9f106 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 11:02:37 +0200 Subject: build: Update simulator dependencies This change updates the simulator dependencies to the latest available version where possible. --- buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'buildSrc/src') diff --git a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts index 6b9109f7..8fb46f5d 100644 --- a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts @@ -34,3 +34,9 @@ tasks.withType().configureEach { kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" kotlinOptions.freeCompilerArgs += "-Xjvm-default=all" } + +configure { + // Higher versions currently have issues with formatting where wildcard imports are automatically removed, + // even when in use. + version.set("0.42.1") +} -- cgit v1.2.3 From d447295f535c3587c82d809397cb1a5f23ab1b4b Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 11:08:03 +0200 Subject: build: Remove unused distribution conventions This change removes the distribution conventions used by the root project of OpenDC. Previously, we used this to build a single distribution for OpenDC containing the experiment uberjars and scripts to start OpenDC. However, with the introduction of the Quarkus-based web server, we have decided to split releases into (potentially) multiple distributions (e.g., one for the web server, one for just the web runner, etc.). Furthermore, the implementation of this convention caused issues with several other Gradle plugins. --- .../kotlin/distribution-conventions.gradle.kts | 51 ---------------------- 1 file changed, 51 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/distribution-conventions.gradle.kts (limited to 'buildSrc/src') diff --git a/buildSrc/src/main/kotlin/distribution-conventions.gradle.kts b/buildSrc/src/main/kotlin/distribution-conventions.gradle.kts deleted file mode 100644 index ebbe46ee..00000000 --- a/buildSrc/src/main/kotlin/distribution-conventions.gradle.kts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.distribution.DistributionContainer - - -plugins { - distribution -} - -tasks.named("assembleDist") { - val tasks = getTasksByName("assembleDist", true).filter { it.project != project } - dependsOn(tasks) -} - -distributions { - main { - contents { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - - from("README.md") - from("LICENSE.txt") - from("docs") { into("docs") } - - // Include distributions of the subprojects - getTasksByName("assembleDist", true) - .filter { it.project != project } - .map { it.project.the() } - .forEach { dist -> dist.findByName("main")?.let { with(it.contents) } } - } - } -} -- cgit v1.2.3 From 47357afd16f928260db34d4dd3e686fb9ee7c5ff Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 13:13:10 +0200 Subject: build: Switch to Spotless for formatting This change updates the build configuration to use Spotless for code formating of both Kotlin and Java. --- .../src/main/kotlin/java-conventions.gradle.kts | 1 + .../src/main/kotlin/kotlin-conventions.gradle.kts | 8 +-- buildSrc/src/main/kotlin/license.kt | 22 ++++++++ .../src/main/kotlin/quarkus-conventions.gradle.kts | 10 ---- .../main/kotlin/spotless-conventions.gradle.kts | 59 ++++++++++++++++++++++ 5 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 buildSrc/src/main/kotlin/license.kt create mode 100644 buildSrc/src/main/kotlin/spotless-conventions.gradle.kts (limited to 'buildSrc/src') diff --git a/buildSrc/src/main/kotlin/java-conventions.gradle.kts b/buildSrc/src/main/kotlin/java-conventions.gradle.kts index d4cc667a..a639a9e1 100644 --- a/buildSrc/src/main/kotlin/java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/java-conventions.gradle.kts @@ -22,6 +22,7 @@ plugins { `java-library` + id("spotless-conventions") } /* Project configuration */ diff --git a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts index 8fb46f5d..5ccc06a4 100644 --- a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("java-conventions") kotlin("jvm") - id("org.jlleitschuh.gradle.ktlint") + id("spotless-conventions") } /* Project configuration */ @@ -34,9 +34,3 @@ tasks.withType().configureEach { kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" kotlinOptions.freeCompilerArgs += "-Xjvm-default=all" } - -configure { - // Higher versions currently have issues with formatting where wildcard imports are automatically removed, - // even when in use. - version.set("0.42.1") -} diff --git a/buildSrc/src/main/kotlin/license.kt b/buildSrc/src/main/kotlin/license.kt new file mode 100644 index 00000000..4e90fd4e --- /dev/null +++ b/buildSrc/src/main/kotlin/license.kt @@ -0,0 +1,22 @@ +/* + * Copyright (c) $YEAR 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. + */ + diff --git a/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts b/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts index 75c4a454..f1adb182 100644 --- a/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts @@ -76,13 +76,3 @@ configurations.create("coverageDataElementsForQuarkus") { } } } - -/* Fix for Quarkus/ktlint-gradle incompatibilities */ -tasks.named("runKtlintCheckOverMainSourceSet") { - mustRunAfter(tasks.quarkusGenerateCode) - mustRunAfter(tasks.quarkusGenerateCodeDev) -} - -tasks.named("runKtlintCheckOverTestSourceSet") { - mustRunAfter(tasks.quarkusGenerateCodeTests) -} diff --git a/buildSrc/src/main/kotlin/spotless-conventions.gradle.kts b/buildSrc/src/main/kotlin/spotless-conventions.gradle.kts new file mode 100644 index 00000000..11131cc8 --- /dev/null +++ b/buildSrc/src/main/kotlin/spotless-conventions.gradle.kts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 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 { + id("com.diffplug.spotless") +} + +spotless { + pluginManager.withPlugin("java") { + java { + importOrder() + removeUnusedImports() + + palantirJavaFormat() + + trimTrailingWhitespace() + endWithNewline() + + licenseHeaderFile(rootProject.file("buildSrc/src/main/kotlin/license.kt")) + } + } + + pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + kotlin { + ktlint() + .setUseExperimental(false) + trimTrailingWhitespace() + endWithNewline() + + licenseHeaderFile(rootProject.file("buildSrc/src/main/kotlin/license.kt")) + } + } + + kotlinGradle { + ktlint() + + trimTrailingWhitespace() + endWithNewline() + } +} -- cgit v1.2.3