tools-build

fabrao 2021-12-21T10:44:50.345500Z

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?

fabrao 2021-12-21T10:46:20.346Z

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"}}

fabrao 2021-12-21T12:29:33.347Z

what is the difference been aot compiled and not?

Kirill Chernyshov 2021-12-21T12:31:30.347100Z

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

fabrao 2021-12-21T12:34:23.347300Z

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

Kirill Chernyshov 2021-12-21T12:40:15.347500Z

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) 2021-12-21T13:26:00.351Z

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

fabrao 2021-12-21T13:53:51.351200Z

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

Alex Miller (Clojure team) 2021-12-21T14:10:50.351900Z

If both are included, the compiler classes are preferred

seancorfield 2021-12-21T17:33:44.352100Z

@fabrao 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).

seancorfield 2021-12-21T17:34:38.352300Z

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 🙂

fabrao 2021-12-21T17:58:20.352500Z

@seancorfield Thank you, I´ll try it