Fork me on GitHub

This is probably a pretty newb question but is there a way/best practice for deploying a Leiningen template to a private JAR server. My company is using to deploy a couple of shared Clojure libs, which works great. Accessing this is dependent on having a :repositories key in the project.clj of the project that is using the shared lib. In the case of a Leiningen template, there is no project.clj file in which to put the repositories information. Is this something that should be handled via ~/.lein/profiles.clj?

Ian Fernandez20:08:27

Guys I'm using lein pedestal uberwar, I have many folders under src and I want to have the folder class by profile. Like

when I use:
lein with-profile a pedestal uberwar
This will only generate a jar that has class a

Ian Fernandez20:08:48

how can I do this?


@d.ian.b I can’t follow what you are trying to do well enough to help there

Ian Fernandez20:08:21

and I want to have jar that does not has propose stuff only user stuff

Ian Fernandez20:08:47

because it were separated repos before

Ian Fernandez20:08:23

(defproject backend "0.1.1"
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [com.walmartlabs/lacinia-pedestal "0.11.0"]
                 [buddy "2.0.0"]
                 [prismatic/schema "1.1.11"]
                 [buddy/buddy-hashers "1.4.0"]
                 [ "1.85.0"]
                 [ "1.9.76"]
                 [ "1.69.0"]
                 [ "0.8"]
                 [com.rpl/specter "1.1.2"]
                 [http-kit "2.3.0"]
                 [clj-time "0.15.1"]
                 [com.twilio.sdk/twilio "7.41.0"]
                 [camel-snake-kebab "0.4.0"]
                 [metosin/jsonista "0.2.3"]
                 [com.walmartlabs/lacinia "0.31.0"]
                 [camel-snake-kebab "0.4.0"]
                 [base64-clj "0.1.1"]
                 [clojurewerkz/money "1.10.0"]
                 [environ "1.1.0"]
                 [org.clojure/data.xml "0.2.0-alpha6"]]
  :plugins [[ohpauleez/lein-pedestal "0.1.0-beta10"]
            [lein-environ "1.1.0"]]
  :resource-paths ["resources"]
  :source-paths ["src" "src/commons"]
  :profiles {:production {:env {:crowd-env         "production"
                                :clojure-repl      "false"
                                :datastore-offline "false"}}
             :homolog    {:env {:crowd-env         "homolog"
                                :clojure-repl      "false"
                                :datastore-offline "false"}}
             :dev        {:resource-paths ["test/backend/"]
                          :plugins        [[lein-midje "3.2.1"]]
                          :dependencies   [[midje "1.9.9"]
                                           [org.clojure/test.check "0.9.0"]
                                           [com.gfredericks/test.chuck "0.2.9"]
                                           [talltale "0.4.3"]
                                           [com.wsscode/pathom  "2.2.19"]]
                          :env            {:crowd-env         "develop"
                                           :clojure-repl      "true"
                                           :datastore-offline "true"}}
              :user       {:dependencies [[org.clojure/java.jdbc "0.7.9"]]
                              :env            {:module "user"}
                              :source-paths   ["src/backend/user"]
                              :resource-paths ["resources/user"]
                              :main           backend.user.core
                              :aot            [backend.user.core]
                              :pedestal       {:server-ns "backend.user.core"}}
              :propose    {:env            {:module "propose"}
                                  :main           backend.propose.core
                                  :source-paths   ["src/backend/propose"]
                                  :resource-paths ["resources/propose"]
                                  :aot            [backend.propose.core]
                                  :pedestal       {:server-ns "backend.propose.core"}}})
mine project.clj

Ian Fernandez20:08:44

mine filetree

├── backend
│   ├── propose
│   │   ├── core.clj
│   │   ├── datastore.clj
│   │   ├── push.clj
│   │   ├── query.clj
│   │   ├── resolvers.clj
│   │   └── twilio.clj
│   └── user
│       ├── core.clj
│       ├── mssql.clj
│       ├── query.clj
│       └── resolvers.clj
└── commons
    ├── datastore.clj
    ├── datastore_schema.clj
    ├── env.clj
    ├── twilio.clj
    └── twilio_schema.clj


you are inheriting the "src" dir in all profiles


for :source-paths


so for example


:user       {:dependencies [[org.clojure/java.jdbc "0.7.9"]]
             :env            {:module "user"}
             :source-paths   ^:replace ["src/backend/user"]
             :resource-paths ["resources/user"]
             :main           backend.user.core
             :aot            [backend.user.core]
             :pedestal       {:server-ns "backend.user.core"}}
added :replace metadata to the :source-paths in the :user profile


Similar for :resource-paths if you need isolation there as well

❤️ 4
Ian Fernandez01:08:46

Thats what I want! Thanks!!!

🎉 4
Ian Fernandez14:08:14

I've changed some stuff here and made a folder named commons

Ian Fernandez14:08:25

i'm having this problem when i run

Ian Fernandez14:08:36

Could not locate user/core__init.class, user/core.clj or user/core.cljc on classpath.

Ian Fernandez14:08:13

I think its better to have 2 folders src/commons and src/user

Ian Fernandez14:08:25

for project.clj I have ... :source-paths ["src/commons"] :profiles {:user {:source-paths ["src/user"] ....}


your last example makes sense


if you put a top level :source-paths in the project it’ll automatically merge to the profiles :source-paths if you do not put the :replace metadata


so that should give you what you want


perhaps state it different or show an example project.clj?


@mafcocinco I think you’re wanting to have a shared :repositories coming from ~/.lein/profiles.clj? I don’t think it’s recommended at least and will likely give you warnings. Why can’t you put the :repositories into your build project? The template can’t have it in it? I think I don’t understand that either hah.