Skip to content

Commit 5057962

Browse files
committed
fix: address review comments
Signed-off-by: melodicore <datafox@datafox.me>
1 parent 94bdd07 commit 5057962

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

elide-plugin/src/main/kotlin/dev/elide/maven/plugin/ElideCompileMojoImpl.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
package dev.elide.maven.plugin
1414

15-
import dev.elide.maven.compiler.ElideJavacCompiler
1615
import org.apache.maven.plugin.compiler.AbstractCompilerMojo
1716
import org.apache.maven.plugin.compiler.CompilerMojo
1817
import org.apache.maven.plugins.annotations.Parameter
@@ -27,11 +26,17 @@ open class ElideCompileMojoImpl : CompilerMojo() {
2726
/** Elide executable location. */
2827
@Parameter(name = "executable") var executable: String? = null
2928

30-
init {
29+
override fun execute() {
3130
AbstractCompilerMojo::class.java.getDeclaredField("compilerId").apply {
3231
isAccessible = true
3332
set(this@ElideCompileMojoImpl, "elide")
3433
}
35-
ElideJavacCompiler.executable = executable
34+
executable?.let {
35+
AbstractCompilerMojo::class.java.getDeclaredField("executable").apply {
36+
isAccessible = true
37+
set(this@ElideCompileMojoImpl, it)
38+
}
39+
}
40+
super.execute()
3641
}
3742
}

elide-plugin/src/main/kotlin/dev/elide/maven/plugin/ElideTestCompileMojoImpl.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
package dev.elide.maven.plugin
1414

15-
import dev.elide.maven.compiler.ElideJavacCompiler
1615
import org.apache.maven.plugin.compiler.AbstractCompilerMojo
1716
import org.apache.maven.plugin.compiler.TestCompilerMojo
1817
import org.apache.maven.plugins.annotations.Parameter
@@ -27,11 +26,17 @@ open class ElideTestCompileMojoImpl : TestCompilerMojo() {
2726
/** Elide executable location. */
2827
@Parameter(name = "executable") var executable: String? = null
2928

30-
init {
29+
override fun execute() {
3130
AbstractCompilerMojo::class.java.getDeclaredField("compilerId").apply {
3231
isAccessible = true
3332
set(this@ElideTestCompileMojoImpl, "elide")
3433
}
35-
ElideJavacCompiler.executable = executable
34+
executable?.let {
35+
AbstractCompilerMojo::class.java.getDeclaredField("executable").apply {
36+
isAccessible = true
37+
set(this@ElideTestCompileMojoImpl, it)
38+
}
39+
}
40+
super.execute()
3641
}
3742
}

java-compiler/src/main/kotlin/dev/elide/maven/compiler/ElideJavacCompiler.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ open class ElideJavacCompiler :
7878
}
7979

8080
private fun getElideExecutable(config: CompilerConfiguration): String =
81-
executable ?: config.executable ?: ElideLocator.locate()?.absolutePathString() ?: ELIDE_EXECUTABLE
81+
config.executable ?: ElideLocator.locate()?.absolutePathString() ?: ELIDE_EXECUTABLE
8282

8383
override fun createCommandLine(config: CompilerConfiguration): Array<String> {
8484
return buildElideArgs(config, getSourceFiles(config)).toTypedArray()
@@ -207,9 +207,4 @@ open class ElideJavacCompiler :
207207
val kind = if (exitCode == 0) CompilerMessage.Kind.NOTE else CompilerMessage.Kind.ERROR
208208
return input.map { CompilerMessage(it, kind) }
209209
}
210-
211-
companion object {
212-
// allow overriding executable in elide-maven-plugin
213-
var executable: String? = null
214-
}
215210
}

java-compiler/src/main/kotlin/dev/elide/maven/compiler/ElideLocator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
package dev.elide.maven.compiler
1414

15+
import java.io.File.pathSeparatorChar
1516
import java.nio.file.Path
1617
import java.nio.file.Paths
1718

@@ -36,7 +37,7 @@ object ElideLocator {
3637
*/
3738
fun locate(): Path? {
3839
val path = System.getenv("PATH") ?: ""
39-
for (pathCandidate in path.split(':')) {
40+
for (pathCandidate in path.split(pathSeparatorChar)) {
4041
val candidate = Paths.get(pathCandidate, ELIDE_EXECUTABLE)
4142
if (isValidElideBinary(candidate)) {
4243
return candidate

0 commit comments

Comments
 (0)