aboutsummaryrefslogtreecommitdiff
path: root/build-logic/src/main/kotlin/org/jetbrains
diff options
context:
space:
mode:
authoraSemy <897017+aSemy@users.noreply.github.com>2023-03-22 16:37:37 +0100
committerGitHub <noreply@github.com>2023-03-22 16:37:37 +0100
commitb9e9962f75bfd6b19c16eccf7d4d6608b8f5db1e (patch)
treeb2161abc4ae5bc733f26bcd53f0dd2837cc5a893 /build-logic/src/main/kotlin/org/jetbrains
parentda7c48bee124fd5e3cf975bbf188c8e797f9bbbc (diff)
downloaddokka-b9e9962f75bfd6b19c16eccf7d4d6608b8f5db1e.tar.gz
dokka-b9e9962f75bfd6b19c16eccf7d4d6608b8f5db1e.tar.bz2
dokka-b9e9962f75bfd6b19c16eccf7d4d6608b8f5db1e.zip
Remove unnecessary Maven CLI setup tasks (#2930)
Diffstat (limited to 'build-logic/src/main/kotlin/org/jetbrains')
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt63
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/SetupMaven.kt45
2 files changed, 0 insertions, 108 deletions
diff --git a/build-logic/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt b/build-logic/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt
deleted file mode 100644
index 715dde2f..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.jetbrains
-
-import org.gradle.api.tasks.AbstractExecTask
-import org.gradle.internal.os.OperatingSystem
-import java.io.File
-import java.nio.file.Files
-import java.nio.file.Path
-import java.nio.file.Paths
-
-open class CrossPlatformExec : AbstractExecTask<CrossPlatformExec>(CrossPlatformExec::class.java) {
- private val windowsExtensions = listOf(".bat", ".cmd", ".exe")
- private val unixExtensions = listOf("", ".sh")
-
- private val isWindows = OperatingSystem.current().isWindows
-
- override fun exec() {
- val commandLine: MutableList<String> = this.commandLine
-
- if (commandLine.isNotEmpty()) {
- commandLine[0] = findCommand(commandLine[0])
- }
-
- if (isWindows && commandLine.isNotEmpty() && commandLine[0].isNotBlank()) {
- this.commandLine = listOf("cmd", "/c") + commandLine
- } else {
- this.commandLine = commandLine
- }
-
- super.exec()
- }
-
- private fun findCommand(command: String): String {
- val normalizedCommand = normalizeCommandPaths(command)
- val extensions = if (isWindows) windowsExtensions else unixExtensions
-
- return extensions.map { extension ->
- resolveCommandFromFile(Paths.get("$normalizedCommand$extension"))
- }.firstOrNull { it.isNotBlank() } ?: normalizedCommand
- }
-
- private fun resolveCommandFromFile(commandFile: Path) =
- if (!Files.isExecutable(commandFile)) {
- ""
- } else {
- commandFile.toAbsolutePath().normalize().toString()
- }
-
-
- private fun normalizeCommandPaths(command: String): String {
- // need to escape backslash so it works with regex
- val backslashSeparator = "\\"
- val forwardSlashSeparator = "/"
-
- // get the actual separator
- val separator = if (File.separatorChar == '\\') backslashSeparator else File.separator
-
- return command
- // first replace all of the backslashes with forward slashes
- .replace(backslashSeparator, forwardSlashSeparator)
- // then replace all forward slashes with whatever the separator actually is
- .replace(forwardSlashSeparator, separator)
- }
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/SetupMaven.kt b/build-logic/src/main/kotlin/org/jetbrains/SetupMaven.kt
deleted file mode 100644
index a1b59a50..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/SetupMaven.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.jetbrains
-
-import org.gradle.api.artifacts.Configuration
-import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.Internal
-import org.gradle.api.tasks.Sync
-import org.gradle.kotlin.dsl.creating
-import org.gradle.kotlin.dsl.dependencies
-import org.gradle.kotlin.dsl.getValue
-import java.io.File
-
-@Suppress("LeakingThis")
-open class SetupMaven : Sync() {
- @get:Input
- var mavenVersion = "3.5.0"
-
- @get:Input
- var mavenPluginToolsVersion = "3.5.2"
-
- @get:Internal
- val mavenBuildDir = "${project.buildDir}/maven"
-
- @get:Internal
- val mavenBinDir = "${project.buildDir}/maven-bin"
-
- @get:Internal
- val mvn = File(mavenBinDir, "apache-maven-$mavenVersion/bin/mvn")
-
- private val mavenBinaryConfiguration: Configuration by project.configurations.creating {
- project.dependencies {
- this@creating.invoke(
- group = "org.apache.maven",
- name = "apache-maven",
- version = mavenVersion,
- classifier = "bin", ext = "zip"
- )
- }
- }
-
- init {
- from(mavenBinaryConfiguration.map { file -> project.zipTree(file) })
- into(mavenBinDir)
- }
-
-}