From fa65804c994cd6218f4ce4ec8e2d8a4ca6d097db Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 4 Jan 2022 14:55:56 +0100 Subject: [PATCH] Fix support for .jar binaries, fixes #10426 --- src/Composer/Installer/BinaryInstaller.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index ec0fbd337..a057c5517 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -158,6 +158,10 @@ class BinaryInstaller return trim($match[1]); } + if (substr($bin, -4) === '.jar') { + return 'java -jar '; + } + return 'php'; } @@ -224,7 +228,7 @@ class BinaryInstaller $binPath = $this->filesystem->findShortestPath($link, $bin); $caller = self::determineBinaryCaller($bin); - // if the target is a php file, we run the unixy proxy file + // if the target is a php file, we run the unixy proxy file (a php script in this case) // to ensure that _composer_autoload_path gets defined, instead // of running the binary directly if ($caller === 'php') { @@ -394,6 +398,11 @@ include $binPathExported; PROXY; } + $caller = ''; + if (substr($bin, -4) === '.jar') { + $caller = 'java -jar '; + } + return << /dev/null; pwd) -"\${dir}/$binFile" "\$@" +$caller"\${dir}/$binFile" "\$@" PROXY; }