Skip to content

Commit bfdc9a9

Browse files
committed
Remove kotlinCompilerDep and kotlinScriptingCompilerDep tasks
1 parent 6164dbb commit bfdc9a9

File tree

1 file changed

+19
-35
lines changed

1 file changed

+19
-35
lines changed

kotlinlib/src/mill/kotlinlib/KotlinModule.scala

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -114,46 +114,30 @@ trait KotlinModule extends JavaModule { outer =>
114114
*/
115115
def kotlinCompilerEmbeddable: Task[Boolean] = Task { false }
116116

117-
/**
118-
* The kotlin-compiler dependencies.
119-
*
120-
* It uses the embeddable version, if [[kotlinCompilerEmbeddable]] is `true`.
121-
*/
122-
def kotlinCompilerDep: T[Seq[Dep]] = Task {
123-
if (kotlinCompilerEmbeddable())
124-
Seq(ivy"org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinCompilerVersion()}")
125-
else
126-
Seq(ivy"org.jetbrains.kotlin:kotlin-compiler:${kotlinCompilerVersion()}")
127-
}
128-
129-
/**
130-
* The kotlin-scripting-compiler dependencies.
131-
*
132-
* It uses the embeddable version, if [[kotlinCompilerEmbeddable]] is `true`.
133-
*/
134-
def kotlinScriptingCompilerDep: T[Seq[Dep]] = Task {
135-
if (kotlinCompilerEmbeddable())
136-
Seq(ivy"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:${kotlinCompilerVersion()}")
137-
else
138-
Seq(ivy"org.jetbrains.kotlin:kotlin-scripting-compiler:${kotlinCompilerVersion()}")
139-
}
140-
141117
/**
142118
* The Ivy/Coursier dependencies resembling the Kotlin compiler.
143119
*
144120
* Default is derived from [[kotlinCompilerVersion]] and [[kotlinCompilerEmbeddable]].
145121
*/
146122
def kotlinCompilerIvyDeps: T[Seq[Dep]] = Task {
147-
kotlinCompilerDep() ++
148-
(
149-
if (
150-
!Seq("1.0.", "1.1.", "1.2.0", "1.2.1", "1.2.2", "1.2.3", "1.2.4").exists(prefix =>
151-
kotlinVersion().startsWith(prefix)
152-
)
153-
)
154-
kotlinScriptingCompilerDep()
155-
else Seq()
156-
)
123+
val useEmbeddable = kotlinCompilerEmbeddable()
124+
val kv = kotlinCompilerVersion()
125+
val isOldKotlin = Seq("1.0.", "1.1.", "1.2.0", "1.2.1", "1.2.2", "1.2.3", "1.2.4")
126+
.exists(prefix => kv.startsWith(prefix))
127+
128+
val compilerDep = if (useEmbeddable) {
129+
ivy"org.jetbrains.kotlin:kotlin-compiler-embeddable:${kv}"
130+
} else {
131+
ivy"org.jetbrains.kotlin:kotlin-compiler:${kv}"
132+
}
133+
134+
val scriptCompilerDep = if (useEmbeddable) {
135+
ivy"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:${kv}"
136+
} else {
137+
ivy"org.jetbrains.kotlin:kotlin-scripting-compiler:${kv}"
138+
}
139+
140+
Seq(compilerDep) ++ when(!isOldKotlin)(scriptCompilerDep)
157141
}
158142

159143
/**
@@ -285,7 +269,7 @@ trait KotlinModule extends JavaModule { outer =>
285269
protected def dokkaAnalysisPlatform: String = "jvm"
286270
protected def dokkaSourceSetDisplayName: String = "jvm"
287271

288-
protected def when(cond: Boolean)(args: String*): Seq[String] = if (cond) args else Seq()
272+
protected def when[T](cond: Boolean)(args: T*): Seq[T] = if (cond) args else Seq.empty
289273

290274
/**
291275
* The actual Kotlin compile task (used by [[compile]] and [[kotlincHelp]]).

0 commit comments

Comments
 (0)