Fork me on GitHub
#tools-build
<
2021-12-21
>
fabrao10:12:50

Hello all, I see the difference btw depstar and tools.build, from depstar I see clj non .class generated and from tools.build I see the .class references for .clj. To the application, what is the impact of it?

fabrao10:12:20

The configuration is

:build {:deps {io.github.clojure/tools.build {:git/tag "v0.7.2" :git/sha "0361dde"}}
          :ns-default build}
:uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.297"}}
            :exec-fn      hf.depstar/uberjar
            :exec-args    {:aot        true
                           :jar        "myjar.jar"
                           :main-class "my-app.core"}}

fabrao12:12:33

what is the difference been aot compiled and not?

delaguardo12:12:30

https://clojure.org/reference/compilation this article covers most of the differences.

fabrao12:12:23

so, should I consider tools.build build with aot or not?

delaguardo12:12:15

I nether use aot to package my applications. It usually complicate things. But if you think one of the reasons given in the first section of the article is relevant to you - you can try it out. Problems (if any) should pop up right away

Alex Miller (Clojure team)13:12:00

Clojure code must be compiled to classes to be loaded by the jvm. This is either done on demand at runtime or ahead of time and saved in your uberjar. Doing the latter will make your app load faster as that work is done already

fabrao13:12:51

So, I see that it includes both, is that why?

Alex Miller (Clojure team)14:12:50

If both are included, the compiler classes are preferred

seancorfield17:12:44

@U0YJJPFRA If you use my build-clj wrapper for tools.build, it will AOT compile your main namespace and since AOT is transitive, that will generally compile "everything". The build-clj equivalent to what you were doing with depstar would be something like:

(ns build
    (:require [org.corfield.build :as bb]))

(defn uberjar [opts]
    (bb/uber (merge {:main 'my-app.core :uber-file "myjar.jar"} opts)))
Then you'd run clojure -T:build uberjar and you can provide any tools.build options you want for the compile and uber steps (and influence the copying steps too).

seancorfield17:12:38

build-clj is intended to provide sane defaults for the various tools.build functions and to simplify your build.clj file -- it's a very thin wrapper 🙂

fabrao17:12:20

@U04V70XH6 Thank you, I´ll try it