1+ /*
2+ * Copyright (c) 2024-2025 Elide Technologies, Inc.
3+ *
4+ * Licensed under the MIT license (the "License"); you may not use this file except in compliance
5+ * with the License. You may obtain a copy of the License at
6+ *
7+ * https://opensource.org/license/mit/
8+ *
9+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+ * License for the specific language governing permissions and limitations under the License.
12+ */
113package dev.elide.maven.compiler
214
315import org.codehaus.plexus.compiler.*
@@ -9,13 +21,18 @@ import java.io.IOException
921import java.util.LinkedList
1022import javax.inject.Named
1123import javax.inject.Singleton
24+ import kotlin.io.path.absolutePathString
1225
1326/* *
14- * @author Lauri "datafox" Heino
27+ * Implements a Java compiler bridge from Maven to Elide.
28+ *
29+ * @author Lauri Heino <datafox>
30+ * @author Sam Gammon <sgammon>
31+ * @since 1.0.0
1532 */
16- @Named(" elide " )
33+ @Named(ELIDE_COMPILER )
1734@Singleton
18- open class ElideJavacCompiler () : AbstractCompiler(
35+ public open class ElideJavacCompiler () : AbstractCompiler(
1936 CompilerOutputStyle .ONE_OUTPUT_FILE_PER_INPUT_FILE ,
2037 " .java" ,
2138 " .class" ,
@@ -63,10 +80,10 @@ open class ElideJavacCompiler() : AbstractCompiler(
6380 return CompilerResult (returnCode == 0 , messages)
6481 }
6582
66- private fun getElideExecutable (config : CompilerConfiguration ): String {
67- if (config.executable != null && config.executable.isNotBlank()) return config.executable
68- return " elide "
69- }
83+ private fun getElideExecutable (config : CompilerConfiguration ): String = when ( val executable = config.executable) {
84+ null -> ElideLocator .locate()?.absolutePathString()
85+ else -> executable
86+ } ? : " elide "
7087
7188 override fun createCommandLine (config : CompilerConfiguration ): Array <String > {
7289 return buildElideArgs(config, getSourceFiles(config)).toTypedArray()
@@ -176,9 +193,9 @@ open class ElideJavacCompiler() : AbstractCompiler(
176193 }
177194
178195 @Throws(IOException ::class )
179- fun parseOutput (exitCode : Int , input : List <String >): List <CompilerMessage > {
196+ private fun parseOutput (exitCode : Int , input : List <String >): List <CompilerMessage > {
180197 // very lazy for now
181198 val kind = if (exitCode == 0 ) CompilerMessage .Kind .NOTE else CompilerMessage .Kind .ERROR
182199 return input.map { CompilerMessage (it, kind) }
183200 }
184- }
201+ }
0 commit comments