Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ jobs:
java -version
bb --version

- name: 🔧 Install bb from dev build (until next release)
shell: bash
run: |
curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
chmod +x ./install
./install --dev-build --dir /tmp
cp /tmp/bb "$(which bb)"

- name: Run bb tests
run: |
bb test:bb
Expand Down
1 change: 1 addition & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{:deps {babashka/fs {:mvn/version "0.4.18"}}
:paths ["src" "resources"]
:aliases {:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:main-opts ["-m" "cognitect.test-runner"]}
Expand Down
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:url "https://www.eclipse.org/legal/epl-1.0/"}
:dependencies [[org.clojure/clojure "1.9.0"]
[babashka/fs "0.4.18"]]
:source-paths ["src" "resources"]
:deploy-repositories [["clojars" {:url "https://clojars.org/repo"
:username :env/clojars_user
:password :env/clojars_pass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[ {
"name" : "org.graalvm.nativeimage.ProcessProperties",
"methods": [{"name": "exec"}]
} ]
22 changes: 8 additions & 14 deletions src/babashka/process.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -604,16 +604,10 @@
:err :string} opts)]
@(process* {:cmd cmd :opts opts :prev prev})))

(def ^:private has-exec?
(boolean (try (.getMethod ^Class
(resolve 'org.graalvm.nativeimage.ProcessProperties) "exec"
(into-array [java.nio.file.Path (Class/forName "[Ljava.lang.String;") java.util.Map]))
(catch Exception _ false))))

(defmacro ^:no-doc
if-has-exec [then else]
(if has-exec?
then else))
(def ^:private exec-meth
(delay (try (.getMethod (Class/forName "org.graalvm.nativeimage.ProcessProperties") "exec"
(into-array [java.nio.file.Path (Class/forName "[Ljava.lang.String;") java.util.Map]))
(catch Exception _ nil))))

(defn exec
"Replaces the current process image with the process image specified
Expand Down Expand Up @@ -649,10 +643,10 @@
^java.util.Map env (into (or (as-string-map env)
(into {} (System/getenv)))
(as-string-map extra-env))]
(if-has-exec
(org.graalvm.nativeimage.ProcessProperties/exec (fs/path program)
(into-array String args)
env)
(if-let [^java.lang.reflect.Method meth @exec-meth]
(.invoke meth nil (into-array Object [(fs/path program)
(into-array String args)
env]))
(throw (ex-info "exec is not supported in non-GraalVM environments" {:cmd cmd}))))))

(def ^:private default-shell-opts
Expand Down