Skip to content

Commit

Permalink
Merge pull request #80 from modelix/ant-absolute-path
Browse files Browse the repository at this point in the history
fix: use an absolute path when executing ant
  • Loading branch information
slisson authored Jan 20, 2025
2 parents de40cfe + 52b41db commit 8096e39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import org.modelix.buildtools.ModulesMiner
import org.modelix.buildtools.PublicationDependencyGraph
import org.modelix.buildtools.SourceModuleOwner
import org.modelix.buildtools.StubsSolutionGenerator
import org.modelix.buildtools.findExecutableAbsolutePath
import org.modelix.buildtools.invokelambda.InvokeLambda
import org.modelix.buildtools.modelixBuildToolsVersion
import org.modelix.buildtools.newChild
Expand Down Expand Up @@ -230,7 +231,7 @@ class MPSBuildPlugin @Inject constructor(val project: Project) : Plugin<Project>

val taskAssembleMpsModules = project.tasks.create("assembleMpsModules", Exec::class.java) {
workingDir(buildDir.get())
commandLine(antScriptFile.map { listOf("ant", "-f", it.asFile.absolutePath, "assemble") }.get())
commandLine(antScriptFile.map { listOf(findExecutableAbsolutePath("ant"), "-f", it.asFile.absolutePath, "assemble") }.get())
standardOutput = System.out
errorOutput = System.err
standardInput = System.`in`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BuildScriptGenerator(
}

fun getAntPath(): String {
return listOf("/usr/local/bin/ant").firstOrNull { File(it).exists() } ?: "ant"
return findExecutableAbsolutePath("ant")
}

fun generateXML(): String {
Expand Down Expand Up @@ -953,3 +953,11 @@ class BuildScriptGenerator(
}

private fun getIdeaPluginsBuildDir(buildDir: File) = buildDir.resolve("idea-plugins")

fun findExecutableAbsolutePath(name: String): String {
return System.getenv("PATH").split(File.pathSeparatorChar)
.map { File(it).resolve(name) }
.firstOrNull { it.isFile && it.exists() }
?.absolutePath
?: name
}

0 comments on commit 8096e39

Please sign in to comment.