From 95196f7c28f2784a2d2d9e5ac84b2e3ff64996fd Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Sat, 18 Mar 2023 13:15:58 +0100 Subject: [PATCH] remove old Maven CLI setup tasks --- .../kotlin/org/jetbrains/CrossPlatformExec.kt | 63 ------------------- .../main/kotlin/org/jetbrains/SetupMaven.kt | 45 ------------- 2 files changed, 108 deletions(-) delete mode 100644 build-logic/src/main/kotlin/org/jetbrains/CrossPlatformExec.kt delete mode 100644 build-logic/src/main/kotlin/org/jetbrains/SetupMaven.kt 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 715dde2faa..0000000000 --- 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::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 = 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 a1b59a50d5..0000000000 --- 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) - } - -}