update logic to find maven

This commit is contained in:
Simon Gardling 2021-04-08 13:18:31 -04:00
parent 5f87d326fd
commit cfffd9d050
2 changed files with 11 additions and 2 deletions

View File

@ -90,4 +90,14 @@ open class ToothpickExtension(objects: ObjectFactory) {
}
return upstreamArray.stream().sorted { upstream1, upstream2 -> upstream1.id - upstream2.id}.collect(Collectors.toList())
}
internal val mavenCommand: String by lazy {
if (exitsSuccessfully("mvn", "-v")) {
return@lazy "mvn"
}
if (exitsSuccessfully("mvn.cmd", "-v")) {
return@lazy "mvn.cmd"
}
error("Unable to locate maven. Please ensure you have maven installed and on your path.")
}
}

View File

@ -22,12 +22,11 @@ internal fun Project.createPaperclipTask(
val patchedJarPath = inputs.files.singleFile.absolutePath
logger.lifecycle(">>> Building paperclip")
val paperclipCmd = arrayListOf(
"mvn", "-T", "2C", "clean", "package",
toothpick.mavenCommand, "-T", "2C", "clean", "package",
"-Dmcver=${toothpick.minecraftVersion}",
"-Dpaperjar=$patchedJarPath",
"-Dvanillajar=$vanillaJarPath"
)
if (System.getProperty("os.name").startsWith("Windows")) paperclipCmd[0] = "mvn.cmd"
if (jenkins) paperclipCmd.add("-Dstyle.color=never")
ensureSuccess(cmd(*paperclipCmd.toTypedArray(), dir = paperclipDir, printOut = true))
val paperClip = paperclipDir.resolve("assembly/target/paperclip-${toothpick.minecraftVersion}.jar")