diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 841098fd4..a2cd02521 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -55,7 +55,7 @@ tasks { create("createAraraAPIObject") { listOf( "src/nativeCommonMain/kotlin/org/islandoftex/arara/api/AraraAPI.kt", - "src/jvmMain/kotlin/org/islandoftex/arara/api/AraraAPI.kt" + "src/jvmMain/kotlin/org/islandoftex/arara/api/AraraAPI.kt", ).forEach { file(it).writeText( """ @@ -67,7 +67,7 @@ tasks { public actual val version: String = "${project.version}" } - """.trimIndent() + """.trimIndent(), ) } } diff --git a/api/src/commonMain/kotlin/org/islandoftex/arara/api/configuration/ExecutionOptions.kt b/api/src/commonMain/kotlin/org/islandoftex/arara/api/configuration/ExecutionOptions.kt index d34b6cb4c..26447c9ab 100644 --- a/api/src/commonMain/kotlin/org/islandoftex/arara/api/configuration/ExecutionOptions.kt +++ b/api/src/commonMain/kotlin/org/islandoftex/arara/api/configuration/ExecutionOptions.kt @@ -28,7 +28,7 @@ public enum class ExecutionMode { * In normal run mode, arara executes everything it is able to giving the * run the full flexibility. */ - NORMAL_RUN + NORMAL_RUN, } /** diff --git a/api/src/commonMain/kotlin/org/islandoftex/arara/api/localization/Messages.kt b/api/src/commonMain/kotlin/org/islandoftex/arara/api/localization/Messages.kt index 0f6e9afdd..b1ad83b9c 100644 --- a/api/src/commonMain/kotlin/org/islandoftex/arara/api/localization/Messages.kt +++ b/api/src/commonMain/kotlin/org/islandoftex/arara/api/localization/Messages.kt @@ -6,7 +6,7 @@ package org.islandoftex.arara.api.localization @RequiresOptIn( "arara's messages are not considered stable API. Only " + "use them in testing scenarios and arara's core projects.", - RequiresOptIn.Level.WARNING + RequiresOptIn.Level.WARNING, ) internal annotation class AraraMessages @@ -104,5 +104,5 @@ public open class Messages( public val LOG_INFO_SYSTEM_COMMAND: String = "System command: %s", public val LOG_INFO_TASK_RESULT: String = "Task result:", public val LOG_INFO_VALIDATED_DIRECTIVES: String = "All directives were validated. We are good to go.", - public val LOG_INFO_WELCOME_MESSAGE: String = "Welcome to arara %s!" + public val LOG_INFO_WELCOME_MESSAGE: String = "Welcome to arara %s!", ) diff --git a/api/src/commonMain/kotlin/org/islandoftex/arara/api/rules/DirectiveConditionals.kt b/api/src/commonMain/kotlin/org/islandoftex/arara/api/rules/DirectiveConditionals.kt index 9e52555c2..a6691e551 100644 --- a/api/src/commonMain/kotlin/org/islandoftex/arara/api/rules/DirectiveConditionals.kt +++ b/api/src/commonMain/kotlin/org/islandoftex/arara/api/rules/DirectiveConditionals.kt @@ -53,5 +53,5 @@ public enum class DirectiveConditionalType { * result is true, and the process is repeated while the result still * holds true. */ - WHILE + WHILE, } diff --git a/api/src/commonMain/kotlin/org/islandoftex/arara/api/session/ExecutionStatus.kt b/api/src/commonMain/kotlin/org/islandoftex/arara/api/session/ExecutionStatus.kt index 4170ac393..f6f087bb9 100644 --- a/api/src/commonMain/kotlin/org/islandoftex/arara/api/session/ExecutionStatus.kt +++ b/api/src/commonMain/kotlin/org/islandoftex/arara/api/session/ExecutionStatus.kt @@ -14,7 +14,7 @@ public sealed class ExecutionStatus( /** * The exit code arara will use when in the given state. */ - public val exitCode: Int + public val exitCode: Int, ) { /** * Everything went just fine (note that the diff --git a/api/src/commonTest/kotlin/org/islandoftex/arara/api/files/MPPPathTest.kt b/api/src/commonTest/kotlin/org/islandoftex/arara/api/files/MPPPathTest.kt index 374821f2f..19f638c49 100644 --- a/api/src/commonTest/kotlin/org/islandoftex/arara/api/files/MPPPathTest.kt +++ b/api/src/commonTest/kotlin/org/islandoftex/arara/api/files/MPPPathTest.kt @@ -12,10 +12,12 @@ class MPPPathTest { fun shouldNotClassifyRelativeAsAbsolutePaths() { assertFalse(MPPPath(".").isAbsolute) } + @Test fun shouldCorrectlyDetectAbsolutePaths() { assertTrue(MPPPath("/test").isAbsolute) } + @Test fun shouldConsiderRootAbsolute() { // korio does not handle this @@ -27,14 +29,15 @@ class MPPPathTest { fun shouldNormalizeDots() { assertEquals( MPPPath("/tmp/./quack/..").normalize().toString(), - MPPPath("/tmp/").normalize().toString() + MPPPath("/tmp/").normalize().toString(), ) } + @Test fun shouldNoExceedRoot() { assertEquals( MPPPath("/tmp/../../..").normalize().toString(), - MPPPath("/").toString() + MPPPath("/").toString(), ) } @@ -43,18 +46,19 @@ class MPPPathTest { fun shouldUseRootAsParentOfRoot() { assertEquals( MPPPath("/").parent.toString(), - MPPPath("/").toString() + MPPPath("/").toString(), ) } + @Test fun shouldDetermineParentCorrectly() { assertEquals( MPPPath("/tmp/./quack/..").parent.normalize().toString(), - MPPPath("/").toString() + MPPPath("/").toString(), ) assertEquals( MPPPath("/tmp/./quack/..").normalize().parent.toString(), - MPPPath("/").toString() + MPPPath("/").toString(), ) } } diff --git a/api/src/jvmMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt b/api/src/jvmMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt index 00886e5d5..9f02f3b60 100644 --- a/api/src/jvmMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt +++ b/api/src/jvmMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt @@ -122,8 +122,9 @@ public actual class MPPPath { } else { // check component-wise otherComponents.forEachIndexed { i, element -> - if (element != components[i]) + if (element != components[i]) { return false + } } true } @@ -137,7 +138,7 @@ public actual class MPPPath { // TODO: align with parent, check relative paths MPPPath( vfsFile.absolutePathInfo.normalize() - .takeIf { it.isNotBlank() } ?: "/" + .takeIf { it.isNotBlank() } ?: "/", ) /** @@ -170,10 +171,11 @@ public actual class MPPPath { * impossible. */ public actual fun readLines(): List = runBlockingNoJs { - if (isRegularFile) + if (isRegularFile) { vfsFile.readLines().toList() - else + } else { throw AraraIOException("Can only read lines from files.") + } } /** @@ -182,10 +184,11 @@ public actual class MPPPath { * impossible. */ public actual fun readText(): String = runBlockingNoJs { - if (isRegularFile) + if (isRegularFile) { vfsFile.readString() - else + } else { throw AraraIOException("Can only read text from files.") + } } /** @@ -196,12 +199,13 @@ public actual class MPPPath { public actual fun writeText(text: String, append: Boolean): Unit = runBlockingNoJs { if (isRegularFile) { - val openMode = if (append) + val openMode = if (append) { VfsOpenMode.APPEND - else - // if not appending choose the same open mode - // korio would use instead + } else { + // if not appending choose the same open mode + // korio would use instead VfsOpenMode.CREATE_OR_TRUNCATE + } vfsFile.vfs.open(vfsFile.absolutePath, openMode) .use { text.openAsync().copyTo(this) diff --git a/api/src/nativeCommonMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt b/api/src/nativeCommonMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt index 3e34814e2..63e645c5d 100644 --- a/api/src/nativeCommonMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt +++ b/api/src/nativeCommonMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt @@ -49,7 +49,7 @@ public actual class MPPPath { public actual fun normalize(): MPPPath = MPPPath( LocalVfs[vfsFile.fullPathNormalized].absolutePath .replace("/./", "/") - .replace("//", "/") + .replace("//", "/"), ) public actual fun resolve(p: String): MPPPath = diff --git a/build.gradle.kts b/build.gradle.kts index 27e673222..ed9fb3b58 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ if (!project.hasProperty("jobToken")) { logger.warn( "Will be unable to publish (jobToken missing)\n" + "Ignore this warning if you are not running the publish task " + - "for the GitLab package repository." + "for the GitLab package repository.", ) } @@ -74,7 +74,7 @@ spotless { "lua/build.gradle.kts", "mvel/build.gradle.kts", "kotlin-dsl/build.gradle.kts", - "cli/build.gradle.kts" + "cli/build.gradle.kts", ) targetExclude("src/test/**/*.kts") ktlint() @@ -90,7 +90,7 @@ spotless { "mvel/src/**/*.kt", "kotlin-dsl/src/**/*.kt", "cli/src/**/*.kt", - "buildSrc/src/**/*.kt" + "buildSrc/src/**/*.kt", ) targetExclude("src/test/**/*.kts") ktlint() @@ -103,21 +103,23 @@ spotless { detekt { allRules = false - source = files( - "api/src/commonMain/kotlin", - "api/src/jvmMain/kotlin", - "core/src/commonMain/kotlin", - "core/src/jvmMain/kotlin", - "lua/src/commonMain/kotlin", - "mvel/src/commonMain/kotlin", - "mvel/src/jvmMain/kotlin", - "kotlin-dsl/src/main/kotlin", - "cli/src/commonMain/kotlin", - "cli/src/jvmMain/kotlin", - "buildSrc/src/main/kotlin" + source.from( + files( + "api/src/commonMain/kotlin", + "api/src/jvmMain/kotlin", + "core/src/commonMain/kotlin", + "core/src/jvmMain/kotlin", + "lua/src/commonMain/kotlin", + "mvel/src/commonMain/kotlin", + "mvel/src/jvmMain/kotlin", + "kotlin-dsl/src/main/kotlin", + "cli/src/commonMain/kotlin", + "cli/src/jvmMain/kotlin", + "buildSrc/src/main/kotlin", + ), ) buildUponDefaultConfig = true - config = files("detekt-config.yml") + config.from(files("detekt-config.yml")) } tasks.register("assembleCTANSourceZip", SourceZipBuilderTask::class.java) @@ -210,8 +212,11 @@ subprojects { testLogging { exceptionFormat = TestExceptionFormat.FULL events( - TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR, - TestLogEvent.SKIPPED, TestLogEvent.PASSED, TestLogEvent.FAILED + TestLogEvent.STANDARD_OUT, + TestLogEvent.STANDARD_ERROR, + TestLogEvent.SKIPPED, + TestLogEvent.PASSED, + TestLogEvent.FAILED, ) } } diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/AraraPublication.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/AraraPublication.kt index 2485966a5..35ba5a607 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/AraraPublication.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/AraraPublication.kt @@ -46,7 +46,7 @@ open class AraraPublication : Plugin { description.set( "arara is a TeX automation tool based on " + "rules and directives. It gives you a way to enhance " + - "your TeX experience." + "your TeX experience.", ) inceptionYear.set("2012") url.set("https://gitlab.com/islandoftex/arara") @@ -89,9 +89,11 @@ open class AraraPublication : Plugin { url.set("https://tex.stackexchange.com/users/344") roles.set( listOf( - "Developer", "Contributor", "Tester", - "Haskell fanatic" - ) + "Developer", + "Contributor", + "Tester", + "Haskell fanatic", + ), ) } developer { @@ -101,9 +103,11 @@ open class AraraPublication : Plugin { url.set("https://tex.stackexchange.com/users/19862") roles.set( listOf( - "Developer", "Contributor", "Tester", - "Hat enthusiast" - ) + "Developer", + "Contributor", + "Tester", + "Hat enthusiast", + ), ) } } diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANTreeBuilderTask.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANTreeBuilderTask.kt index d9585569e..cd26c9e71 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANTreeBuilderTask.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANTreeBuilderTask.kt @@ -16,8 +16,8 @@ open class CTANTreeBuilderTask : DefaultTask() { description = "Create a CTAN compliant directory tree." // depend on the TDS zip - inputs.files(project.buildDir.resolve("arara.tds.zip")) - outputs.dir(project.buildDir.resolve("ctan").absolutePath) + inputs.files(project.layout.buildDirectory.file("arara.tds.zip").get().asFile) + outputs.dir(project.layout.buildDirectory.dir("ctan").get().asFile.absolutePath) } /** @@ -27,16 +27,17 @@ open class CTANTreeBuilderTask : DefaultTask() { fun run() { logger.lifecycle("Preparing the archive file for CTAN submission") - val temporaryDir = project.buildDir.resolve("ctan") - if (temporaryDir.exists()) + val temporaryDir = project.layout.buildDirectory.dir("ctan").get().asFile + if (temporaryDir.exists()) { temporaryDir.deleteRecursively() + } temporaryDir.mkdirs() logger.debug("Copying the TDS archive file to the temporary directory") - val tdsZip = project.buildDir.resolve("arara.tds.zip") + val tdsZip = project.layout.buildDirectory.file("arara.tds.zip").get().asFile .copyTo( temporaryDir.resolve("arara.tds.zip"), - overwrite = true + overwrite = true, ) logger.debug("Extracting the temporary TDS structure") @@ -92,8 +93,8 @@ open class CTANTreeBuilderTask : DefaultTask() { PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_EXECUTE, - PosixFilePermission.OTHERS_EXECUTE - ) + PosixFilePermission.OTHERS_EXECUTE, + ), ) } } diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANZipBuilderTask.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANZipBuilderTask.kt index 793547507..132346aaf 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANZipBuilderTask.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/CTANZipBuilderTask.kt @@ -12,11 +12,11 @@ open class CTANZipBuilderTask : Zip() { group = "distribution" description = "Create a CTAN-ready ZIP file." - inputs.dir(project.buildDir.resolve("ctan")) - outputs.file(project.buildDir.resolve("arara-ctan.zip")) + inputs.dir(project.layout.buildDirectory.dir("ctan").get().asFile) + outputs.file(project.layout.buildDirectory.file("arara-ctan.zip").get().asFile) outputs.upToDateWhen { false } - archiveFileName.set(project.buildDir.resolve("arara-ctan.zip").absolutePath) - from(project.buildDir.resolve("ctan")) + archiveFileName.set(project.layout.buildDirectory.file("arara-ctan.zip").get().asFile.absolutePath) + from(project.layout.buildDirectory.dir("ctan").get().asFile) } } diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/DocumentationSourceZipBuilderTask.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/DocumentationSourceZipBuilderTask.kt index f48dcb660..30d472ed4 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/DocumentationSourceZipBuilderTask.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/DocumentationSourceZipBuilderTask.kt @@ -13,10 +13,10 @@ open class DocumentationSourceZipBuilderTask : Zip() { description = "Create a documentation source ZIP as required by CTAN." inputs.dir(project.projectDir.resolve("website/public")) - outputs.files(project.buildDir.resolve("arara-${project.version}-docsrc.zip")) + outputs.files(project.layout.buildDirectory.file("arara-${project.version}-docsrc.zip").get().asFile) outputs.upToDateWhen { false } - archiveFileName.set(project.buildDir.resolve("arara-${project.version}-docsrc.zip").absolutePath) + archiveFileName.set(project.layout.buildDirectory.file("arara-${project.version}-docsrc.zip").get().asFile.absolutePath) from(project.projectDir.resolve("website/public")) exclude("build") diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/SourceZipBuilderTask.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/SourceZipBuilderTask.kt index 8574fde79..0603c820a 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/SourceZipBuilderTask.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/SourceZipBuilderTask.kt @@ -20,10 +20,10 @@ open class SourceZipBuilderTask : Zip() { inputs.file(project.projectDir.resolve("cli/build.gradle.kts")) inputs.dir(project.projectDir.resolve("lua/src")) inputs.file(project.projectDir.resolve("lua/build.gradle.kts")) - outputs.files(project.buildDir.resolve("arara-${project.version}-src.zip")) + outputs.files(project.layout.buildDirectory.file("arara-${project.version}-src.zip").get().asFile) outputs.upToDateWhen { false } - archiveFileName.set(project.buildDir.resolve("arara-${project.version}-src.zip").absolutePath) + archiveFileName.set(project.layout.buildDirectory.file("arara-${project.version}-src.zip").get().asFile.absolutePath) from(project.projectDir.resolve("api")) from(project.projectDir.resolve("core")) from(project.projectDir.resolve("cli")) diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSTreeBuilderTask.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSTreeBuilderTask.kt index 48cb80047..0ffdcfe91 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSTreeBuilderTask.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSTreeBuilderTask.kt @@ -16,16 +16,16 @@ open class TDSTreeBuilderTask : DefaultTask() { // depend on shadow Jar input inputs.files( project.fileTree("cli/build/libs/") - .include("*-with-deps*.jar") + .include("*-with-deps*.jar"), ) // depend on source zips as required by CTAN - inputs.file(project.buildDir.resolve("arara-${project.version}-src.zip")) - inputs.file(project.buildDir.resolve("arara-${project.version}-docsrc.zip")) + inputs.file(project.layout.buildDirectory.file("arara-${project.version}-src.zip").get().asFile) + inputs.file(project.layout.buildDirectory.file("arara-${project.version}-docsrc.zip").get().asFile) // depend on documentation (it should be compiled) inputs.dir("docs") inputs.dir("cli") inputs.dir("rules") - outputs.dir(project.buildDir.resolve("tds").absolutePath) + outputs.dir(project.layout.buildDirectory.dir("tds").get().asFile.absolutePath) } /** @@ -34,9 +34,10 @@ open class TDSTreeBuilderTask : DefaultTask() { @TaskAction @Suppress("LongMethod") fun run() { - val temporaryDir = project.buildDir.resolve("tds") - if (temporaryDir.exists()) + val temporaryDir = project.layout.buildDirectory.dir("tds").get().asFile + if (temporaryDir.exists()) { temporaryDir.deleteRecursively() + } temporaryDir.mkdirs() logger.lifecycle("Creating the TeX Directory Structure (TDS) archive") @@ -61,7 +62,7 @@ open class TDSTreeBuilderTask : DefaultTask() { logger.debug("Copying the zipped documentation sources") project.copy { - from(project.files(project.buildDir.resolve("arara-${project.version}-docsrc.zip"))) + from(project.files(project.layout.buildDirectory.file("arara-${project.version}-docsrc.zip").get().asFile)) into(temporaryDir.resolve("doc/support/arara")) } @@ -81,7 +82,7 @@ open class TDSTreeBuilderTask : DefaultTask() { TaskHelper.createManPage( temporaryDir .resolve("doc/man/man1/${project.name}.1").toPath(), - project.version.toString() + project.version.toString(), ) logger.info("Building the scripts directory") @@ -108,7 +109,7 @@ open class TDSTreeBuilderTask : DefaultTask() { logger.info("Building the source code structure") project.copy { - from(project.buildDir.resolve("arara-${project.version}-src.zip")) + from(project.layout.buildDirectory.file("arara-${project.version}-src.zip").get().asFile) into(temporaryDir.resolve("source/support/arara")) } } diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSZipBuilderTask.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSZipBuilderTask.kt index 2f1149121..46a40cfa3 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSZipBuilderTask.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TDSZipBuilderTask.kt @@ -12,11 +12,11 @@ open class TDSZipBuilderTask : Zip() { group = "distribution" description = "Create a TDS compliant ZIP file." - inputs.dir(project.buildDir.resolve("tds")) - outputs.file(project.buildDir.resolve("arara.tds.zip")) + inputs.dir(project.layout.buildDirectory.dir("tds").get().asFile) + outputs.file(project.layout.buildDirectory.file("arara.tds.zip").get().asFile) outputs.upToDateWhen { false } - archiveFileName.set(project.buildDir.resolve("arara.tds.zip").absolutePath) - from(project.buildDir.resolve("tds")) + archiveFileName.set(project.layout.buildDirectory.file("arara.tds.zip").get().asFile.absolutePath) + from(project.layout.buildDirectory.dir("tds").get().asFile) } } diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TaskHelper.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TaskHelper.kt index c6c70a3b2..899bb3ce6 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TaskHelper.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/TaskHelper.kt @@ -40,7 +40,7 @@ object TaskHelper { fi exec java -jar "${'$'}jarpath" "${'$'}@" - """.trimIndent().lines() + """.trimIndent().lines(), ) Files.setPosixFilePermissions( file, @@ -51,15 +51,15 @@ object TaskHelper { PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_EXECUTE, - PosixFilePermission.OTHERS_EXECUTE - ) + PosixFilePermission.OTHERS_EXECUTE, + ), ) } catch (_: IOException) { throw IOException( "I could not create the shell script for " + "arara due to an IO error. Please make sure the " + "current directory has the correct permissions " + - "and try again. The application will halt now." + "and try again. The application will halt now.", ) } } @@ -125,14 +125,14 @@ object TaskHelper { Issue tracker at .UR https://gitlab.com/islandoftex/arara/-/issues .UE . - """.trimIndent().lines() + """.trimIndent().lines(), ) } catch (_: IOException) { throw IOException( "I could not create the man page for " + "arara due to an IO error. Please make sure the " + "current directory has the correct permissions " + - "and try again. The application will halt now." + "and try again. The application will halt now.", ) } } diff --git a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/Versions.kt b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/Versions.kt index ee6ad8acf..12d833e39 100644 --- a/buildSrc/src/main/kotlin/org/islandoftex/arara/build/Versions.kt +++ b/buildSrc/src/main/kotlin/org/islandoftex/arara/build/Versions.kt @@ -6,29 +6,29 @@ package org.islandoftex.arara.build */ object Versions { // plugin dependencies - const val detekt = "1.20.0" - const val dokka = "1.8.10" - const val kotlin = "1.8.20" + const val detekt = "1.23.1" + const val dokka = "1.9.0" + const val kotlin = "1.9.10" const val shadow = "7.1.2" - const val spotless = "6.5.2" - const val spotlessChangelog = "2.4.0" - const val versionsPlugin = "0.46.0" + const val spotless = "6.21.0" + const val spotlessChangelog = "3.0.2" + const val versionsPlugin = "0.48.0" // non-plugin dependencies - const val clikt = "3.4.2" + const val clikt = "4.2.0" const val coroutines = "1.4.2" const val jna = "5.13.0" - const val junit = "5.9.2" - const val kaml = "0.43.0" - const val korlibs = "2.7.0" - const val kotest = "4.6.3" - const val kotlinLogging = "2.1.21" - const val kotlinxSerialization = "1.5.0" + const val junit = "5.10.0" + const val kaml = "0.55.0" + const val korlibs = "4.0.10" + const val kotest = "5.7.2" + const val kotlinLogging = "3.0.5" + const val kotlinxSerialization = "1.6.0" const val jackson = "2.13.1" const val log4j = "2.20.0" - const val luak = "2.4.13" - const val mvel = "2.4.15.Final" - const val slf4j = "1.7.36" - const val yamlkt = "0.12.0" + const val luak = "3.4.0" + const val mvel = "2.5.0.Final" + const val slf4j = "2.0.9" + const val yamlkt = "0.13.0" const val ztExec = "1.12" } diff --git a/cli/build.gradle.kts b/cli/build.gradle.kts index 5ea1d7690..f63edb7ea 100644 --- a/cli/build.gradle.kts +++ b/cli/build.gradle.kts @@ -61,7 +61,7 @@ tasks { if (JavaVersion.current() > JavaVersion.VERSION_1_8) { doFirst { jvmArgs = listOf( - "--module-path", classpath.asPath + "--module-path", classpath.asPath, ) } } diff --git a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/interpreter/HaltExpectedException.kt b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/interpreter/HaltExpectedException.kt index 1513ad613..62942056b 100644 --- a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/interpreter/HaltExpectedException.kt +++ b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/interpreter/HaltExpectedException.kt @@ -10,5 +10,5 @@ import org.islandoftex.arara.api.session.ExecutionStatus */ internal class HaltExpectedException( msg: String, - val status: ExecutionStatus + val status: ExecutionStatus, ) : AraraException(msg) diff --git a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleFormat.kt b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleFormat.kt index 46ad50350..ce3f33c9a 100644 --- a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleFormat.kt +++ b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleFormat.kt @@ -13,5 +13,5 @@ enum class RuleFormat(val extension: String) { /** * The new and experimental Kotlin DSL format from version 6 on. */ - KOTLIN_DSL("kts") + KOTLIN_DSL("kts"), } diff --git a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/DisplayUtils.kt b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/DisplayUtils.kt index dff09221f..3f57d0a57 100644 --- a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/DisplayUtils.kt +++ b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/DisplayUtils.kt @@ -49,7 +49,7 @@ object DisplayUtils { listOf( LanguageController.messages.INFO_LABEL_ON_SUCCESS, LanguageController.messages.INFO_LABEL_ON_FAILURE, - LanguageController.messages.INFO_LABEL_ON_ERROR + LanguageController.messages.INFO_LABEL_ON_ERROR, ).map { it.length }.maxOrNull()!! } @@ -100,10 +100,11 @@ object DisplayUtils { * @param task Task name. */ private fun buildShortEntry(name: String, task: String) { - val result = if (longestMatch >= outputWidth) + val result = if (longestMatch >= outputWidth) { shortenedLongestMatch - else + } else { longestMatch + } val space = outputWidth - result - 1 val line = "($name) $task ".abbreviate(space - "... ".length) print(line.padEnd(space, '.') + " ") @@ -129,7 +130,7 @@ object DisplayUtils { } else { "\n" + (" " + getResult(value)) .padStart(outputWidth, '-') - } + }, ) } } @@ -173,7 +174,7 @@ object DisplayUtils { println(displaySeparator()) println( "($name) $task" - .abbreviate(outputWidth) + .abbreviate(outputWidth), ) println(displaySeparator()) } @@ -202,8 +203,9 @@ object DisplayUtils { fun printException(exception: AraraException) { displayException = true - if (displayResult) + if (displayResult) { println() + } if (displayLine) { if (!isDryRunMode) { println( @@ -212,17 +214,18 @@ object DisplayUtils { } else { (" " + LanguageController.messages.INFO_LABEL_ON_ERROR) .padStart(outputWidth, '-') - } + }, ) println() } } val text = ( - if (exception.hasException()) + if (exception.hasException()) { exception.message + " " + LanguageController.messages .INFO_DISPLAY_EXCEPTION_MORE_DETAILS - else + } else { exception.message + } ) ?: "EXCEPTION PROVIDES NO MESSAGE" // TODO: check null handling logger.error { text } @@ -243,10 +246,11 @@ object DisplayUtils { * @return The string representation. */ private fun getResult(value: Boolean): String { - return if (value) + return if (value) { LanguageController.messages.INFO_LABEL_ON_SUCCESS - else + } else { LanguageController.messages.INFO_LABEL_ON_FAILURE + } } /** @@ -263,14 +267,16 @@ object DisplayUtils { * @param authors The list of authors. */ fun printAuthors(authors: List) { - val line = if (authors.size == 1) + val line = if (authors.size == 1) { LanguageController.messages.INFO_LABEL_AUTHOR - else + } else { LanguageController.messages.INFO_LABEL_AUTHORS - val text = if (authors.isEmpty()) + } + val text = if (authors.isEmpty()) { LanguageController.messages.INFO_LABEL_NO_AUTHORS - else + } else { authors.joinToString(", ") { it.trim() } + } printWrapped("$line $text") } @@ -284,7 +290,7 @@ object DisplayUtils { printWrapped( LanguageController.messages.INFO_LABEL_CONDITIONAL + " (" + conditional.type + ") " + - conditional.condition + conditional.condition, ) } } @@ -298,8 +304,9 @@ object DisplayUtils { @Suppress("MagicNumber") internal fun byteSizeToString(size: Long): String { val conversionFactor = 1000.0 - return if (size < conversionFactor) "$size B" - else + return if (size < conversionFactor) { + "$size B" + } else { (ln(size.toDouble()) / ln(conversionFactor)).toInt().let { exp -> val baseSize = size / conversionFactor.pow(exp.toDouble()) val ones = baseSize.toInt() @@ -309,9 +316,10 @@ object DisplayUtils { Session.userInterfaceOptions.locale .decimalSeparator.toString(), tenths.toString(), - "kMGTPE"[exp - 1].toString() + "kMGTPE"[exp - 1].toString(), ) } + } } /** @@ -320,8 +328,9 @@ object DisplayUtils { * @param seconds The elapsed seconds. */ fun printTime(seconds: Double) { - if (displayLine || displayException) + if (displayLine || displayException) { println() + } val secondDuration = Duration.seconds(seconds) val text = LanguageController.messages.INFO_DISPLAY_EXECUTION_TIME @@ -331,8 +340,8 @@ object DisplayUtils { Session.userInterfaceOptions.locale .decimalSeparator.toString(), (secondDuration - Duration.seconds(secondDuration.inWholeSeconds)) - .inWholeMilliseconds.toString() - ) + .inWholeMilliseconds.toString(), + ), ) logger.info { text } printWrapped(text) @@ -344,7 +353,7 @@ object DisplayUtils { private fun displayDetailsLine() = println( (LanguageController.messages.INFO_LABEL_ON_DETAILS + " ") .abbreviate(outputWidth) - .padEnd(outputWidth, '-') + .padEnd(outputWidth, '-'), ) /** diff --git a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/StringExtensions.kt b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/StringExtensions.kt index 3c77a9c3b..a88310c5c 100644 --- a/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/StringExtensions.kt +++ b/cli/src/commonMain/kotlin/org/islandoftex/arara/cli/utils/StringExtensions.kt @@ -33,8 +33,9 @@ internal fun String.abbreviate(maxWidth: Int, ellipsis: String = "…"): String * @return The padded string. */ internal fun String.center(width: Int, padChar: Char): String { - return if (this.length > width) this - else { + return if (this.length > width) { + this + } else { val charsLeft = width - this.length padChar.toString().repeat(charsLeft / 2) + this + padChar.toString().repeat(ceil(charsLeft.toDouble() / 2.0).toInt()) diff --git a/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/DisplayUtilsTest.kt b/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/DisplayUtilsTest.kt index 58cdd74aa..c07551a52 100644 --- a/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/DisplayUtilsTest.kt +++ b/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/DisplayUtilsTest.kt @@ -15,7 +15,7 @@ class DisplayUtilsTest { 800 to "800 B", 1000 to "1.0 kB", 1024 to "1.0 kB", - 1000000 to "1.0 MB" + 1000000 to "1.0 MB", ).forEach { (key, value) -> assertEquals(DisplayUtils.byteSizeToString(key.toLong()), value) } diff --git a/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/StringExtensionsTest.kt b/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/StringExtensionsTest.kt index 30e2d19e1..98f126993 100644 --- a/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/StringExtensionsTest.kt +++ b/cli/src/commonTest/kotlin/org/islandoftex/arara/cli/utils/StringExtensionsTest.kt @@ -11,6 +11,7 @@ class StringExtensionsTest { assertEquals("Quack…", "Quack quack".abbreviate(6)) assertEquals("Quack Quack", "Quack Quack".abbreviate(80)) } + @Test fun shouldFailAbbreviatingShorterThanEllipsis() { assertFailsWith { diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/CLI.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/CLI.kt index 8dd565cce..4f0947e35 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/CLI.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/CLI.kt @@ -56,7 +56,8 @@ import kotlin.time.TimeSource * @since 5.0 */ class CLI : CliktCommand( - name = "arara", printHelpOnEmptyArgs = true, + name = "arara", + printHelpOnEmptyArgs = true, help = """ ${DisplayUtils.logoString.replace('\n', '\u0085').replace(' ', '\u00A0')} @@ -65,7 +66,7 @@ class CLI : CliktCommand( arara executes the TeX workflow you tell it to execute. Simply specify your needs within your TeX file and let arara do the work. These directives feature conditional execution and parameter expansion. - """ + """, ) { private val log by option("-l", "--log") .help("Generate a log output") @@ -76,13 +77,13 @@ class CLI : CliktCommand( private val dryRun by option("-n", "--dry-run") .help( "Go through all the motions of running a command, but " + - "with no actual calls" + "with no actual calls", ) .flag() private val safeRun by option("-S", "--safe-run") .help( "Run in safe mode and disable potentially harmful features. " + - "Make sure your projects uses only allowed features." + "Make sure your projects uses only allowed features.", ) .flag() private val wholeFile by option("-w", "--whole-file") @@ -146,7 +147,7 @@ class CLI : CliktCommand( DisplayUtils.printWrapped( "Found Lua file, attempted to parse it as a project but failed. " + "Continuing by treating the Lua file as regular input. " + - "See log for details.\n" + "See log for details.\n", ) logger.info { "Failed to parse Lua file argument as project: ${it.message}\n" + @@ -160,7 +161,7 @@ class CLI : CliktCommand( ?: Project( "Untitled", workingDir, - emptySet() + emptySet(), ).also { project -> ConfigurationUtils.configFileForProject(project)?.let { DisplayUtils.configurationFileName = it.toString() @@ -175,10 +176,10 @@ class CLI : CliktCommand( FileSearching.resolveFile( fileName, workingDir, - LinearExecutor.executionOptions + LinearExecutor.executionOptions, ) - }.toSet() - ) + }.toSet(), + ), ) } } @@ -190,7 +191,7 @@ class CLI : CliktCommand( Session.userInterfaceOptions = UserInterfaceOptions( locale = language?.let { MPPLocale(it) } ?: Session.userInterfaceOptions.locale, - swingLookAndFeel = Session.userInterfaceOptions.swingLookAndFeel + swingLookAndFeel = Session.userInterfaceOptions.swingLookAndFeel, ) LanguageController.loadMessagesFor(Session.userInterfaceOptions.locale) @@ -201,28 +202,31 @@ class CLI : CliktCommand( ?: LinearExecutor.executionOptions.maxLoops, timeoutValue = timeout?.let { Duration.milliseconds(it) } ?: LinearExecutor.executionOptions.timeoutValue, - verbose = if (verbose) + verbose = if (verbose) { true - else - LinearExecutor.executionOptions.verbose, + } else { + LinearExecutor.executionOptions.verbose + }, executionMode = when { dryRun -> ExecutionMode.DRY_RUN safeRun -> ExecutionMode.SAFE_RUN else -> LinearExecutor.executionOptions.executionMode }, - parseOnlyHeader = if (wholeFile) + parseOnlyHeader = if (wholeFile) { false - else + } else { LinearExecutor.executionOptions.parseOnlyHeader + }, ) Session.loggingOptions = LoggingOptions( - enableLogging = if (log) + enableLogging = if (log) { true - else - Session.loggingOptions.enableLogging, + } else { + Session.loggingOptions.enableLogging + }, appendLog = Session.loggingOptions.appendLog, - logFile = Session.loggingOptions.logFile + logFile = Session.loggingOptions.logFile, ) } @@ -235,13 +239,13 @@ class CLI : CliktCommand( */ private fun prependPreambleDirectives( fileType: FileType, - directives: List + directives: List, ): List { val resolvedPreamble = preamble ?: MvelState.defaultPreamble if (resolvedPreamble != null && resolvedPreamble !in MvelState.preambles) { throw AraraException( LanguageController.messages - .ERROR_PARSER_INVALID_PREAMBLE.format(resolvedPreamble) + .ERROR_PARSER_INVALID_PREAMBLE.format(resolvedPreamble), ) } val allDirectives = resolvedPreamble @@ -252,14 +256,15 @@ class CLI : CliktCommand( .lines() .filterNot { it.isEmpty() }, true, - fileType + fileType, ).plus(directives) } ?: directives - if (allDirectives.isEmpty()) + if (allDirectives.isEmpty()) { throw AraraException( LanguageController - .messages.ERROR_VALIDATE_NO_DIRECTIVES_FOUND + .messages.ERROR_VALIDATE_NO_DIRECTIVES_FOUND, ) + } return allDirectives } @@ -309,16 +314,17 @@ class CLI : CliktCommand( file, list .takeIf { list.isNotEmpty() && !MvelState.prependPreambleIfDirectivesGiven } - ?: prependPreambleDirectives(file.fileType, list) + ?: prependPreambleDirectives(file.fileType, list), ) - } + }, ) val projects = resolveProjects() - if (LinearExecutor.execute(projects).exitCode != 0) + if (LinearExecutor.execute(projects).exitCode != 0) { ExecutionStatus.ExternalCallFailed() - else + } else { ExecutionStatus.Processing() + } } catch (ex: AraraException) { // catch a propagated exception to replace intentionally left // out local treatment @@ -348,10 +354,11 @@ fun main(args: Array) { .completionOption( help = "Generate a completion script for arara. " + "Add 'source <(arara --generate-completion )' " + - "to your shell's init file." + "to your shell's init file.", ) .versionOption( - AraraAPI.version, names = setOf("-V", "--version"), + AraraAPI.version, + names = setOf("-V", "--version"), message = { "${DisplayUtils.logoString}\n\n" + "arara ${AraraAPI.version}\n" + @@ -361,7 +368,7 @@ fun main(args: Array) { CLI::class.java .getResource("/org/islandoftex/arara/cli/configuration/release-notes") .readText() - } + }, ) .main(args) } diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/configuration/ConfigurationUtils.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/configuration/ConfigurationUtils.kt index afca28f20..dcd58f3d7 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/configuration/ConfigurationUtils.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/configuration/ConfigurationUtils.kt @@ -30,7 +30,9 @@ object ConfigurationUtils { fun configFileForProject(project: Project): MPPPath? { val names = listOf( ".araraconfig.yaml", - "araraconfig.yaml", ".arararc.yaml", "arararc.yaml" + "araraconfig.yaml", + ".arararc.yaml", + "arararc.yaml", ) return project.workingDirectory.let { workingDir -> names.map { workingDir / it }.firstOrNull { it.exists } @@ -51,10 +53,11 @@ object ConfigurationUtils { */ @Throws(AraraException::class) private fun loadLocalConfiguration(file: MPPPath): LocalConfiguration { - return if (file.fileName.endsWith(".yaml")) + return if (file.fileName.endsWith(".yaml")) { LocalConfiguration.load(file) - else + } else { TODO("Kotlin DSL not implemented yet") + } } /** @@ -71,13 +74,13 @@ object ConfigurationUtils { val resource = loadLocalConfiguration(file) LinearExecutor.executionOptions = resource.toExecutionOptions( currentProject, - LinearExecutor.executionOptions + LinearExecutor.executionOptions, ) Session.loggingOptions = resource.toLoggingOptions( - Session.loggingOptions + Session.loggingOptions, ) Session.userInterfaceOptions = resource.toUserInterfaceOptions( - Session.userInterfaceOptions + Session.userInterfaceOptions, ) MvelState.preambles += resource.preambles diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/Interpreter.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/Interpreter.kt index 274a1692e..0cd047909 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/Interpreter.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/Interpreter.kt @@ -35,7 +35,7 @@ import org.mvel2.templates.TemplateRuntime class Interpreter( private val executionOptions: ExecutionOptions, currentFile: ProjectFile, - private val workingDirectory: MPPPath + private val workingDirectory: MPPPath, ) { private val logger = KotlinLogging.logger { } @@ -61,11 +61,11 @@ class Interpreter( listOf( InterpreterUtils.construct( path, directive.identifier, - RuleFormat.MVEL, workingDirectory + RuleFormat.MVEL, workingDirectory, ), InterpreterUtils.construct( path, directive.identifier, - RuleFormat.KOTLIN_DSL, workingDirectory + RuleFormat.KOTLIN_DSL, workingDirectory, ), // this lookup adds support for the rules distributed with // arara (in TL names should be unique, hence we avoided @@ -73,8 +73,8 @@ class Interpreter( // from version 6 on) InterpreterUtils.construct( path, "arara-rule-" + directive.identifier, - RuleFormat.MVEL, workingDirectory - ) + RuleFormat.MVEL, workingDirectory, + ), ) }.firstOrNull { it.exists } ?: throw AraraException( LanguageController.messages.ERROR_INTERPRETER_RULE_NOT_FOUND.format( @@ -82,8 +82,8 @@ class Interpreter( directive.identifier, paths.joinToString("; ", "(", ")") { it.normalize().toString() - } - ) + }, + ), ) } @@ -99,7 +99,7 @@ class Interpreter( private fun runBoolean( value: Boolean, conditional: DirectiveConditional, - authors: List + authors: List, ): Boolean = value.also { logger.info { LanguageController.messages.LOG_INFO_BOOLEAN_MODE.format(it) @@ -109,7 +109,7 @@ class Interpreter( DisplayUtils.printAuthors(authors) DisplayUtils.printWrapped( LanguageController.messages - .INFO_INTERPRETER_DRYRUN_MODE_BOOLEAN_MODE.format(it) + .INFO_INTERPRETER_DRYRUN_MODE_BOOLEAN_MODE.format(it), ) DisplayUtils.printConditional(conditional) } @@ -131,7 +131,7 @@ class Interpreter( command: Command, conditional: DirectiveConditional, authors: List, - ruleCommandExitValue: String? + ruleCommandExitValue: String?, ): Boolean { logger.info { LanguageController.messages.LOG_INFO_SYSTEM_COMMAND.format(command) @@ -144,13 +144,13 @@ class Interpreter( val context = mapOf("value" to code) TemplateRuntime.eval( "@{ " + (ruleCommandExitValue ?: "value == 0") + " }", - context + context, ) } catch (exception: RuntimeException) { throw AraraExceptionWithHeader( LanguageController.messages .ERROR_INTERPRETER_EXIT_RUNTIME_ERROR, - exception + exception, ) } @@ -159,14 +159,14 @@ class Interpreter( } else { throw AraraExceptionWithHeader( LanguageController.messages - .ERROR_INTERPRETER_WRONG_EXIT_CLOSURE_RETURN + .ERROR_INTERPRETER_WRONG_EXIT_CLOSURE_RETURN, ) } } else { DisplayUtils.printAuthors(authors) DisplayUtils.printWrapped( LanguageController.messages - .INFO_INTERPRETER_DRYRUN_MODE_SYSTEM_COMMAND.format(command) + .INFO_INTERPRETER_DRYRUN_MODE_SYSTEM_COMMAND.format(command), ) DisplayUtils.printConditional(conditional) } @@ -199,36 +199,39 @@ class Interpreter( command: SerialRuleCommand, conditional: DirectiveConditional, rule: Rule, - parameters: Map + parameters: Map, ) = try { resultToList(TemplateRuntime.eval(command.commandString!!, parameters)) } catch (exception: RuntimeException) { throw AraraExceptionWithHeader( LanguageController .messages.ERROR_INTERPRETER_COMMAND_RUNTIME_ERROR, - exception + exception, ) }.filter { it.toString().isNotBlank() } .fold(ExecutionStatus.Processing() as ExecutionStatus) { _, current -> DisplayUtils.printEntry( rule.displayName!!, command.name - ?: LanguageController.messages.INFO_LABEL_UNNAMED_TASK + ?: LanguageController.messages.INFO_LABEL_UNNAMED_TASK, ) val success = when (current) { is Boolean -> runBoolean( - current, conditional, - rule.authors + current, + conditional, + rule.authors, ) is Command -> runCommand( - current, conditional, - rule.authors, command.exit + current, + conditional, + rule.authors, + command.exit, ) else -> throw AraraExceptionWithHeader( LanguageController - .messages.ERROR_INTERPRETER_WRONG_RETURN_TYPE + .messages.ERROR_INTERPRETER_WRONG_RETURN_TYPE, ) } @@ -239,15 +242,15 @@ class Interpreter( LanguageController.messages .ERROR_INTERPRETER_USER_REQUESTED_HALT, ExecutionStatus.FinishedWithCode( - Session[haltKey].toString().toInt() - ) + Session[haltKey].toString().toInt(), + ), ) executionOptions.haltOnErrors && !success -> throw HaltExpectedException( LanguageController .messages.ERROR_INTERPRETER_COMMAND_UNSUCCESSFUL_EXIT .format(command.name), - ExecutionStatus.ExternalCallFailed() + ExecutionStatus.ExternalCallFailed(), ) success -> ExecutionStatus.Processing() else -> ExecutionStatus.ExternalCallFailed() @@ -266,14 +269,14 @@ class Interpreter( fun execute(directive: Directive): ExecutionStatus { logger.info { LanguageController.messages.LOG_INFO_INTERPRET_RULE.format( - directive.identifier + directive.identifier, ) } val file = getRule(directive, workingDirectory) logger.info { LanguageController.messages.LOG_INFO_RULE_LOCATION.format( - file.parent + file.parent, ) } @@ -282,9 +285,11 @@ class Interpreter( val parameters = parseArguments(rule, directive).plus(MvelState.ruleMethods) val evaluator = DirectiveConditionalEvaluator(executionOptions) val available = - if (InterpreterUtils.runPriorEvaluation(directive.conditional)) + if (InterpreterUtils.runPriorEvaluation(directive.conditional)) { evaluator.evaluate(directive.conditional) - else true + } else { + true + } return when { !available -> @@ -302,14 +307,14 @@ class Interpreter( do { retValue = rule.commands.fold( ExecutionStatus.Processing() - as ExecutionStatus + as ExecutionStatus, ) { _, command -> executeCommand( // TODO: remove cast command as SerialRuleCommand, directive.conditional, rule, - parameters + parameters, ) } } while (evaluator.evaluate(directive.conditional)) @@ -326,7 +331,7 @@ class Interpreter( LanguageController.messages.ERROR_RULE_IDENTIFIER_AND_PATH .format(directive.identifier, file.parent.toString()) + " " + e.message, - e.exception ?: e + e.exception ?: e, ) } } @@ -343,7 +348,7 @@ class Interpreter( */ private fun getUnknownKeys( parameters: Map, - arguments: List> + arguments: List>, ): Set { val found = parameters.keys val expected = arguments.map { it.identifier } @@ -362,24 +367,24 @@ class Interpreter( */ @Suppress("UNCHECKED_CAST") @Throws(AraraException::class) - private fun parseArguments(rule: Rule, directive: Directive): - Map { + private fun parseArguments(rule: Rule, directive: Directive): Map { val unknown = getUnknownKeys(directive.parameters, rule.arguments) .minus("reference") - if (unknown.isNotEmpty()) + if (unknown.isNotEmpty()) { throw AraraExceptionWithHeader( LanguageController.messages .ERROR_INTERPRETER_UNKNOWN_KEYS.format( - unknown.joinToString(", ", "(", ")") - ) + unknown.joinToString(", ", "(", ")"), + ), ) + } val resolvedArguments = mutableMapOf() resolvedArguments["reference"] = directive.parameters.getValue("reference") val context = mapOf( "parameters" to directive.parameters, - "reference" to directive.parameters.getValue("reference") + "reference" to directive.parameters.getValue("reference"), ).plus(MvelState.ruleMethods) rule.arguments.forEach { argument -> @@ -387,7 +392,7 @@ class Interpreter( argument as RuleArgument, directive.parameters.containsKey(argument.identifier), context, - directive.parameters[argument.identifier] + directive.parameters[argument.identifier], ) } @@ -410,19 +415,21 @@ class Interpreter( argument: RuleArgument, idInDirectiveParams: Boolean, context: Map, - parameterValue: Any? + parameterValue: Any?, ): List<*> { - if (argument.isRequired && !idInDirectiveParams) + if (argument.isRequired && !idInDirectiveParams) { throw AraraExceptionWithHeader( LanguageController.messages.ERROR_INTERPRETER_ARGUMENT_IS_REQUIRED - .format(argument.identifier) + .format(argument.identifier), ) + } - return if (idInDirectiveParams) + return if (idInDirectiveParams) { argument.processor(parameterValue, context) - else + } else { argument.defaultValue?.let { default -> argument.processor(default, context) } ?: emptyList() + } } } diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterUtils.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterUtils.kt index 119e3b5ff..64234ad8d 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterUtils.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterUtils.kt @@ -38,7 +38,8 @@ internal object InterpreterUtils { when (conditional.type) { DirectiveConditionalType.IF, DirectiveConditionalType.WHILE, - DirectiveConditionalType.UNLESS -> true + DirectiveConditionalType.UNLESS, + -> true else -> false } } @@ -56,7 +57,7 @@ internal object InterpreterUtils { internal fun run(command: Command): Int = Environment.executeSystemCommand( command, !LinearExecutor.executionOptions.verbose, - LinearExecutor.executionOptions.timeoutValue + LinearExecutor.executionOptions.timeoutValue, ).let { val (exitCode, output) = it if (exitCode == Environment.errorExitStatus) { @@ -74,17 +75,17 @@ internal object InterpreterUtils { else -> ERROR_RUN_GENERIC_EXCEPTION } }, - AraraException(output) + AraraException(output), ) } logger.info { """ ${DisplayUtils.displayOutputSeparator( - LanguageController.messages.LOG_INFO_BEGIN_BUFFER + LanguageController.messages.LOG_INFO_BEGIN_BUFFER, )} $output ${DisplayUtils.displayOutputSeparator( - LanguageController.messages.LOG_INFO_END_BUFFER + LanguageController.messages.LOG_INFO_END_BUFFER, )} """.trimIndent() } @@ -105,7 +106,7 @@ internal object InterpreterUtils { path: MPPPath, name: String, format: RuleFormat, - workingDirectory: MPPPath + workingDirectory: MPPPath, ): MPPPath = "$name.${format.extension}".let { fileName -> if (path.isAbsolute) { path / fileName diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveImpl.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveImpl.kt index 1b73bc8bc..ef9a5b565 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveImpl.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveImpl.kt @@ -17,11 +17,12 @@ data class DirectiveImpl( override val identifier: String, override val parameters: Map, override val conditional: DirectiveConditional, - override val lineNumbers: List + override val lineNumbers: List, ) : Directive { override fun execute(): Int = Interpreter( - LinearExecutor.executionOptions, LinearExecutor.currentFile!!, - LinearExecutor.currentProject!!.workingDirectory + LinearExecutor.executionOptions, + LinearExecutor.currentFile!!, + LinearExecutor.currentProject!!.workingDirectory, ).execute(this).exitCode override fun toString(): String { diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveUtils.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveUtils.kt index d43f10474..dbd0703b8 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveUtils.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/DirectiveUtils.kt @@ -47,7 +47,7 @@ object DirectiveUtils { identifier = id, parameters = parameterMap, conditional = conditional, - lineNumbers = lines + lineNumbers = lines, ) }, buildDirective = { id, parameters, conditional, lines -> @@ -55,9 +55,9 @@ object DirectiveUtils { identifier = id, parameters = parameters, conditional = conditional, - lineNumbers = lines + lineNumbers = lines, ) - } + }, ) } @@ -73,10 +73,11 @@ object DirectiveUtils { @Throws(AraraException::class) private fun getParameters( text: String?, - numbers: List + numbers: List, ): Map { - if (text == null) + if (text == null) { return mapOf() + } val map = kotlin.runCatching { Yaml.Default.decodeFromString>(text) @@ -84,14 +85,14 @@ object DirectiveUtils { throw AraraException( LanguageController.messages.ERROR_VALIDATE_YAML_EXCEPTION .format( - numbers.joinToString(", ", "(", ")") + numbers.joinToString(", ", "(", ")"), ), - it + it, ) } return if ("options" in map.keys && LinearExecutor.executionOptions - .executionMode != ExecutionMode.SAFE_RUN + .executionMode != ExecutionMode.SAFE_RUN ) { // perform directive interpolation by applying MVEL methods to the // directive arguments @@ -108,13 +109,15 @@ object DirectiveUtils { throw AraraException( LanguageController.messages .ERROR_EXTRACTOR_INTERPOLATION_FAILURE, - it + it, ) } } ?: emptyList() - ) + ), ) - } else map + } else { + map + } } /** @@ -129,22 +132,23 @@ object DirectiveUtils { @Throws(AraraException::class) fun process( file: ProjectFile, - directives: List + directives: List, ): List = directives.flatMap { directive -> val parameters = directive.parameters - if (parameters.containsKey("reference")) + if (parameters.containsKey("reference")) { throw AraraException( LanguageController.messages.ERROR_VALIDATE_REFERENCE_IS_RESERVED - .format(directive.lineNumbers.joinToString(", ", "(", ")")) + .format(directive.lineNumbers.joinToString(", ", "(", ")")), ) + } if (parameters.containsKey("files")) { Directives.replicateDirective( parameters.getValue("files"), parameters.minus("files"), - directive + directive, ) } else { listOf( @@ -152,8 +156,8 @@ object DirectiveUtils { directive.identifier, parameters.plus("reference" to file.path), directive.conditional, - directive.lineNumbers - ) + directive.lineNumbers, + ), ) } }.also { result -> @@ -161,7 +165,7 @@ object DirectiveUtils { """ ${LanguageController.messages.LOG_INFO_VALIDATED_DIRECTIVES} ${DisplayUtils.displayOutputSeparator( - LanguageController.messages.LOG_INFO_DIRECTIVES_BLOCK + LanguageController.messages.LOG_INFO_DIRECTIVES_BLOCK, )} ${result.joinToString("\n")} ${DisplayUtils.displaySeparator()} diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleUtils.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleUtils.kt index 50a3ba9f8..1040e63d0 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleUtils.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/ruleset/RuleUtils.kt @@ -25,9 +25,10 @@ object RuleUtils { */ @Throws(AraraException::class) fun parseRule(file: MPPPath, identifier: String): org.islandoftex.arara.api.rules.Rule { - return if (file.toString().substringAfterLast('.') == "yaml") + return if (file.toString().substringAfterLast('.') == "yaml") { Rule.parse(file, identifier) - else + } else { TODO("Kotlin DSL not implemented yet") + } } } diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/JVMExtensions.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/JVMExtensions.kt index d41b12cd2..e8659894e 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/JVMExtensions.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/JVMExtensions.kt @@ -34,32 +34,32 @@ fun ProjectFile.printFileInformation() { """.trimIndent().formatString( Environment.getSystemProperty( "java.version", - "[unknown version]" + "[unknown version]", ), Environment.getSystemProperty( "java.vendor", - "[unknown vendor]" + "[unknown vendor]", ), Environment.getSystemProperty( "java.home", - "[unknown location]" + "[unknown location]", ), Environment.getSystemProperty( "os.name", - "[unknown OS name]" + "[unknown OS name]", ), Environment.getSystemProperty( "os.arch", - "[unknown OS arch]" + "[unknown OS arch]", ), Environment.getSystemProperty( "os.version", - "[unknown OS version]" + "[unknown OS version]", ), Environment.getSystemProperty( "user.home", - "[unknown user's home directory]" - ) + "[unknown user's home directory]", + ), ) } LanguageController.messages.INFO_DISPLAY_FILE_INFORMATION @@ -67,7 +67,7 @@ fun ProjectFile.printFileInformation() { path.fileName, DisplayUtils.byteSizeToString(path.fileSize), DateFormat("yyyy-MM-dd HH:mm:ss") - .format(path.lastModified) + .format(path.lastModified), ).let { logger.info { it } DisplayUtils.printWrapped(it) diff --git a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/LoggingUtils.kt b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/LoggingUtils.kt index d115fa985..61ff254a3 100644 --- a/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/LoggingUtils.kt +++ b/cli/src/jvmMain/kotlin/org/islandoftex/arara/cli/utils/LoggingUtils.kt @@ -28,7 +28,7 @@ object LoggingUtils { // TODO: check for multi-threading ThreadContext.put( "araraLogFile", - loggingOptions.logFile.normalize().toString() + loggingOptions.logFile.normalize().toString(), ) val loggerContext = LogManager.getContext(false) as org.apache.logging.log4j.core.LoggerContext diff --git a/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterTest.kt b/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterTest.kt index 68dbb32cc..239ff293b 100644 --- a/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterTest.kt +++ b/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/interpreter/InterpreterTest.kt @@ -20,17 +20,20 @@ class InterpreterTest : ShouldSpec({ .normalize() / "halt.tex" val haltDirective = Directives.extractDirectives( listOf("% arara: halt"), - false, texFile + false, + texFile, ).single().run { DirectiveImpl( - identifier, parameters.plus("reference" to filePath.toString()), - conditional, lineNumbers + identifier, + parameters.plus("reference" to filePath.toString()), + conditional, + lineNumbers, ) } Interpreter( ExecutionOptions(rulePaths = setOf(rulePath)), - ProjectFile(filePath, texFile), filePath.parent + ProjectFile(filePath, texFile), filePath.parent, ) .execute(haltDirective).exitCode shouldBe 0 } @@ -41,17 +44,20 @@ class InterpreterTest : ShouldSpec({ val filePath = MPPPath(rulePath / "halt-error.tex") val haltDirective = Directives.extractDirectives( listOf("% arara: halt"), - false, texFile + false, + texFile, ).single().run { DirectiveImpl( - identifier, parameters.plus("reference" to filePath.toString()), - conditional, lineNumbers + identifier, + parameters.plus("reference" to filePath.toString()), + conditional, + lineNumbers, ) } Interpreter( ExecutionOptions(rulePaths = setOf(rulePath)), - ProjectFile(filePath, texFile), rulePath + ProjectFile(filePath, texFile), rulePath, ) .execute(haltDirective).exitCode shouldNotBe 0 } diff --git a/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/utils/ExecutionTest.kt b/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/utils/ExecutionTest.kt index bd6c4b9a4..b2247239a 100644 --- a/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/utils/ExecutionTest.kt +++ b/cli/src/jvmTest/kotlin/org/islandoftex/arara/cli/utils/ExecutionTest.kt @@ -38,14 +38,14 @@ class ExecutionTest : ShouldSpec({ }, processDirectives = { file, list -> DirectiveUtils.process(file, list) - } + }, ) } fun getPathForTest(name: String): String = "src/jvmTest/resources/executiontests/$name" fun outputForTest( testName: String, - fileName: String = "$testName.tex" + fileName: String = "$testName.tex", ): String { val sysout = System.out val output = ByteArrayOutputStream() @@ -55,16 +55,17 @@ class ExecutionTest : ShouldSpec({ LinearExecutor.execute( listOf( Project( - "Test", workingDirectory, + "Test", + workingDirectory, setOf( FileSearching.resolveFile( fileName, workingDirectory, - LinearExecutor.executionOptions - ) - ) - ) - ) + LinearExecutor.executionOptions, + ), + ), + ), + ), ) return output.toByteArray().toString(Charsets.UTF_8) } catch (ex: Exception) { diff --git a/cli/src/jvmTest/resources/executiontests/conditionals/conditionals.quack b/cli/src/jvmTest/resources/executiontests/conditionals/conditionals.quack new file mode 100644 index 000000000..ad2a91795 --- /dev/null +++ b/cli/src/jvmTest/resources/executiontests/conditionals/conditionals.quack @@ -0,0 +1 @@ +Duck \ No newline at end of file diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/ExecutionOptions.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/ExecutionOptions.kt index 07b918221..330d0b40a 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/ExecutionOptions.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/ExecutionOptions.kt @@ -16,18 +16,17 @@ data class ExecutionOptions( override val verbose: Boolean = false, override val executionMode: ExecutionMode = ExecutionMode.NORMAL_RUN, override val rulePaths: Set = setOf( - ConfigurationUtils.applicationPath / "rules" + ConfigurationUtils.applicationPath / "rules", ), override val fileTypes: List = ConfigurationUtils.defaultFileTypes, - override val parseOnlyHeader: Boolean = true + override val parseOnlyHeader: Boolean = true, ) : ExecutionOptions { companion object { /** * As the interface does not have a copy method, we provide this * conversion method. */ - fun from(options: ExecutionOptions): - org.islandoftex.arara.core.configuration.ExecutionOptions { + fun from(options: ExecutionOptions): org.islandoftex.arara.core.configuration.ExecutionOptions { return ExecutionOptions( maxLoops = options.maxLoops, timeoutValue = options.timeoutValue, @@ -38,7 +37,7 @@ data class ExecutionOptions( executionMode = options.executionMode, rulePaths = options.rulePaths, fileTypes = options.fileTypes, - parseOnlyHeader = options.parseOnlyHeader + parseOnlyHeader = options.parseOnlyHeader, ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/LoggingOptions.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/LoggingOptions.kt index e7184b2ee..7b4c46c08 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/LoggingOptions.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/LoggingOptions.kt @@ -7,5 +7,5 @@ import org.islandoftex.arara.api.files.MPPPath data class LoggingOptions( override val enableLogging: Boolean = false, override val appendLog: Boolean = false, - override val logFile: MPPPath = MPPPath("arara.log") + override val logFile: MPPPath = MPPPath("arara.log"), ) : LoggingOptions diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/UserInterfaceOptions.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/UserInterfaceOptions.kt index 14d6b8896..ee04eb66d 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/UserInterfaceOptions.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/configuration/UserInterfaceOptions.kt @@ -7,5 +7,5 @@ import org.islandoftex.arara.api.localization.MPPLocale data class UserInterfaceOptions( override val locale: MPPLocale = MPPLocale("en"), override val swingLookAndFeel: String = "none", - override val terminalOutputWidth: Int = 65 + override val terminalOutputWidth: Int = 65, ) : UserInterfaceOptions diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/Graph.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/Graph.kt index 74e543b5d..ed2410bc4 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/Graph.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/Graph.kt @@ -9,10 +9,11 @@ internal open class Graph { private val indegree = mutableMapOf() private fun updateInDegree(vertex: T) { - if (vertex in indegree) + if (vertex in indegree) { indegree[vertex] = indegree[vertex]!!.inc() - else + } else { throw NoSuchElementException("Vertex $vertex in graph expected") + } } /** @@ -21,10 +22,12 @@ internal open class Graph { * @param vertex The new vertex. */ fun addVertex(vertex: T) { - if (vertex !in vertices) + if (vertex !in vertices) { vertices[vertex] = mutableSetOf() - if (vertex !in indegree) + } + if (vertex !in indegree) { indegree[vertex] = 0 + } } /** diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraph.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraph.kt index 76a9ba735..d7875b939 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraph.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraph.kt @@ -22,7 +22,7 @@ internal class ProjectGraph : Graph() { addEdge( projects.find { it.name == dependency } ?: throw AraraException("Stray project dependencies"), - project + project, ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Database.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Database.kt index 44b9083f0..3cb695d95 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Database.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Database.kt @@ -28,7 +28,7 @@ data class Database( * the key is the absolute canonical file and the value * is its corresponding CRC32 hash. */ - private val map: MutableMap = mutableMapOf() + private val map: MutableMap = mutableMapOf(), ) : Database { /** * Check whether the database contains a file. @@ -71,13 +71,14 @@ data class Database( @Throws(NoSuchElementException::class) override fun remove(path: MPPPath) { val normalPath = path.normalize().toString() - if (normalPath in map) + if (normalPath in map) { map.remove(normalPath) - else + } else { throw NoSuchElementException( "Attempt to remove non-existent path " + - "from database." + "from database.", ) + } } /** @@ -98,7 +99,7 @@ data class Database( throw AraraException( LanguageController.messages.ERROR_SAVE_COULD_NOT_SAVE_XML .formatString(path.fileName), - it + it, ) } } @@ -120,19 +121,20 @@ data class Database( val text = runBlockingNoJs { localVfs(path.normalize().toString()).readString() } - if (!text.startsWith("!database")) + if (!text.startsWith("!database")) { throw AraraException("Database should start with !database") + } Yaml.Default.decodeFromString( serializer(), text.lines() - .drop(1).joinToString("\n") + .drop(1).joinToString("\n"), ) }.getOrElse { throw AraraException( LanguageController .messages.ERROR_LOAD_COULD_NOT_LOAD_XML .formatString(path.fileName), - it + it, ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileHandling.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileHandling.kt index 883e9762d..2f0a12a63 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileHandling.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileHandling.kt @@ -59,7 +59,7 @@ object FileHandling { } catch (exception: IOException) { throw AraraException( LanguageController.messages.ERROR_CALCULATEHASH_IO_EXCEPTION, - exception + exception, ) } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileSearching.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileSearching.kt index c62b1d8a6..547b4a4c1 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileSearching.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileSearching.kt @@ -44,20 +44,21 @@ object FileSearching { fun listFilesByExtensions( directory: MPPPath, extensions: List, - recursive: Boolean + recursive: Boolean, ): List = runBlockingNoJs { LocalVfs[directory.normalize().toString()].runCatching { // return the result of the // provided search - if (recursive) + if (recursive) { listRecursive() - else + } else { list() + } }.getOrDefault( // if something bad happens, // gracefully fallback to // an empty file list - emptyFlow() + emptyFlow(), ).filter { !it.isDirectory() && extensions.contains(it.extension) @@ -78,7 +79,7 @@ object FileSearching { fun listFilesByPatterns( directory: MPPPath, patterns: List, - recursive: Boolean + recursive: Boolean, ): List = runBlockingNoJs { // return the result of the provided // search, with the wildcard filter @@ -87,15 +88,16 @@ object FileSearching { LocalVfs[directory.normalize().toString()].runCatching { // return the result of the // provided search - if (recursive) + if (recursive) { listRecursive() - else + } else { list() + } }.getOrDefault( // if something bad happens, // gracefully fallback to // an empty file list - emptyFlow() + emptyFlow(), ).filter { file -> !file.isDirectory() && regexes.any { it.matches(file.baseName) } @@ -116,7 +118,7 @@ object FileSearching { fun resolveFile( reference: String, workingDirectory: MPPPath, - executionOptions: ExecutionOptions + executionOptions: ExecutionOptions, ): ProjectFile = lookupFile(reference, workingDirectory, executionOptions) ?: throw AraraException( @@ -124,8 +126,8 @@ object FileSearching { .formatString( reference, executionOptions.fileTypes - .joinToString(" | ", "[ ", " ]") - ) + .joinToString(" | ", "[ ", " ]"), + ), ) /** @@ -140,7 +142,7 @@ object FileSearching { internal fun lookupFile( reference: String, workingDirectory: MPPPath, - executionOptions: ExecutionOptions + executionOptions: ExecutionOptions, ): ProjectFile? { val types = executionOptions.fileTypes @@ -156,7 +158,7 @@ object FileSearching { ProjectFile( path = testFile, fileType = types.firstOrNull { extension == it.extension } - ?: FileType.UNKNOWN_TYPE + ?: FileType.UNKNOWN_TYPE, ) } } @@ -178,7 +180,7 @@ object FileSearching { types.map { testFile.parent / "${name.removeSuffix(".").trim()}.${it.extension}" - } + }, ) .firstOrNull { it.exists && it.isRegularFile } ?.let { found -> @@ -186,7 +188,7 @@ object FileSearching { ProjectFile( found, types.firstOrNull { extension == it.extension } - ?: FileType.UNKNOWN_TYPE + ?: FileType.UNKNOWN_TYPE, ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileType.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileType.kt index 6200f7753..a29dccdc9 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileType.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/FileType.kt @@ -6,7 +6,7 @@ import org.islandoftex.arara.api.files.FileType data class FileType( override val extension: String = FileType.INVALID_EXTENSION, - override val pattern: String = FileType.INVALID_PATTERN + override val pattern: String = FileType.INVALID_PATTERN, ) : FileType { init { try { @@ -14,7 +14,7 @@ data class FileType( } catch (e: IllegalArgumentException) { throw AraraException( "The pattern you wanted to choose for this file type is invalid.", - e + e, ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Project.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Project.kt index 86fab0a7e..23712c793 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Project.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/Project.kt @@ -9,5 +9,5 @@ data class Project( override val name: String, override val workingDirectory: MPPPath, override val files: Set, - override val dependencies: Set = setOf() + override val dependencies: Set = setOf(), ) : Project diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/ProjectFile.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/ProjectFile.kt index e592a8956..9730ecb74 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/ProjectFile.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/files/ProjectFile.kt @@ -14,7 +14,7 @@ import org.islandoftex.arara.core.session.LinearExecutor open class ProjectFile( override val path: MPPPath, override val fileType: FileType, - override val priority: Int = DEFAULT_PRIORITY + override val priority: Int = DEFAULT_PRIORITY, ) : ProjectFile { companion object { /** @@ -48,12 +48,12 @@ open class ProjectFile( Directives.extractDirectives( path.readLines(), LinearExecutor.executionOptions.parseOnlyHeader, - fileType + fileType, ) } catch (ioexception: AraraIOException) { throw AraraException( LanguageController.messages.ERROR_EXTRACTOR_IO_ERROR, - ioexception + ioexception, ) } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/BrazilianLanguage.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/BrazilianLanguage.kt index 272b295f9..88828f2aa 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/BrazilianLanguage.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/BrazilianLanguage.kt @@ -85,5 +85,5 @@ class BrazilianLanguage : Messages( LOG_INFO_SYSTEM_COMMAND = "Comando de sistema: %s", LOG_INFO_TASK_RESULT = "Resultado da tarefa:", LOG_INFO_VALIDATED_DIRECTIVES = "Todas as diretivas foram validadas. Estamos prontos para continuar.", - LOG_INFO_WELCOME_MESSAGE = "Olá, eu sou o arara %s!" + LOG_INFO_WELCOME_MESSAGE = "Olá, eu sou o arara %s!", ) diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/DutchLanguage.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/DutchLanguage.kt index 37e9548c5..f8e76f383 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/DutchLanguage.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/DutchLanguage.kt @@ -85,5 +85,5 @@ class DutchLanguage : Messages( LOG_INFO_SYSTEM_COMMAND = "Systeemopdracht: %s", LOG_INFO_TASK_RESULT = "Taakresultaat:", LOG_INFO_VALIDATED_DIRECTIVES = "Alle directives zijn gevalideerd, we kunnen beginnen.", - LOG_INFO_WELCOME_MESSAGE = "Welkom bij arara %s!" + LOG_INFO_WELCOME_MESSAGE = "Welkom bij arara %s!", ) diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/GermanLanguage.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/GermanLanguage.kt index 865b040df..84a08cc84 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/GermanLanguage.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/GermanLanguage.kt @@ -85,5 +85,5 @@ class GermanLanguage : Messages( LOG_INFO_SYSTEM_COMMAND = "Systemkommando: %s", LOG_INFO_TASK_RESULT = "Resultat der Aufgabe:", LOG_INFO_VALIDATED_DIRECTIVES = "Alle Direktiven sind gültig. Wir sind guter Dinge.", - LOG_INFO_WELCOME_MESSAGE = "Willkommen bei arara %s!" + LOG_INFO_WELCOME_MESSAGE = "Willkommen bei arara %s!", ) diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/ItalianLanguage.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/ItalianLanguage.kt index c60a1dc8c..cd736a6fb 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/ItalianLanguage.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/ItalianLanguage.kt @@ -85,5 +85,5 @@ class ItalianLanguage : Messages( LOG_INFO_SYSTEM_COMMAND = "Comando di sistema: %s", LOG_INFO_TASK_RESULT = "Risultato del compito:", LOG_INFO_VALIDATED_DIRECTIVES = "Tutte le direttive erano valide. Pronti a partire.", - LOG_INFO_WELCOME_MESSAGE = "Benvenuto in arara %s!" + LOG_INFO_WELCOME_MESSAGE = "Benvenuto in arara %s!", ) diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/NorfolkLanguage.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/NorfolkLanguage.kt index e2bba92df..c28281f8b 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/NorfolkLanguage.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/localization/NorfolkLanguage.kt @@ -85,5 +85,5 @@ class NorfolkLanguage : Messages( LOG_INFO_SYSTEM_COMMAND = "System command: %s", LOG_INFO_TASK_RESULT = "Here's what that jarb say:", LOG_INFO_VALIDATED_DIRECTIVES = "Thass a masterous jarb, orl the directives are in good kelter. We can git troshin'.", - LOG_INFO_WELCOME_MESSAGE = "Hello, my bewty. Welcome to arara %s! (Thass one onnem hully big birds they git in Brazil.)" + LOG_INFO_WELCOME_MESSAGE = "Hello, my bewty. Welcome to arara %s! (Thass one onnem hully big birds they git in Brazil.)", ) diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditional.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditional.kt index e735cf2ce..50a6537c2 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditional.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditional.kt @@ -14,7 +14,7 @@ import org.islandoftex.arara.api.rules.DirectiveConditionalType */ data class DirectiveConditional( override val type: DirectiveConditionalType = DirectiveConditionalType.NONE, - override val condition: String = "" + override val condition: String = "", ) : DirectiveConditional { /** * Provides a textual representation of the conditional object. @@ -22,8 +22,10 @@ data class DirectiveConditional( */ override fun toString(): String { return "{ $type" + - if (type != DirectiveConditionalType.NONE) + if (type != DirectiveConditionalType.NONE) { ", expression: ${condition.trim()}" - else "" + " }" + } else { + "" + " }" + } } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditionalEvaluator.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditionalEvaluator.kt index f2bfd0109..9f1da5687 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditionalEvaluator.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveConditionalEvaluator.kt @@ -16,7 +16,7 @@ import org.islandoftex.arara.api.rules.DirectiveConditionalType * @since 4.0 */ abstract class DirectiveConditionalEvaluator( - private val executionOptions: ExecutionOptions + private val executionOptions: ExecutionOptions, ) { /** * This attribute holds the maximum number of @@ -45,7 +45,7 @@ abstract class DirectiveConditionalEvaluator( */ private fun isIfUnlessAndHalt( type: DirectiveConditionalType, - haltCheck: Boolean = true + haltCheck: Boolean = true, ): Boolean = ( type == DirectiveConditionalType.IF || @@ -77,9 +77,9 @@ abstract class DirectiveConditionalEvaluator( if (conditional.type == DirectiveConditionalType.NONE || executionOptions.executionMode == ExecutionMode.DRY_RUN || isIfUnlessAndHalt(conditional.type, true) - ) + ) { return false - else if (isIfUnlessAndHalt(conditional.type, false)) { + } else if (isIfUnlessAndHalt(conditional.type, false)) { halt = true } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveFetchingHooks.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveFetchingHooks.kt index be4708604..bc2c000be 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveFetchingHooks.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/DirectiveFetchingHooks.kt @@ -33,5 +33,5 @@ data class DirectiveFetchingHooks( val buildDirective: (String, Map, DirectiveConditional, List) -> Directive = { _, _, _, _ -> TODO("directives can't be built by default") - } + }, ) diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/Directives.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/Directives.kt index e088dc5e2..e2a69de88 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/Directives.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/rules/Directives.kt @@ -42,7 +42,7 @@ object Directives { private fun getPotentialDirectiveLines( lines: List, parseOnlyHeader: Boolean, - pattern: String + pattern: String, ): Map { val validLinePattern = pattern.toRegex() val validLineStartPattern = (pattern + namePattern).toRegex() @@ -78,7 +78,7 @@ object Directives { fun extractDirectives( lines: List, parseOnlyHeader: Boolean, - fileType: FileType + fileType: FileType, ): List { val pairs = getPotentialDirectiveLines(lines, parseOnlyHeader, fileType.pattern) .takeIf { it.isNotEmpty() } ?: return emptyList() @@ -92,7 +92,7 @@ object Directives { throw AraraException( LanguageController .messages.ERROR_VALIDATE_ORPHAN_LINEBREAK - .formatString(lineno.toString()) + .formatString(lineno.toString()), ) } else { assembler.addLineNumber(lineno) @@ -139,17 +139,17 @@ object Directives { type = match.groupValues[5] .takeIf { it.isNotEmpty() } .toDirectiveConditional(), - condition = match.groupValues[6] + condition = match.groupValues[6], ), // line numbers - assembler.getLineNumbers() + assembler.getLineNumbers(), ) } ?: throw AraraException( LanguageController.messages.ERROR_VALIDATE_INVALID_DIRECTIVE_FORMAT .formatString( assembler.getLineNumbers() - .joinToString(", ", "(", ")") - ) + .joinToString(", ", "(", ")"), + ), ) /** @@ -167,7 +167,7 @@ object Directives { fun replicateDirective( holder: Any, parameters: Map, - directive: Directive + directive: Directive, ): List { return if (holder is List<*>) { // we received a file list, so we map that list to files @@ -181,7 +181,7 @@ object Directives { directive.identifier, parameters.plus("reference" to reference), directive.conditional, - directive.lineNumbers + directive.lineNumbers, ) } .toList() @@ -192,16 +192,16 @@ object Directives { LanguageController.messages.ERROR_VALIDATE_EMPTY_FILES_LIST .formatString( directive.lineNumbers - .joinToString(", ", "(", ")") - ) + .joinToString(", ", "(", ")"), + ), ) } else { throw AraraException( LanguageController.messages.ERROR_VALIDATE_FILES_IS_NOT_A_LIST .formatString( directive.lineNumbers - .joinToString(", ", "(", ")") - ) + .joinToString(", ", "(", ")"), + ), ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Command.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Command.kt index 9f738b8fd..1a49eaa3a 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Command.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Command.kt @@ -13,7 +13,7 @@ import org.islandoftex.arara.api.session.Command */ data class Command( override val elements: List, - override val workingDirectory: MPPPath? = null + override val workingDirectory: MPPPath? = null, ) : Command { /** * Provides a textual representation of the current command. diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutionReport.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutionReport.kt index 4c4e77ecd..d998ad066 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutionReport.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutionReport.kt @@ -7,5 +7,5 @@ import kotlin.time.TimeMark data class ExecutionReport( override val executionStarted: TimeMark, override val executionStopped: TimeMark, - override val exitCode: Int + override val exitCode: Int, ) : ExecutionReport diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutorHooks.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutorHooks.kt index fabc01e3d..27b894b87 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutorHooks.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/ExecutorHooks.kt @@ -17,5 +17,5 @@ data class ExecutorHooks( val executeAfterProject: (Project) -> Unit = { _ -> }, val executeBeforeFile: (ProjectFile) -> Unit = { _ -> }, val executeAfterFile: (ExecutionReport) -> Unit = { _ -> }, - val processDirectives: (ProjectFile, List) -> List = { _, l -> l } + val processDirectives: (ProjectFile, List) -> List = { _, l -> l }, ) diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/LinearExecutor.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/LinearExecutor.kt index ba7285384..5b626e056 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/LinearExecutor.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/LinearExecutor.kt @@ -39,18 +39,20 @@ object LinearExecutor : Executor { override var executionOptions: ExecutionOptions = org.islandoftex.arara.core.configuration.ExecutionOptions() set(value) { - if (currentFile != null) - throw AraraException( - "Cannot change execution options while " + - "executing the file ${currentFile?.path}." - ) - if (value.parallelExecution) - throw AraraException( - "This executor does not support " + - "parallel execution." - ) - field = value + if (currentFile != null) { + throw AraraException( + "Cannot change execution options while " + + "executing the file ${currentFile?.path}.", + ) } + if (value.parallelExecution) { + throw AraraException( + "This executor does not support " + + "parallel execution.", + ) + } + field = value + } /** * Execute rules based on the projects. Should roughly implement the @@ -71,8 +73,9 @@ object LinearExecutor : Executor { var exitCode = 0 for (project in projectsInOrder) { exitCode = executeProject(project) - if (executionOptions.haltOnErrors && exitCode != 0) + if (executionOptions.haltOnErrors && exitCode != 0) { break + } } val executionEnded = TimeSource.Monotonic.markNow() val executionReport = ExecutionReport(executionStarted, executionEnded, exitCode) @@ -88,8 +91,9 @@ object LinearExecutor : Executor { hooks.executeBeforeFile(file) val executionReport = execute(file) exitCode = executionReport.exitCode - if (executionOptions.haltOnErrors && exitCode != 0) + if (executionOptions.haltOnErrors && exitCode != 0) { return exitCode + } hooks.executeAfterFile(executionReport) } hooks.executeAfterProject(project) @@ -107,7 +111,7 @@ object LinearExecutor : Executor { val executionStarted = TimeSource.Monotonic.markNow() val directives = hooks.processDirectives( file, - file.fetchDirectives(executionOptions.parseOnlyHeader) + file.fetchDirectives(executionOptions.parseOnlyHeader), ) var exitCode = 0 for (directive in directives) { @@ -118,7 +122,9 @@ object LinearExecutor : Executor { } currentFile = null return ExecutionReport( - executionStarted, TimeSource.Monotonic.markNow(), exitCode + executionStarted, + TimeSource.Monotonic.markNow(), + exitCode, ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Session.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Session.kt index c9dd2b6ad..090e1004d 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Session.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/session/Session.kt @@ -51,7 +51,7 @@ object Session : Session { } else { throw AraraException( LanguageController.messages.ERROR_SESSION_OBTAIN_UNKNOWN_KEY - .formatString(key) + .formatString(key), ) } } @@ -82,7 +82,7 @@ object Session : Session { } else { throw AraraException( LanguageController.messages.ERROR_SESSION_REMOVE_UNKNOWN_KEY - .formatString(key) + .formatString(key), ) } } @@ -113,7 +113,7 @@ object Session : Session { */ fun updateEnvironmentVariables( additionFilter: (String) -> Boolean = { true }, - removalFilter: (String) -> Boolean = { true } + removalFilter: (String) -> Boolean = { true }, ) { // remove all current environment variables to clean up the session map.filterKeys { it.startsWith("environment:") } @@ -123,7 +123,7 @@ object Session : Session { map.putAll( Environment.getAll() .filterKeys(additionFilter) - .mapKeys { "environment:${it.key}" } + .mapKeys { "environment:${it.key}" }, ) } } diff --git a/core/src/commonMain/kotlin/org/islandoftex/arara/core/ui/InputHandling.kt b/core/src/commonMain/kotlin/org/islandoftex/arara/core/ui/InputHandling.kt index 07e674d41..479736bba 100644 --- a/core/src/commonMain/kotlin/org/islandoftex/arara/core/ui/InputHandling.kt +++ b/core/src/commonMain/kotlin/org/islandoftex/arara/core/ui/InputHandling.kt @@ -24,7 +24,7 @@ object InputHandling { return if (!yes.union(no).contains(value.lowercase())) { throw AraraException( LanguageController.messages.ERROR_CHECKBOOLEAN_NOT_VALID_BOOLEAN - .formatString(value) + .formatString(value), ) } else { yes.contains(value.lowercase()) @@ -40,9 +40,10 @@ object InputHandling { // TODO: check nullity fun flatten(list: List<*>): List = list.flatMap { item -> - if (item is List<*>) + if (item is List<*>) { flatten(item) - else + } else { listOf(item as Any) + } } } diff --git a/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/GraphTest.kt b/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/GraphTest.kt index d2bb67c38..79fc82fc0 100644 --- a/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/GraphTest.kt +++ b/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/GraphTest.kt @@ -9,15 +9,18 @@ class GraphTest { fun shouldOperateCorrectlyOnEmptyList() { assertEquals(Graph().kahn(), emptyList()) } + @Test fun shouldOperateCorrectlyOnSingletonList() { assertEquals(Graph().apply { addVertex(1) }.kahn(), listOf(1)) } + @Test fun shouldBeEmptyOnCycles() { // TODO: is that the correct behavior we want to enforce? assertEquals(Graph().apply { addEdge(1, 1) }.kahn(), emptyList()) } + @Test fun shouldSortCorrectly() { assertEquals( @@ -28,7 +31,7 @@ class GraphTest { addEdge(4, 2) addEdge(3, 1) }.kahn(), - listOf(6, 4, 5, 3, 2, 1) + listOf(6, 4, 5, 3, 2, 1), ) } } diff --git a/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraphTest.kt b/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraphTest.kt index 67806279e..1235899ad 100644 --- a/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraphTest.kt +++ b/core/src/commonTest/kotlin/org/islandoftex/arara/core/dependencies/ProjectGraphTest.kt @@ -14,11 +14,11 @@ class ProjectGraphTest { addAll( listOf( Project("Test", MPPPath(""), setOf(), setOf("Test 2")), - Project("Test 2", MPPPath(""), setOf()) - ) + Project("Test 2", MPPPath(""), setOf()), + ), ) }.kahn().map { it.name }, - listOf("Test 2", "Test") + listOf("Test 2", "Test"), ) } } diff --git a/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileHandlingTest.kt b/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileHandlingTest.kt index 77978d1af..d561c7621 100644 --- a/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileHandlingTest.kt +++ b/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileHandlingTest.kt @@ -14,14 +14,15 @@ class FileHandlingTest { fun shouldChangeExtensionOfFileWithExtension() { assertEquals( MPPPath("quack.log").fileName, - FileHandling.changeExtension(MPPPath("quack.tex"), "log").fileName + FileHandling.changeExtension(MPPPath("quack.tex"), "log").fileName, ) } + @Test fun shouldChangeExtensionOfFileWithoutExtension() { assertEquals( MPPPath("quack.log").fileName, - FileHandling.changeExtension(MPPPath("quack"), "log").fileName + FileHandling.changeExtension(MPPPath("quack"), "log").fileName, ) } @@ -30,6 +31,7 @@ class FileHandlingTest { assertTrue(FileHandling.isSubDirectory(MPPPath("../docs"), MPPPath(".."))) assertFalse(FileHandling.isSubDirectory(MPPPath(".."), MPPPath("../docs"))) } + @Test fun shouldNotTreatFilesAsSubdirectories() { assertFalse(FileHandling.isSubDirectory(MPPPath("../LICENSE"), MPPPath(".."))) @@ -42,6 +44,7 @@ class FileHandlingTest { FileHandling.calculateHash(MPPPath("QUACK")) } } + @Test fun shouldGenerateCorrectCRCSum() { assertEquals(1616727774, FileHandling.calculateHash(MPPPath("../LICENSE"))) diff --git a/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileTypeTest.kt b/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileTypeTest.kt index b119d0a9c..dec6a3bd3 100644 --- a/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileTypeTest.kt +++ b/core/src/commonTest/kotlin/org/islandoftex/arara/core/files/FileTypeTest.kt @@ -13,11 +13,13 @@ class FileTypeTest { assertEquals(FileType("test", "^\\s*"), FileType("test", "^\\s*%\\s+")) assertEquals(FileType("test", "^\\s*%\\s+"), FileType("test", "^\\s*%\\s+")) } + @Test fun shouldOnlyDependOnExtensionForInequality() { assertNotEquals(FileType("test", "^\\s*"), FileType("tes", "^\\s*%\\s+")) assertNotEquals(FileType("test", "^\\s*%\\s+"), FileType("tes", "^\\s*%\\s+")) } + @Test fun shouldExpectValidPattern() { assertFailsWith { diff --git a/core/src/commonTest/kotlin/org/islandoftex/arara/core/localization/LanguageControllerTest.kt b/core/src/commonTest/kotlin/org/islandoftex/arara/core/localization/LanguageControllerTest.kt index 2b30b7bf2..c2a824038 100644 --- a/core/src/commonTest/kotlin/org/islandoftex/arara/core/localization/LanguageControllerTest.kt +++ b/core/src/commonTest/kotlin/org/islandoftex/arara/core/localization/LanguageControllerTest.kt @@ -15,7 +15,7 @@ class LanguageControllerTest { MPPLocale("it"), MPPLocale("nl"), MPPLocale("en-QN"), - MPPLocale("pt-BR") + MPPLocale("pt-BR"), ).forEach { LanguageController.loadMessagesFor(it) assertEquals(LanguageController.messages.providedLocale, it) diff --git a/core/src/commonTest/kotlin/org/islandoftex/arara/core/session/SessionTest.kt b/core/src/commonTest/kotlin/org/islandoftex/arara/core/session/SessionTest.kt index ea6309339..30787bb92 100644 --- a/core/src/commonTest/kotlin/org/islandoftex/arara/core/session/SessionTest.kt +++ b/core/src/commonTest/kotlin/org/islandoftex/arara/core/session/SessionTest.kt @@ -16,7 +16,7 @@ class SessionTest { // on Linux it is called PATH, on Windows it may be Path assertTrue( Session.contains("environment:PATH") || - Session.contains("environment:Path") + Session.contains("environment:Path"), ) } @@ -78,6 +78,7 @@ class SessionTest { assertTrue(false) } } + @Test fun shouldThrowOnUnknownRemoval() { Session.clear() diff --git a/core/src/commonTest/kotlin/org/islandoftex/arara/core/ui/InputHandlingTest.kt b/core/src/commonTest/kotlin/org/islandoftex/arara/core/ui/InputHandlingTest.kt index 6e8c11d31..082e2366a 100644 --- a/core/src/commonTest/kotlin/org/islandoftex/arara/core/ui/InputHandlingTest.kt +++ b/core/src/commonTest/kotlin/org/islandoftex/arara/core/ui/InputHandlingTest.kt @@ -13,27 +13,29 @@ class InputHandlingTest { fun shouldReturnTruthyValuesForCommonTruthyInput() { listOf( "yes", "true", "1", "on", "Yes", "True", "On", "YES", "TRUE", - "ON", "YeS", "yEs", "TrUe", "oN" + "ON", "YeS", "yEs", "TrUe", "oN", ).forEach { assertTrue(InputHandling.checkBoolean(it)) } } + @Test fun shouldReturnFalsyValuesForCommonFalsyInput() { listOf( "no", "false", "0", "off", "No", "False", "Off", "NO", "FALSE", - "OFF", "nO", "oFf", "fAlsE" + "OFF", "nO", "oFf", "fAlsE", ).forEach { assertFalse(InputHandling.checkBoolean(it)) } } + @Test fun shouldThrowOnAmbiguousBooleanInput() { listOf("quack", "duck", "yess", "yyes", "noo", "nno").forEach { assertTrue( assertFailsWith { InputHandling.checkBoolean(it) - }.message?.contains("not a valid boolean") == true + }.message?.contains("not a valid boolean") == true, ) } } @@ -43,7 +45,7 @@ class InputHandlingTest { assertEquals( InputHandling.flatten(listOf(1, 2, listOf(3, 4, listOf(5, 6)))) .toSet(), - (setOf(1, 2, 3, 4, 5, 6) as Set) + (setOf(1, 2, 3, 4, 5, 6) as Set), ) } } diff --git a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/configuration/ConfigurationUtils.kt b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/configuration/ConfigurationUtils.kt index 7cd2677a1..9ee1b6f66 100644 --- a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/configuration/ConfigurationUtils.kt +++ b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/configuration/ConfigurationUtils.kt @@ -14,7 +14,7 @@ actual object ConfigurationUtils { "dtx" to "^\\s*%\\s*", "ltx" to "^\\s*%\\s*", "drv" to "^\\s*%\\s*", - "ins" to "^\\s*%\\s*" + "ins" to "^\\s*%\\s*", ) @JvmStatic @@ -47,7 +47,7 @@ actual object ConfigurationUtils { }.getOrElse { throw AraraException( LanguageController.messages.ERROR_GETAPPLICATIONPATH_ENCODING_EXCEPTION, - it + it, ) } } diff --git a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/ClassLoading.kt b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/ClassLoading.kt index d684c2c06..4f5ec996f 100644 --- a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/ClassLoading.kt +++ b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/ClassLoading.kt @@ -24,7 +24,7 @@ object ClassLoading { MALFORMED_URL, CLASS_NOT_FOUND, ILLEGAL_ACCESS, - INSTANTIATION_EXCEPTION + INSTANTIATION_EXCEPTION, } /** @@ -34,8 +34,7 @@ object ClassLoading { * @return A pair representing the status and the class. */ @JvmStatic - fun loadClass(path: MPPPath, name: String): - Pair> { + fun loadClass(path: MPPPath, name: String): Pair> { val file = path.toJVMFile() // status and class to be returned, @@ -57,7 +56,7 @@ object ClassLoading { // a JAR file) val classloader = URLClassLoader( arrayOf(file.toURI().toURL()), - ClassLoading::class.java.classLoader + ClassLoading::class.java.classLoader, ) // fetches the class from the diff --git a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/Environment.kt b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/Environment.kt index cce414dc5..fabf58e05 100644 --- a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/Environment.kt +++ b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/session/Environment.kt @@ -65,7 +65,7 @@ object Environment { executeSystemCommand( // execute the Cygwin detection; we do not specify a working // directory because for the test it is irrelevant - Command(listOf("uname", "-s")) + Command(listOf("uname", "-s")), ).second.lowercase().startsWith("cygwin") } @@ -78,7 +78,7 @@ object Environment { LINUX, MACOS, UNIX, - CYGWIN + CYGWIN, } /** @@ -203,7 +203,7 @@ object Environment { fun executeSystemCommand( command: Command, silenceSystemOut: Boolean = true, - timeout: Duration = Duration.ZERO + timeout: Duration = Duration.ZERO, ): Pair = ByteArrayOutputStream().use { buffer -> ProcessExecutor(command.elements).runCatching { addDestroyer(ShutdownHookProcessDestroyer()) diff --git a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/ui/GUIDialogs.kt b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/ui/GUIDialogs.kt index 29fe71a80..86316621a 100644 --- a/core/src/jvmMain/kotlin/org/islandoftex/arara/core/ui/GUIDialogs.kt +++ b/core/src/jvmMain/kotlin/org/islandoftex/arara/core/ui/GUIDialogs.kt @@ -18,7 +18,7 @@ class GUIDialogs /** * The default width for the message body, in pixels. */ - val defaultWidth: Int = 250 + val defaultWidth: Int = 250, ) { init { applyUIOptions(uiOptions) @@ -93,17 +93,17 @@ class GUIDialogs width: Int = defaultWidth, type: Int, title: String, - text: String + text: String, ) { // effectively shows the message based // on the provided parameters JOptionPane.showMessageDialog( null, "$text".format( - normalizeMessageWidth(width) + normalizeMessageWidth(width), ), title, - normalizeIconType(type) + normalizeIconType(type), ) } @@ -122,20 +122,20 @@ class GUIDialogs type: Int, title: String, text: String, - buttons: Array + buttons: Array, ): Int { // returns the index of the selected button, // zero if nothing is selected return JOptionPane.showOptionDialog( null, "$text".format( - normalizeMessageWidth(width) + normalizeMessageWidth(width), ), title, JOptionPane.DEFAULT_OPTION, normalizeIconType(type), null, buttons, - buttons[0] + buttons[0], ) + 1 } @@ -152,17 +152,17 @@ class GUIDialogs width: Int = defaultWidth, type: Int, title: String, - text: String + text: String, ): String { // get the string from the // input text, if any val input = JOptionPane.showInputDialog( null, "$text".format( - normalizeMessageWidth(width) + normalizeMessageWidth(width), ), title, - normalizeIconType(type) + normalizeIconType(type), ) // if the input is not null, that is, @@ -187,18 +187,19 @@ class GUIDialogs type: Int, title: String, text: String, - elements: Array + elements: Array, ): Int { // show the dropdown list and get the selected object, if any val index = JOptionPane.showInputDialog( null, "$text".format( - normalizeMessageWidth(width) + normalizeMessageWidth(width), ), title, - normalizeIconType(type), null, + normalizeIconType(type), + null, elements, - elements[0] + elements[0], ) // if it's not a null object, let's find the corresponding index diff --git a/core/src/jvmTest/kotlin/org/islandoftex/arara/core/files/FileSearchingTest.kt b/core/src/jvmTest/kotlin/org/islandoftex/arara/core/files/FileSearchingTest.kt index fabb23b93..c2a50f638 100644 --- a/core/src/jvmTest/kotlin/org/islandoftex/arara/core/files/FileSearchingTest.kt +++ b/core/src/jvmTest/kotlin/org/islandoftex/arara/core/files/FileSearchingTest.kt @@ -33,12 +33,12 @@ class FileSearchingTest : ShouldSpec({ val tempDir = prepareFileSystem().toMPPPath() FileSearching.listFilesByExtensions( tempDir, - listOf("tex"), false + listOf("tex"), false, ).toSet() shouldBe setOf(tempDir / "quack.tex") FileSearching.listFilesByExtensions( tempDir, - listOf("tex"), true + listOf("tex"), true, ).toSet() shouldBe listOf("quack", "quack/quack", "quack/quack/quack") .map { tempDir / "$it.tex" }.toSet() @@ -48,12 +48,12 @@ class FileSearchingTest : ShouldSpec({ val tempDir = prepareFileSystem().toMPPPath() FileSearching.listFilesByPatterns( tempDir, - listOf("*q*.txt"), false + listOf("*q*.txt"), false, ).toSet() shouldBe setOf(tempDir / "quack.txt") FileSearching.listFilesByPatterns( tempDir, - listOf("q*.txt"), true + listOf("q*.txt"), true, ).toSet() shouldBe listOf("quack", "quack/quack", "quack/quack/quack") .map { tempDir / "$it.txt" }.toSet() @@ -64,14 +64,14 @@ class FileSearchingTest : ShouldSpec({ should("fail looking up inexistent file") { FileSearching.lookupFile( "QUACK", MPPPath("."), - ExecutionOptions() + ExecutionOptions(), ) shouldBe null } should("fail on existing directory") { FileSearching.lookupFile( "../buildSrc", MPPPath("."), - ExecutionOptions() + ExecutionOptions(), ) shouldBe null } @@ -84,7 +84,7 @@ class FileSearchingTest : ShouldSpec({ val projectFile = FileSearching.lookupFile( pathToTest.toString(), testDir.toMPPPath(), - ExecutionOptions() + ExecutionOptions(), ) as ProjectFile projectFile.path.normalize().toString() shouldBe pathToTest.normalize().toString() @@ -101,7 +101,7 @@ class FileSearchingTest : ShouldSpec({ val projectFile = FileSearching.lookupFile( (parent / "changes").toString(), testDir.toMPPPath(), - ExecutionOptions() + ExecutionOptions(), ) as ProjectFile projectFile.path.normalize().toString() shouldBe (parent.normalize() / "changes.tex").toString() @@ -119,7 +119,7 @@ class FileSearchingTest : ShouldSpec({ val projectFile = FileSearching.lookupFile( pathToTest.toString(), testDir.toMPPPath(), - ExecutionOptions().copy(executionMode = ExecutionMode.SAFE_RUN) + ExecutionOptions().copy(executionMode = ExecutionMode.SAFE_RUN), ) as ProjectFile projectFile.path.normalize().toString() shouldBe pathToTest.normalize().toString() @@ -132,7 +132,7 @@ class FileSearchingTest : ShouldSpec({ FileSearching.lookupFile( MPPPath("src/test/resources/executiontests/changes/changes").toString(), MPPPath("."), - ExecutionOptions().copy(executionMode = ExecutionMode.SAFE_RUN) + ExecutionOptions().copy(executionMode = ExecutionMode.SAFE_RUN), ) shouldBe null } } diff --git a/core/src/jvmTest/kotlin/org/islandoftex/arara/core/session/EnvironmentTest.kt b/core/src/jvmTest/kotlin/org/islandoftex/arara/core/session/EnvironmentTest.kt index 1063bcc3f..256a7d9d2 100644 --- a/core/src/jvmTest/kotlin/org/islandoftex/arara/core/session/EnvironmentTest.kt +++ b/core/src/jvmTest/kotlin/org/islandoftex/arara/core/session/EnvironmentTest.kt @@ -46,7 +46,9 @@ class EnvironmentTest : ShouldSpec({ } should("error with timeout exception") { val (exit, output) = Environment.executeSystemCommand( - Command(listOf("sleep", "1s")), true, Duration.milliseconds(500) + Command(listOf("sleep", "1s")), + true, + Duration.milliseconds(500), ) exit shouldBe Environment.errorExitStatus output shouldContain TimeoutException::class.java.name diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a4..ccebba771 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fcea..4e86b9270 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c78733..79a61d421 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32c..6689b85be 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/kotlin-dsl/build.gradle.kts b/kotlin-dsl/build.gradle.kts index da1964fa6..16e455a49 100644 --- a/kotlin-dsl/build.gradle.kts +++ b/kotlin-dsl/build.gradle.kts @@ -15,7 +15,7 @@ kotlin { api(kotlin("scripting-jvm-host")) implementation(project(":core")) - implementation(kotlin("script-util")) +// implementation(kotlin("script-util")) runtimeOnly(kotlin("compiler-embeddable")) runtimeOnly(kotlin("scripting-dependencies")) diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/Executor.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/Executor.kt index c7aa8a5b6..b49687df1 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/Executor.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/Executor.kt @@ -27,7 +27,7 @@ object Executor { val path = URLDecoder.decode( Executor::class.java.protectionDomain .codeSource.location.path, - "UTF-8" + "UTF-8", ) val scriptSource = Paths.get(File(path).toURI()).parent.toAbsolutePath() .resolve("../../../../src/jvmTest/resources/org/islandoftex/arara/dsl/samples/project.kts") @@ -36,7 +36,7 @@ object Executor { BasicJvmScriptingHost().eval( scriptSource, AraraScriptCompilationConfiguration(), - AraraScriptEvaluationConfiguration() + AraraScriptEvaluationConfiguration(), ).valueOrThrow() println(DSLInstance.projects.size) diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/files/ProjectFile.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/files/ProjectFile.kt index e5da22d0e..681bc1400 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/files/ProjectFile.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/files/ProjectFile.kt @@ -15,7 +15,7 @@ import java.nio.file.Path internal class ProjectFile( path: Path, fileType: FileType, - priority: Int = DEFAULT_PRIORITY + priority: Int = DEFAULT_PRIORITY, ) : ProjectFile(path.toMPPPath(), fileType, priority) { /** * The directives to be used instead of fetching them from file. Used diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLInstance.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLInstance.kt index 1611b8f83..053744edd 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLInstance.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLInstance.kt @@ -49,7 +49,7 @@ object DSLInstance { label: String? = null, description: String = "", authors: List = listOf(), - configure: DSLRule.() -> Unit + configure: DSLRule.() -> Unit, ): Rule = DSLRule(id, label, description, authors) .apply(configure).toRule().also { rules.add(it) } } diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLProject.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLProject.kt index 5897315d5..7b42b0d13 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLProject.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLProject.kt @@ -38,7 +38,7 @@ class DSLProject(private val name: String) { fun file(name: String, configure: DSLProjectFile.() -> Unit = {}) = files.add( DSLProjectFile(Paths.get(name)) - .apply(configure).toProjectFile() + .apply(configure).toProjectFile(), ) /** @@ -63,7 +63,7 @@ class DSLProject(private val name: String) { fun file(file: File, configure: DSLProjectFile.() -> Unit) = files.add( DSLProjectFile(file.toPath()) - .apply(configure).toProjectFile() + .apply(configure).toProjectFile(), ) /** @@ -110,6 +110,9 @@ class DSLProject(private val name: String) { * @return A [Project] resembling the user's configuration. */ internal fun toProject(): Project = org.islandoftex.arara.core.files.Project( - name, workingDirectory, files, dependencyList + name, + workingDirectory, + files, + dependencyList, ) } diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRule.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRule.kt index 2f61757d1..81db88bcb 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRule.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRule.kt @@ -18,7 +18,7 @@ class DSLRule( private val id: String, private val label: String? = null, private val description: String = "", - private val authors: List = listOf() + private val authors: List = listOf(), ) { private val commands = mutableListOf() @@ -28,7 +28,7 @@ class DSLRule( @Deprecated( "This should not be used to fetch the arguments and " + "will be removed as soon as we found a way to remove the " + - "inline/reified classification of argument." + "inline/reified classification of argument.", ) val ruleArguments = mutableListOf>() @@ -53,20 +53,20 @@ class DSLRule( fun command( command: String, vararg parameters: String?, - workingDirectory: Path? = null + workingDirectory: Path? = null, ): Command = org.islandoftex.arara.core.session.Command( listOf(command) .plus(parameters.filterNotNull().filterNot { it.isBlank() }), - workingDirectory?.toMPPPath() + workingDirectory?.toMPPPath(), ).also { commands.add( org.islandoftex.arara.dsl.rules.RuleCommand(command) { Environment.executeSystemCommand( it, !LinearExecutor.executionOptions.verbose, - LinearExecutor.executionOptions.timeoutValue + LinearExecutor.executionOptions.timeoutValue, ).first - } + }, ) } @@ -78,7 +78,7 @@ class DSLRule( */ fun execute( name: String? = null, - executable: DSLExecutable.() -> Unit + executable: DSLExecutable.() -> Unit, ): RuleCommand { val dslExecutable = DSLExecutable() return org.islandoftex.arara.dsl.rules.RuleCommand(name) { @@ -96,13 +96,14 @@ class DSLRule( */ inline fun argument( identifier: String, - configure: DSLRuleArgument.() -> Unit + configure: DSLRuleArgument.() -> Unit, ): RuleArgument { - if (identifier in arguments) + if (identifier in arguments) { throw AraraException( "Two rule arguments can't have the same " + - "identifier." + "identifier.", ) + } return DSLRuleArgument(identifier).apply(configure) .toRuleArgument().also { ruleArguments.add(it) } } @@ -128,6 +129,6 @@ class DSLRule( displayName = label ?: description, authors = authors, commands = commands, - arguments = ruleArguments + arguments = ruleArguments, ) } diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRuleArgument.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRuleArgument.kt index d64c8e2c2..e5f7be343 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRuleArgument.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/language/DSLRuleArgument.kt @@ -35,10 +35,11 @@ class DSLRuleArgument(val identifier: String) { fun processor(fn: RuleMethods.(T) -> Any) { processor = { it, _ -> val result = fn(RuleMethods, it) - if (result is List<*>) + if (result is List<*>) { result.map { it.toString() } - else + } else { listOf(it.toString()) + } } } @@ -49,8 +50,10 @@ class DSLRuleArgument(val identifier: String) { */ fun toRuleArgument(): RuleArgument { return org.islandoftex.arara.dsl.rules.RuleArgument( - identifier, isRequired = required, defaultValue = defaultValue, - processor = processor + identifier, + isRequired = required, + defaultValue = defaultValue, + processor = processor, ) } } diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/Rule.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/Rule.kt index 1592448a8..e880cc8ac 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/Rule.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/Rule.kt @@ -10,5 +10,5 @@ data class Rule( override val displayName: String?, override val authors: List, override val commands: List, - override val arguments: List> + override val arguments: List>, ) : Rule diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleArgument.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleArgument.kt index 1f55587f2..d7b3598fa 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleArgument.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleArgument.kt @@ -7,5 +7,5 @@ data class RuleArgument( override val identifier: String, override val isRequired: Boolean, override val defaultValue: T?, - override val processor: (T, Map) -> List = { _, _ -> listOf() } + override val processor: (T, Map) -> List = { _, _ -> listOf() }, ) : RuleArgument diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleCommand.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleCommand.kt index 6579403e4..b5dda5d48 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleCommand.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/rules/RuleCommand.kt @@ -5,5 +5,5 @@ import org.islandoftex.arara.api.rules.RuleCommand data class RuleCommand( override val name: String?, - override val command: () -> Int + override val command: () -> Int, ) : RuleCommand diff --git a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/scripting/AraraScriptConfigurations.kt b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/scripting/AraraScriptConfigurations.kt index 0c61a9d3f..4d75312ab 100644 --- a/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/scripting/AraraScriptConfigurations.kt +++ b/kotlin-dsl/src/jvmMain/kotlin/org/islandoftex/arara/dsl/scripting/AraraScriptConfigurations.kt @@ -42,7 +42,7 @@ class AraraScriptCompilationConfiguration : ScriptCompilationConfiguration({ } else { dependenciesFromClassContext( AraraScriptCompilationConfiguration::class, - wholeClasspath = true + wholeClasspath = true, ) } } @@ -63,11 +63,11 @@ class AraraScriptCompilationConfiguration : ScriptCompilationConfiguration({ compilationCache( CompiledScriptJarsCache { script, compilationConfiguration -> it.resolve(compiledScriptUniqueName(script, compilationConfiguration) + ".jar") - } + }, ) } } - } + }, ) }) @@ -77,7 +77,7 @@ class AraraScriptEvaluationConfiguration : ScriptEvaluationConfiguration({ private fun compiledScriptUniqueName( script: SourceCode, - scriptCompilationConfiguration: ScriptCompilationConfiguration + scriptCompilationConfiguration: ScriptCompilationConfiguration, ): String { val digestWrapper = MessageDigest.getInstance("MD5") digestWrapper.update(script.text.toByteArray()) @@ -95,7 +95,9 @@ private fun ByteArray.toHexString(): String = joinToString("", transform = { "%0 internal fun URL.toContainingJarOrNull(): File? = if (protocol == "jar") { (openConnection() as? JarURLConnection)?.jarFileURL?.toFileOrNull() - } else null + } else { + null + } internal fun URL.toFileOrNull() = try { @@ -105,6 +107,9 @@ internal fun URL.toFileOrNull() = } catch (e: java.net.URISyntaxException) { null } ?: run { - if (protocol != "file") null - else File(file) + if (protocol != "file") { + null + } else { + File(file) + } } diff --git a/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaInterpreter.kt b/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaInterpreter.kt index cdec59f3d..fdc73f0c5 100644 --- a/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaInterpreter.kt +++ b/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaInterpreter.kt @@ -21,14 +21,14 @@ class LuaInterpreter(private val appWorkingDir: MPPPath) { private fun dumpLuaValue(value: LuaValue): String { return if (value is LuaTable) { "{${ - value.keys().joinToString(", ") { key -> - val k = if (key is LuaNumber) { - key.toString() - } else { - "\"${key}\"" + value.keys().joinToString(", ") { key -> + val k = if (key is LuaNumber) { + key.toString() + } else { + "\"${key}\"" + } + "[$k] = ${dumpLuaValue(value[key])}" } - "[$k] = ${dumpLuaValue(value[key])}" - } }} " } else { value.toString() @@ -98,7 +98,7 @@ class LuaInterpreter(private val appWorkingDir: MPPPath) { ?.let { fileSpec -> extractProjectFile( path, - fileSpec as LuaTable + fileSpec as LuaTable, ) } } @@ -142,7 +142,7 @@ class LuaInterpreter(private val appWorkingDir: MPPPath) { } ?: throw ProjectParseException( "The return type of the Lua project specification has to be a table " + - "(project or list of projects)." + "(project or list of projects).", ) // try extracting a single project from the Lua result and if that diff --git a/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaProjectFile.kt b/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaProjectFile.kt index eec9db505..53dc08d4e 100644 --- a/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaProjectFile.kt +++ b/lua/src/commonMain/kotlin/org/islandoftex/arara/lua/LuaProjectFile.kt @@ -14,7 +14,7 @@ import org.islandoftex.arara.core.rules.Directives internal class LuaProjectFile( path: MPPPath, fileType: FileType, - priority: Int = DEFAULT_PRIORITY + priority: Int = DEFAULT_PRIORITY, ) : ProjectFile(path, fileType, priority) { /** * The directives to be used instead of fetching them from file. Used diff --git a/mvel/src/commonMain/kotlin/org/islandoftex/arara/mvel/configuration/SerialFileType.kt b/mvel/src/commonMain/kotlin/org/islandoftex/arara/mvel/configuration/SerialFileType.kt index 22c501a05..3aa64d1c2 100644 --- a/mvel/src/commonMain/kotlin/org/islandoftex/arara/mvel/configuration/SerialFileType.kt +++ b/mvel/src/commonMain/kotlin/org/islandoftex/arara/mvel/configuration/SerialFileType.kt @@ -19,7 +19,7 @@ import org.islandoftex.arara.core.utils.formatString @Serializable data class SerialFileType( private var extension: String = FileType.INVALID_EXTENSION, - private var pattern: String = FileType.INVALID_PATTERN + private var pattern: String = FileType.INVALID_PATTERN, ) { /** @@ -38,8 +38,8 @@ data class SerialFileType( .formatString( extension, LinearExecutor.executionOptions.fileTypes - .joinToString(" | ", "[ ", " ]") - ) - ) + .joinToString(" | ", "[ ", " ]"), + ), + ), ) } diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/configuration/LocalConfiguration.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/configuration/LocalConfiguration.kt index 218668ad8..dce85d485 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/configuration/LocalConfiguration.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/configuration/LocalConfiguration.kt @@ -35,7 +35,7 @@ data class LocalConfiguration( private val laf: String? = null, val preambles: Map = mapOf(), val defaultPreamble: String? = null, - val prependPreambleIfDirectivesGiven: Boolean = true + val prependPreambleIfDirectivesGiven: Boolean = true, ) { /** * Convert the relevant properties of the configuration to execution @@ -47,30 +47,31 @@ data class LocalConfiguration( @Throws(AraraException::class) fun toExecutionOptions( currentProject: Project, - baseOptions: ExecutionOptions = org.islandoftex.arara.core.configuration.ExecutionOptions() + baseOptions: ExecutionOptions = org.islandoftex.arara.core.configuration.ExecutionOptions(), ): ExecutionOptions { val preprocessedPaths = paths.asSequence() .map { it.trim() } .map { input -> input.replace( "@{user.home}", - Environment.getSystemPropertyOrNull("user.home") ?: "" + Environment.getSystemPropertyOrNull("user.home") ?: "", ) .replace( "@{user.name}", - Environment.getSystemPropertyOrNull("user.name") ?: "" + Environment.getSystemPropertyOrNull("user.name") ?: "", ) .replace( "@{application.workingDirectory}", - currentProject.workingDirectory.normalize().toString() + currentProject.workingDirectory.normalize().toString(), ) } .map { MPPPath(it) } .map { path -> - if (path.isAbsolute) + if (path.isAbsolute) { path - else + } else { currentProject.workingDirectory / path + } } .map { it.normalize() } .toSet() @@ -81,7 +82,7 @@ data class LocalConfiguration( loops } else { throw AraraException( - LanguageController.messages.ERROR_CONFIGURATION_LOOPS_INVALID_RANGE + LanguageController.messages.ERROR_CONFIGURATION_LOOPS_INVALID_RANGE, ) } } ?: baseOptions.maxLoops @@ -96,7 +97,7 @@ data class LocalConfiguration( .plus(baseOptions.fileTypes), rulePaths = preprocessedPaths .plus(baseOptions.rulePaths), - parseOnlyHeader = header ?: baseOptions.parseOnlyHeader + parseOnlyHeader = header ?: baseOptions.parseOnlyHeader, ) } @@ -108,13 +109,13 @@ data class LocalConfiguration( * @return The corresponding logging options. */ fun toLoggingOptions( - baseOptions: LoggingOptions = org.islandoftex.arara.core.configuration.LoggingOptions() + baseOptions: LoggingOptions = org.islandoftex.arara.core.configuration.LoggingOptions(), ): LoggingOptions { val logName = logname?.let { MPPPath(it) } ?: baseOptions.logFile return org.islandoftex.arara.core.configuration.LoggingOptions( enableLogging = logging ?: baseOptions.enableLogging, - logFile = logName + logFile = logName, ) } @@ -126,12 +127,12 @@ data class LocalConfiguration( * @return The corresponding user interface options. */ fun toUserInterfaceOptions( - baseOptions: UserInterfaceOptions = org.islandoftex.arara.core.configuration.UserInterfaceOptions() + baseOptions: UserInterfaceOptions = org.islandoftex.arara.core.configuration.UserInterfaceOptions(), ): UserInterfaceOptions { return org.islandoftex.arara.core.configuration.UserInterfaceOptions( locale = language?.let { MPPLocale(it) } ?: baseOptions.locale, - swingLookAndFeel = laf ?: baseOptions.swingLookAndFeel + swingLookAndFeel = laf ?: baseOptions.swingLookAndFeel, ) } @@ -148,13 +149,14 @@ data class LocalConfiguration( fun load(file: MPPPath): LocalConfiguration = file.runCatching { val text = file.readText() - if (!text.startsWith("!config")) + if (!text.startsWith("!config")) { throw AraraException("Configuration should start with !config") + } Yaml.default.decodeFromString(serializer(), text) }.getOrElse { throw AraraException( LanguageController.messages.ERROR_CONFIGURATION_GENERIC_ERROR, - it + it, ) } } diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/DirectiveConditionalEvaluator.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/DirectiveConditionalEvaluator.kt index dcbd5d204..82043b093 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/DirectiveConditionalEvaluator.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/DirectiveConditionalEvaluator.kt @@ -32,24 +32,25 @@ class DirectiveConditionalEvaluator(executionOptions: ExecutionOptions) : try { val result = TemplateRuntime.eval( "@{ ${conditional.condition} }", - MvelState.conditionalMethods + MvelState.conditionalMethods, ) return if (result is Boolean) { if (conditional.type == DirectiveConditionalType.UNLESS || conditional.type == DirectiveConditionalType.UNTIL - ) + ) { !result - else + } else { result + } } else { throw AraraException( - LanguageController.messages.ERROR_EVALUATE_NOT_BOOLEAN_VALUE + LanguageController.messages.ERROR_EVALUATE_NOT_BOOLEAN_VALUE, ) } } catch (exception: RuntimeException) { throw AraraException( LanguageController.messages.ERROR_EVALUATE_COMPILATION_FAILED, - exception + exception, ) } } diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/Rule.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/Rule.kt index 6dcf3811b..008b032a7 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/Rule.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/Rule.kt @@ -23,7 +23,7 @@ data class Rule( override val displayName: String? = null, override val authors: List = emptyList(), override val commands: List = emptyList(), - override val arguments: List = emptyList() + override val arguments: List = emptyList(), ) : Rule { companion object { private var ruleId: String? = null @@ -59,16 +59,18 @@ data class Rule( rulePath = file.normalize().toString() val rule = file.runCatching { val text = readText() - if (!text.startsWith("!config")) + if (!text.startsWith("!config")) { throw AraraException("Rule should start with !config") + } Yaml.default.decodeFromString( - org.islandoftex.arara.mvel.rules.Rule.serializer(), text + org.islandoftex.arara.mvel.rules.Rule.serializer(), + text, ) }.getOrElse { throw AraraException( ruleErrorHeader + LanguageController .messages.ERROR_PARSERULE_GENERIC_ERROR, - it + it, ) } @@ -92,13 +94,13 @@ data class Rule( throw AraraException( ruleErrorHeader + LanguageController.messages.ERROR_VALIDATEHEADER_WRONG_IDENTIFIER - .format(rule.identifier, identifier) + .format(rule.identifier, identifier), ) } if (rule.displayName == null) { throw AraraException( ruleErrorHeader + LanguageController - .messages.ERROR_VALIDATEHEADER_NULL_NAME + .messages.ERROR_VALIDATEHEADER_NULL_NAME, ) } } @@ -113,11 +115,12 @@ data class Rule( @Throws(AraraException::class) @Suppress("ThrowsCount") private fun validateBody(rule: org.islandoftex.arara.mvel.rules.Rule) { - if (rule.commands.any { it.commandString == null }) + if (rule.commands.any { it.commandString == null }) { throw AraraException( ruleErrorHeader + LanguageController - .messages.ERROR_VALIDATEBODY_NULL_COMMAND + .messages.ERROR_VALIDATEBODY_NULL_COMMAND, ) + } val arguments = rule.arguments.filter { it.validate(ruleErrorHeader) } @@ -125,14 +128,14 @@ data class Rule( throw AraraException( ruleErrorHeader + LanguageController .messages.ERROR_VALIDATEBODY_ARGUMENT_ID_IS_RESERVED - .format(it) + .format(it), ) } if (arguments.size != arguments.toSet().size) { throw AraraException( ruleErrorHeader + LanguageController.messages - .ERROR_VALIDATEBODY_DUPLICATE_ARGUMENT_IDENTIFIERS + .ERROR_VALIDATEBODY_DUPLICATE_ARGUMENT_IDENTIFIERS, ) } } diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/RuleArgument.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/RuleArgument.kt index 9b7a78472..eac606c19 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/RuleArgument.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/rules/RuleArgument.kt @@ -45,7 +45,7 @@ class RuleArgument : RuleArgument { context .getValue("parameters") as Map<*, *> ) - .plus(identifier to input!!) + .plus(identifier to input!!), ) flag?.let { fn -> when (val output = TemplateRuntime.eval(fn, resolvedContext)) { @@ -55,7 +55,7 @@ class RuleArgument : RuleArgument { logger.warn( "You are using an unsupported return type " + "which may be deprecated in future versions of " + - "arara. Please use String or List instead." + "arara. Please use String or List instead.", ) listOf(output.toString()) } @@ -65,7 +65,7 @@ class RuleArgument : RuleArgument { throw AraraExceptionWithHeader( LanguageController.messages .ERROR_INTERPRETER_FLAG_RUNTIME_EXCEPTION, - exception + exception, ) } } @@ -79,13 +79,13 @@ class RuleArgument : RuleArgument { } else { throw AraraException( ruleErrorHeader + LanguageController - .messages.ERROR_VALIDATEBODY_MISSING_KEYS + .messages.ERROR_VALIDATEBODY_MISSING_KEYS, ) } } else { throw AraraException( ruleErrorHeader + LanguageController - .messages.ERROR_VALIDATEBODY_NULL_ARGUMENT_ID + .messages.ERROR_VALIDATEBODY_NULL_ARGUMENT_ID, ) } diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/ConditionalMethods.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/ConditionalMethods.kt index 60dd6528a..9c904b777 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/ConditionalMethods.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/ConditionalMethods.kt @@ -26,7 +26,8 @@ object ConditionalMethods { @JvmStatic @Throws(AraraException::class) fun exists(extension: String): Boolean = FileHandling.changeExtension( - LinearExecutor.currentFile!!.path, extension + LinearExecutor.currentFile!!.path, + extension, ).exists /** @@ -53,8 +54,9 @@ object ConditionalMethods { @Throws(AraraException::class) fun changed(extension: String): Boolean = changed( FileHandling.changeExtension( - LinearExecutor.currentFile!!.path, extension - ) + LinearExecutor.currentFile!!.path, + extension, + ), ) /** @@ -100,7 +102,7 @@ object ConditionalMethods { fun changed(filename: MPPPath): Boolean = FileHandling.hasChanged( filename, LinearExecutor.currentProject!!.workingDirectory / - LinearExecutor.executionOptions.databaseName + LinearExecutor.executionOptions.databaseName, ) /** @@ -128,9 +130,10 @@ object ConditionalMethods { @Throws(AraraException::class) fun found(extension: String, regex: String): Boolean = found( FileHandling.changeExtension( - LinearExecutor.currentFile!!.path, extension + LinearExecutor.currentFile!!.path, + extension, ), - regex + regex, ) /** @@ -173,7 +176,7 @@ object ConditionalMethods { type: Int, title: String, text: String, - vararg buttons: Any + vararg buttons: Any, ): Int = dialogs.showOptions(width, type, title, text, buttons) /** @@ -191,7 +194,7 @@ object ConditionalMethods { width: Int = dialogs.defaultWidth, type: Int, title: String, - text: String + text: String, ): String = dialogs.showInput(width, type, title, text) /** @@ -211,7 +214,7 @@ object ConditionalMethods { type: Int, title: String, text: String, - vararg elements: Any + vararg elements: Any, ): Int = dialogs.showDropdown(width, type, title, text, elements) /** diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MethodUtils.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MethodUtils.kt index 78cc3f043..fef76df4a 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MethodUtils.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MethodUtils.kt @@ -31,7 +31,7 @@ object MethodUtils { throw AraraException( LanguageController.messages.ERROR_CHECKREGEX_IO_EXCEPTION .format(file.fileName), - exception + exception, ) } } @@ -64,14 +64,14 @@ object MethodUtils { @Throws(AraraException::class) fun replicateList( pattern: String, - values: List + values: List, ): List { return try { values.map { pattern.format(it) } } catch (exception: MissingFormatArgumentException) { throw AraraException( LanguageController.messages.ERROR_REPLICATELIST_MISSING_FORMAT_ARGUMENTS_EXCEPTION, - exception + exception, ) } } diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MvelState.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MvelState.kt index 6c4e84302..1feb46d41 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MvelState.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/MvelState.kt @@ -28,7 +28,7 @@ object MvelState { "isEmpty", "isNotEmpty", "isTrue", "isFalse", "isWindows", "isLinux", "isMac", "isUnix", "isCygwin", "checkClass", "isString", "isList", "isMap", "isBoolean", - "getOrNull" + "getOrNull", ).forEach { name: String -> map[name] = methodsKotlin.first { it.name == name } } @@ -47,7 +47,7 @@ object MvelState { listOf( "exists", "missing", "changed", "unchanged", "found", "toFile", "showDropdown", "showInput", - "showOptions", "currentFile", "loadClass", "loadObject" + "showOptions", "currentFile", "loadClass", "loadObject", ).forEach { name: String -> map[name] = methodsKotlin.first { it.name == name } } diff --git a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/RuleMethods.kt b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/RuleMethods.kt index 45b87cba1..a5f1168ab 100644 --- a/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/RuleMethods.kt +++ b/mvel/src/jvmMain/kotlin/org/islandoftex/arara/mvel/utils/RuleMethods.kt @@ -82,7 +82,7 @@ object RuleMethods { } else { throw AraraExceptionWithHeader( LanguageController.messages - .ERROR_BASENAME_NOT_A_FILE.format(file.fileName) + .ERROR_BASENAME_NOT_A_FILE.format(file.fileName), ) } @@ -111,7 +111,7 @@ object RuleMethods { } else { throw AraraExceptionWithHeader( LanguageController.messages - .ERROR_FILETYPE_NOT_A_FILE.format(file.fileName) + .ERROR_FILETYPE_NOT_A_FILE.format(file.fileName), ) } @@ -191,7 +191,7 @@ object RuleMethods { fun getCommand(elements: List): Command = org.islandoftex.arara.core.session.Command( elements, - LinearExecutor.currentProject!!.workingDirectory + LinearExecutor.currentProject!!.workingDirectory, ) /** @@ -205,7 +205,7 @@ object RuleMethods { getCommand( InputHandling.flatten(elements.filterNotNull()) .map { it.toString() } - .filter { it.isNotEmpty() } + .filter { it.isNotEmpty() }, ) /** @@ -219,12 +219,12 @@ object RuleMethods { @JvmStatic fun getCommandWithWorkingDirectory( path: String, - vararg elements: Any? + vararg elements: Any?, ): Command = org.islandoftex.arara.core.session.Command( InputHandling.flatten(elements.filterNotNull()) .map { it.toString() } .filter { it.isNotEmpty() }, - MPPPath(path) + MPPPath(path), ) /** @@ -238,12 +238,12 @@ object RuleMethods { @JvmStatic fun getCommandWithWorkingDirectory( file: MPPPath, - vararg elements: Any? + vararg elements: Any?, ): Command = org.islandoftex.arara.core.session.Command( InputHandling.flatten(elements.filterNotNull()) .map { it.toString() } .filter { it.isNotEmpty() }, - file + file, ) /** @@ -257,9 +257,10 @@ object RuleMethods { @JvmStatic fun getCommandWithWorkingDirectory( path: String, - elements: List + elements: List, ): Command = org.islandoftex.arara.core.session.Command( - elements, MPPPath(path) + elements, + MPPPath(path), ) /** @@ -273,7 +274,7 @@ object RuleMethods { @JvmStatic fun getCommandWithWorkingDirectory( file: MPPPath, - elements: List + elements: List, ): Command = org.islandoftex.arara.core.session.Command(elements, file) /** @@ -298,7 +299,7 @@ object RuleMethods { width: Int = dialogs.defaultWidth, type: Int, title: String, - text: String + text: String, ) = dialogs.showMessage(width, type, title, text) /** @@ -312,13 +313,14 @@ object RuleMethods { */ @JvmStatic fun unsafelyExecuteSystemCommand(command: Command): Pair = - if (LinearExecutor.executionOptions.executionMode == ExecutionMode.SAFE_RUN) + if (LinearExecutor.executionOptions.executionMode == ExecutionMode.SAFE_RUN) { throw SafeRunViolationException( "In safe mode, rules are not allowed to execute " + - "arbitrary system commands within a step of execution." + "arbitrary system commands within a step of execution.", ) - else + } else { Environment.executeSystemCommand(command) + } /** * List all files from the provided directory according to the list of @@ -334,12 +336,12 @@ object RuleMethods { fun listFilesByExtensions( directory: MPPPath, extensions: List, - recursive: Boolean + recursive: Boolean, ): List = FileSearching.listFilesByExtensions( directory, extensions, - recursive + recursive, ) /** @@ -356,7 +358,7 @@ object RuleMethods { fun listFilesByExtensions( path: String, extensions: List, - recursive: Boolean + recursive: Boolean, ): List = listFilesByExtensions(MPPPath(path), extensions, recursive) @@ -373,12 +375,12 @@ object RuleMethods { fun listFilesByPatterns( directory: MPPPath, patterns: List, - recursive: Boolean + recursive: Boolean, ): List = FileSearching.listFilesByPatterns( directory, patterns, - recursive + recursive, ) /** @@ -394,7 +396,7 @@ object RuleMethods { fun listFilesByPatterns( path: String, patterns: List, - recursive: Boolean + recursive: Boolean, ): List = listFilesByPatterns(MPPPath(path), patterns, recursive) @@ -480,7 +482,7 @@ object RuleMethods { fun isSubdirectory(directory: MPPPath): Boolean = FileHandling.isSubDirectory( directory, - LinearExecutor.currentProject!!.workingDirectory + LinearExecutor.currentProject!!.workingDirectory, ) /**