Skip to content

Commit

Permalink
Update attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
cereda committed Sep 21, 2023
1 parent 4d2e3cf commit d5bfb04
Show file tree
Hide file tree
Showing 102 changed files with 744 additions and 617 deletions.
4 changes: 2 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand All @@ -67,7 +67,7 @@ tasks {
public actual val version: String = "${project.version}"
}
""".trimIndent()
""".trimIndent(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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!",
)
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ public enum class DirectiveConditionalType {
* result is true, and the process is repeated while the result still
* holds true.
*/
WHILE
WHILE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),
)
}

Expand All @@ -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(),
)
}
}
24 changes: 14 additions & 10 deletions api/src/jvmMain/kotlin/org/islandoftex/arara/api/files/MPPPath.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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() } ?: "/",
)

/**
Expand Down Expand Up @@ -170,10 +171,11 @@ public actual class MPPPath {
* impossible.
*/
public actual fun readLines(): List<String> = runBlockingNoJs {
if (isRegularFile)
if (isRegularFile) {
vfsFile.readLines().toList()
else
} else {
throw AraraIOException("Can only read lines from files.")
}
}

/**
Expand All @@ -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.")
}
}

/**
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
41 changes: 23 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)
}

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class AraraPublication : Plugin<Project> {
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")
Expand Down Expand Up @@ -89,9 +89,11 @@ open class AraraPublication : Plugin<Project> {
url.set("https://tex.stackexchange.com/users/344")
roles.set(
listOf(
"Developer", "Contributor", "Tester",
"Haskell fanatic"
)
"Developer",
"Contributor",
"Tester",
"Haskell fanatic",
),
)
}
developer {
Expand All @@ -101,9 +103,11 @@ open class AraraPublication : Plugin<Project> {
url.set("https://tex.stackexchange.com/users/19862")
roles.set(
listOf(
"Developer", "Contributor", "Tester",
"Hat enthusiast"
)
"Developer",
"Contributor",
"Tester",
"Hat enthusiast",
),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand All @@ -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")
Expand Down Expand Up @@ -92,8 +93,8 @@ open class CTANTreeBuilderTask : DefaultTask() {
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.OWNER_EXECUTE,
PosixFilePermission.GROUP_EXECUTE,
PosixFilePermission.OTHERS_EXECUTE
)
PosixFilePermission.OTHERS_EXECUTE,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Loading

0 comments on commit d5bfb04

Please sign in to comment.