Fork me on GitHub
#babashka
<
2021-08-12
>
maxp07:08:39

how to set compile-path in babashka?

borkdude07:08:24

@maxp There is no compile path in babashka

borkdude07:08:24

can you explain what you are trying to accomplish?

maxp07:08:08

I'm trying to build uberjar with aot using depstar

maxp07:08:16

(clojure "-X:depstar"   "uberjar"
                               ":aliases"     "[:uber-resources]"
                               ":sync-pom"    "true"
                               ":aot"         "true"
                               ":jar"         (deref *jar)
                               ":main-class"  (:main-class project)
                               ":group-id"    group-id
                               ":artifact-id" artifact-id
                               ":version"     (str "\"" (deref *version-str) "\"")))

maxp07:08:45

that is part of my bb.edn task

maxp07:08:03

it uses compile inside depstar

borkdude07:08:13

ah yes. but this is invoking a clojure process. so the compile path isn't related to the babashka environment itself

borkdude07:08:29

I'm pretty sure depstar has an option for this

maxp07:08:25

thank you

👍 4
rohit_19:08:00

Hi there I was trying to figure out if there is a way to use the postgres pod within my task. I see there is an ongoing discussion on how to include pods within tasks but dont know if there is some way to do this prior to it becoming a babashka feature.

borkdude19:08:20

@rohit_ you don't have to do anything specific to load pods in tasks, that will just work

borkdude19:08:44

just (:requires ([babashka.pods]) and then (pods/load-pod ...)

borkdude19:08:36

you could make a -load-pod tasks and then depend on that one before you require any other namespaces

borkdude20:08:03

hmm, now you mention it, I'm not sure if that would work

borkdude20:08:21

I will give it a try locally

rohit_20:08:28

so something like this

(pods/load-pod 'org.babashka/postgresql "0.0.7")
 (require '(pod.babashka [postgresql :as pg]))
 (pg/execute! db "select * from cluster") 
would work?

borkdude20:08:45

yeah, the problem is that all namespaces are required before any expressions are executed

borkdude20:08:52

so with tasks this is a bit iffy

borkdude20:08:37

perhaps put the code not within tasks and just in a .clj file and then call that from the tasks

rohit_20:08:13

so i should make a dependee task in a clj file that does this

(defn load-pods [] (pods/load-pod 'org.babashka/postgresql "0.0.7")
and then add the require in the target ns

borkdude20:08:42

right, I think that will work

rohit_20:08:49

let me try that, thanks so much. I've been meddling around into getting the publics from the name space and I dont know that much about SciVars but it felt like there should be an easier answer

borkdude20:08:27

This would also work:

[email protected] /tmp $ cat bb.edn
{:paths ["."]
 :tasks {sql db/main}}
[email protected] /tmp $ cat db.clj
(ns db)

(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/postgresql "0.0.7")
(require '[pod.babashka.postgresql :as psql])

(defn main []
  (psql/execute! <db> "select * from foo"))

[email protected] /tmp $ bb sql

rohit_20:08:42

i'll try this this is great thank you so much