Skip to content

Commit dcfb788

Browse files
authored
[maintenance] Remove dead code (#1472)
1 parent 5aafd49 commit dcfb788

File tree

11 files changed

+2
-437
lines changed

11 files changed

+2
-437
lines changed

src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/CompilationArgs.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ class CompilationArgs(
7878
return this
7979
}
8080

81-
fun given(
82-
test: Boolean,
83-
conditionalArgs: CompilationArgs.() -> Unit,
84-
): CompilationArgs {
85-
if (test) {
86-
this.conditionalArgs()
87-
}
88-
return this
89-
}
90-
9181
fun given(value: String): StringConditional = StringConditional(value, this)
9282

9383
operator fun plus(other: CompilationArgs): CompilationArgs =

src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolException.kt renamed to src/main/kotlin/io/bazel/kotlin/builder/toolchain/CompilationStatusException.kt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,8 @@
1515
*/
1616
package io.bazel.kotlin.builder.toolchain
1717

18-
sealed class KotlinToolException(
19-
msg: String,
20-
ex: Throwable? = null,
21-
) : RuntimeException(msg, ex)
22-
23-
class CompilationException(
24-
msg: String,
25-
cause: Throwable? = null,
26-
) : KotlinToolException(msg, cause)
27-
2818
class CompilationStatusException(
2919
msg: String,
3020
val status: Int,
3121
val lines: List<String> = emptyList(),
32-
) : KotlinToolException("$msg:${lines.joinToString("\n", "\n")}")
22+
) : RuntimeException("$msg:${lines.joinToString("\n", "\n")}")

src/main/kotlin/io/bazel/kotlin/builder/toolchain/CompilationTaskContext.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class CompilationTaskContext(
4646
isTracing = debugging.contains("trace")
4747
}
4848

49-
fun reportUnhandledException(throwable: Throwable) {
50-
throwable.printStackTrace(out)
51-
}
52-
5349
@Suppress("unused")
5450
fun print(msg: String) {
5551
out.println(msg)

src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ class KotlinToolchain private constructor(
7979
).toPath()
8080
}
8181

82-
private val KOTLIN_REFLECT by lazy {
83-
BazelRunFiles
84-
.resolveVerifiedFromProperty(
85-
"@rules_kotlin..kotlin.compiler.kotlin-reflect",
86-
).toPath()
87-
}
88-
8982
private val KOTLINX_SERIALIZATION_CORE_JVM by lazy {
9083
BazelRunFiles
9184
.resolveVerifiedFromProperty(
@@ -221,15 +214,6 @@ class KotlinToolchain private constructor(
221214
)
222215
}
223216

224-
fun toolchainWithReflect(kotlinReflect: File? = null): KotlinToolchain =
225-
KotlinToolchain(
226-
baseJars + listOf(kotlinReflect ?: KOTLIN_REFLECT.toFile()),
227-
kapt3Plugin,
228-
jvmAbiGen,
229-
skipCodeGen,
230-
jdepsGen,
231-
)
232-
233217
data class CompilerPlugin(
234218
val jarPath: String,
235219
val id: String,

src/main/kotlin/io/bazel/kotlin/builder/utils/IOUtils.kt

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,70 +18,11 @@
1818

1919
package io.bazel.kotlin.builder.utils
2020

21-
import java.io.BufferedReader
2221
import java.io.File
23-
import java.io.InterruptedIOException
24-
import java.io.PrintStream
2522
import java.nio.file.Files
2623
import java.nio.file.Path
2724
import java.nio.file.Paths
2825
import java.util.Arrays
29-
import java.util.concurrent.TimeUnit
30-
import java.util.concurrent.TimeoutException
31-
32-
private fun executeAwait(
33-
timeoutSeconds: Int,
34-
process: Process,
35-
): Int {
36-
try {
37-
if (!process.waitFor(timeoutSeconds.toLong(), TimeUnit.SECONDS)) {
38-
throw TimeoutException()
39-
}
40-
return process.exitValue()
41-
} finally {
42-
if (process.isAlive) {
43-
process.destroy()
44-
}
45-
}
46-
}
47-
48-
fun executeAndAwait(
49-
timeoutSeconds: Int,
50-
directory: File? = null,
51-
args: List<String>,
52-
): Int {
53-
val process =
54-
ProcessBuilder(*args.toTypedArray()).let { pb ->
55-
pb.redirectError(ProcessBuilder.Redirect.PIPE)
56-
pb.redirectOutput(ProcessBuilder.Redirect.PIPE)
57-
directory?.also { pb.directory(it) }
58-
pb.start()
59-
}
60-
61-
var isr: BufferedReader? = null
62-
var esr: BufferedReader? = null
63-
64-
try {
65-
isr = process.inputStream.bufferedReader()
66-
esr = process.errorStream.bufferedReader()
67-
return executeAwait(timeoutSeconds, process)
68-
} finally {
69-
isr?.drainTo(System.out)
70-
esr?.drainTo(System.err)
71-
}
72-
}
73-
74-
private fun BufferedReader.drainTo(pw: PrintStream) {
75-
lines().forEach(pw::println)
76-
close()
77-
}
78-
79-
fun Path.resolveTwinVerified(extension: String): Path =
80-
parent
81-
.resolve(
82-
"${toFile().nameWithoutExtension}${if (extension.startsWith(".")) "" else "."}$extension",
83-
).verified()
84-
.toPath()
8526

8627
fun Path.resolveNewDirectories(vararg parts: String) =
8728
Files.createDirectories(
@@ -91,9 +32,6 @@ fun Path.resolveNewDirectories(vararg parts: String) =
9132
fun Path.resolveVerified(vararg parts: String): File =
9233
resolve(Paths.get(parts[0], *Arrays.copyOfRange(parts, 1, parts.size))).verified()
9334

94-
fun Path.resolveVerifiedToAbsoluteString(vararg parts: String): String =
95-
resolveVerified(*parts).absolutePath.toString()
96-
9735
fun Path.verified(): File =
9836
this
9937
.toFile()
@@ -104,21 +42,3 @@ fun Path.verifiedPath(): Path =
10442
.toFile()
10543
.also { check(it.exists()) { "file did not exist: $this" } }
10644
.toPath()
107-
108-
val Throwable.rootCause: Throwable
109-
get() {
110-
var result = this
111-
do {
112-
val cause = result.cause
113-
if (cause != null) result = cause
114-
} while (cause != null && result != cause)
115-
return result
116-
}
117-
118-
fun Throwable.wasInterrupted(): Boolean {
119-
val cause = rootCause
120-
if (cause is InterruptedException || cause is InterruptedIOException) {
121-
return true
122-
}
123-
return false
124-
}

src/main/kotlin/io/bazel/kotlin/builder/utils/MiscUtils.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ package io.bazel.kotlin.builder.utils
1919
import java.util.function.Predicate
2020
import java.util.regex.Pattern
2121

22-
fun <T, C : MutableCollection<T>> C.addAll(vararg entries: T): C = this.also { addAll(entries) }
23-
24-
/**
25-
* Utility function to add multiple entries to a list with a leader.
26-
*/
27-
fun <T, C : MutableCollection<T>> C.addAll(
28-
leader: T,
29-
entries: List<T>,
30-
): C =
31-
this.also {
32-
add(leader)
33-
addAll(entries)
34-
}
35-
3622
private fun extensionMatcher(vararg ext: String): Predicate<String> =
3723
Pattern
3824
.compile("^(.+?)${ext.joinToString("|\\.", prefix = "(\\.", postfix = ")$")}")

src/main/kotlin/io/bazel/kotlin/builder/utils/TaskUtils.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
package io.bazel.kotlin.builder.utils
1717

1818
import io.bazel.kotlin.model.CompilationTaskInfo
19-
import io.bazel.kotlin.model.JvmCompilationTask
20-
import java.io.File
21-
22-
val JvmCompilationTask.Inputs.joinedClasspath: String
23-
get() =
24-
this.classpathList.joinToString(
25-
File.pathSeparator,
26-
)
2719

2820
val CompilationTaskInfo.bazelRuleKind: String
2921
get() = "kt_${platform.name.lowercase()}_${ruleKind.name.lowercase()}"

0 commit comments

Comments
 (0)