Fork me on GitHub
#leiningen
<
2019-06-19
>
Yehonathan Sharvit06:06:37

Hi there! I’d like to deploy a library to clojars but only the files under the src folder. How can I do that?

mikerod14:06:52

@viebel do you want to deploy them within a jar?

Yehonathan Sharvit14:06:35

@mikerod Basically, I want the library to be consumable from other projects

mikerod14:06:11

As a jar typically.

mikerod14:06:24

I don’t understand your problem

mikerod14:06:47

by default, if you do lein install, you’ll make and install into your local artifact repo a jar with the files from the :source-paths and :resource-paths

mikerod14:06:03

If you don’t set those, that defaults to the 2 directories "src" and "resources"

mikerod14:06:28

If you want to deploy, you do lein deploy, but there are options there depending on how/where you are wanting to deploy it

mikerod14:06:50

I don’t see you asking for anything beyond the basic operations built into lein, unless you have some more specific requirement here

mikerod14:06:36

Not sure which lein -v you are using, but using 2.8.3 here as an example, read through https://github.com/technomancy/leiningen/blob/2.8.3/doc/DEPLOY.md

mikerod14:06:09

However, sounds like you may need more background than that, so read perhaps several of the files there under that doc/ dir in the repo.

Yehonathan Sharvit14:06:44

I am in a cljs project

Yehonathan Sharvit14:06:38

Here is my project.clj:

(defproject klipse "7.9.0"
  :description "Embeddable multi-language WEB REPL"
  :license "GPL-3.0"
  :url ""
  :resource-paths ["src"]
;  :resource-paths ["scripts" "src" "resources" "target"]
  :min-lein-version "2.8.1"
  :middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn]
  :lein-tools-deps/config {:config-files [:install :user :project]}
  :plugins [[lein-cljsbuild "1.1.7"]
            [lein-hiera "0.9.5"]
            [lein-tools-deps "0.4.1"]]
  :clean-targets ^{:protect false} ["targets"]
  :hiera {:path "deps-graph.png"
          :vertical true
          :show-external false
          :cluster-depth 2
          :trim-ns-prefix true}
  :cljsbuild {:builds {:plugin {:source-paths ["src/klipse/run/plugin"]
                                :compiler {
                                           :output-to "resources/public/plugin/js/klipse_plugin.js"
                                           :output-dir "resources/public/plugin/js"
                                           :pretty-print false
                                           :optimize-constants true
                                           :static-fns true
                                           ;:elide-asserts true
                                           :closure-defines {klipse.core/version
                                                             ~(->> (slurp "project.clj")
                                                                (re-seq #"\".*\"")
                                                                (first))}
                                           :optimizations :simple
                                           :verbose false}}
                       :plugin-prod {
                                     :source-paths ["src/klipse/run/plugin_prod"]
                                     :compiler {
                                                :output-to "resources/public/plugin_prod/js/klipse_plugin.min.js"
                                                :output-dir "resources/public/plugin_prod/js"
                                                :pretty-print true
                                                :elide-asserts false
                                                :optimizations :advanced
                                                :closure-defines {klipse.core/version
                                                                  ~(->> (slurp "project.clj")
                                                                     (re-seq #"\".*\"")
                                                                     (first))}
                                                :verbose true}}}})

Yehonathan Sharvit14:06:58

For some reason, when I run lein install the generated jar is huge (around 11G)

Yehonathan Sharvit14:06:15

I cannot understand why. Any idea @mikerod @lukaszkorecki?

mikerod15:06:47

@viebel there is a lot involved here, so I won’t be able to answer why you’d get a large size. You could open the jar and see what things in it are large.

mikerod15:06:45

I do think that in your :compiler options in :cljsbuild it is odd you have :pretty-print true, while doing :optimizations :advanced, but I’m not even sure the cljs compiler would do anything about that. I think it’d ignore the :pretty-print option (should be false).

mikerod15:06:27

Overall though, too many unknowns. Look in the jar and see what is being included. It’s probably some really large JS stuff or something from your dependencies. Maybe the :hiera img stuff too

mikerod15:06:17

I also don’t understand your goals. You mentioned earlier that you only wanted to include the “src”. I don’t see how that’d work for someone necessarily.

Yehonathan Sharvit15:06:05

The jar is so big that it take ages to open

mikerod15:06:19

you can just extract it. then look around the extracted contents

mikerod15:06:40

not sure how you are you trying to open it

Yehonathan Sharvit16:06:10

I use :lein-tools-deps/config {:config-files [:install :user :project]} which overrides :resources-path with its value from deps.edn

mikerod16:06:33

yeah, I’ve nevered used this in lein, so that could make sense to me