babashka / pods

Pods support for JVM and babashka
Eclipse Public License 1.0
122 stars 12 forks source link

Binding to suppress print output not supported by pod #72

Open Kaspazza opened 2 months ago

Kaspazza commented 2 months ago

I'm using tools bbuild for building pom.xml, which prints messages to *err* using tools deps utils function e.g. here. I would like to have control on what's printed, so I did simple:

(let [s (new java.io.StringWriter)]
(binding [*out* s *err* s] (clj-build-api/write-pom params)))

This binding takes no effect and there is no way to suppress the messages due to pod not being affected by binding.

Temporary solution: After starting, evaluating (require 'clojure.tools.deps.util.io :reload) makes binding to work

Kaspazza commented 2 months ago

Conversation on slack: https://clojurians.slack.com/archives/CLX41ASCS/p1727087596166359

borkdude commented 2 months ago

I think in the case of tools.bbuild this might work: (require '[clojure.tools.deps.util.io](http://clojure.tools.deps.util.io/) :reload). The issue here is that the tools.build.native pod exposes this native namespace, but in tools.bbuild it could just load this namespace from source and then the binding would work. So perhaps this is just fixable in tools.bbuild itself, by reloading this namepace AND/OR removing the exposed native namespace in the tools.build.native pod. I'm not sure we even need to expose it in the pod for it to be useful as a standalone thing.