babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-05-02T09:27:05.357Z

Merging this in the next version of bb:

$ ./bb -e '(with-precision 20 :rounding CEILING (/ 1M 3))'
0.33333333333333333334M
:D

borkdude 2021-05-02T11:09:58.357700Z

@mike1452 Now alignment works for me: https://github.com/clj-kondo/clj-kondo.lsp/blob/master/bb.edn with (setq clojure-align-separator 'entire). Before it would stop aligning after blank lines.

mike_ananev 2021-05-02T11:46:34.359400Z

@borkdude 👍. I continue to play with babashka. Can't stop enjoying it after years with bash, python, groovy.

😊 2
mike_ananev 2021-05-02T18:20:41.361700Z

how to catch output of ?

(babashka.tasks/clojure "-Spath")
I need to build clojure project classpath from deps.edn and send it to javac utility as -cp parameter.

borkdude 2021-05-02T18:21:35.362Z

@mike1452

(with-out-str (babashka.tasks/clojure "-Spath"))
:)

mike_ananev 2021-05-02T18:24:11.362600Z

huh! yeah, I'm a bit tired today 🙂

borkdude 2021-05-02T18:24:46.363100Z

well, it only works because it's designed that way, it could have been different

mike_ananev 2021-05-02T22:09:10.364600Z

@borkdude, another bb.edn example for new version of application template https://github.com/redstarssystems/rssysapp/blob/develop/resources/clj/new/rssysapp/bb.edn

borkdude 2021-05-02T22:20:08.365300Z

@mike1452 Very cool! Any reason you are not using :depends rather than (run 'task)?

borkdude 2021-05-02T22:20:57.365900Z

You could do this in :init: (def cformat clojure.core/format) and then use cformat in the rest of your tasks, for shorter naming, or (alias 'core 'clojure.core)

mike_ananev 2021-05-02T22:33:20.368600Z

yeah, good advices! :depends and run are both good, but I wanted to call another task in particular place in code (or execution time), so I used run

👍 1
borkdude 2021-05-02T22:40:03.369200Z

@mike1452 Does this work? https://github.com/redstarssystems/rssysapp/blob/0763853843973692a7594f90061c6b24d2e1cb3b/resources/clj/new/rssysapp/bb.edn#L85 The File class is not imported anywhere?

mike_ananev 2021-05-02T22:41:21.369600Z

Yes! It works!

mike_ananev 2021-05-02T22:42:00.369900Z

You can try it

clojure -X:new :template org.rssys.apptemplate :name com.example/app01
Then create java/src folder and put there some class like
package com.example;

public class Hello01{
    public static void sayHello (){
        System.out.println("hello from Hello01");
    }
}
Then uncomment "java/src" in deps.edn and call Hello01 from main

borkdude 2021-05-02T22:44:17.370500Z

I guess bb was a bit too liberal with its default imports compared to clojure...

borkdude 2021-05-02T22:44:34.370800Z

bb -e 'File'
java.io.File

$ clj -M -e 'File'
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: File in this context

borkdude 2021-05-02T22:45:34.371500Z

because this isn't compatible with normal Clojure, I might revert that so it would probably be better to write java.io.File

borkdude 2021-05-02T22:46:32.371700Z

https://github.com/babashka/babashka/issues/816

mike_ananev 2021-05-02T22:49:00.372500Z

ok, I'll rewrite it tomorrow.