typelead/eta

suggestion: use clojure aot similar mechanism to reduce jar size.

clojurians-org opened this issue · 3 comments

haskell compile too much class file, it led to its big jar size.

clojure has a simple solution for this situation for reference.

it has pomegranate library(just like haskell hint library), it can be used to load clojure file in runtime to generate class dynamically. it also publish clj file as maven repository directrly.

in case we need the same physical class sometimes, it offer the aot mechanism to compile only little needed class file before script interpretion procecure.
the situation is:

export physical jar class implement used by java project
some library use refletion mechanism to load class, so the physical class file must exist.
the reference doc is:
https://clojure.org/reference/compilation

a simple example, it offer aot entry for needed module for project configuration

(defproject clj-java-compile "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :aot [core, xxx.yyy, ...]
  :source-paths ["src/main/clojure"]
  :java-source-paths ["src/main/java"])

as you can see from maven repository:
http://central.maven.org/maven2/org/clojure/core.async/0.4.490/

the maven repository container only clj file without java.

Hi, the tool to minimize the jar that has been used so far is proguard , you can use it directly or including the appropiate gradle plugin if you are already are using gradle to build the eta project.