Fork me on GitHub
#boot
<
2017-05-10
>
cpmcdaniel12:05:35

did you try it?

cpmcdaniel12:05:57

oh, now I remember

cpmcdaniel12:05:40

I think I was just using the pom for deps only, so it parses the XML rather than downloading maven jars to build a full project object model in memory

cpmcdaniel12:05:55

pull requests are welcome šŸ˜‰

cpmcdaniel12:05:55

I suppose version variables like that are primarily useful for maven modules (multi-projects), for which there isnā€™t really an analog in either lein or boot

cpmcdaniel12:05:10

well, not without a lein plugin

cpmcdaniel12:05:59

I mean, there are other ways to skin the multi-project cat with boot, but that doesnā€™t help you in this case

pjullah15:05:30

Hi there, Iā€™m hoping for some help with a simple build task that Iā€™m using.

(deftask build
  "Build the project locally as a JAR."
  [d dir PATH #{str} "the set of directories to write to (target)."]
  (let [dir (if (seq dir) dir #{"target"})]
    (comp
      (aot)
      (pom)
      (uber)
      (jar)
      (target :dir dir))))
Itā€™s taken from an example somewhere, and works fine. The issue Iā€™m facing is that the contents of a resources/ directory at the root of my project are copied to the top of directory structure in the jar file. Iā€™ve toyed around with :resource-paths and :asset-paths a little, but not sure where to go next to figure this out. Any advice would be great. Thanks Oh, and here is some of my build.boot
(set-env! :resource-paths #{"resources"}
          :source-paths #{"test" "src"}
          :dependencies '[
(task-options!
  aot {:namespace #{'app.main}}
  pom {:project     project
       :version     version
       :description ""
       :url         ""
       :scm         {:url ""}
       :license     {"" ""}}
  jar {:main 'app.main
       :file        (str "app-" version ".jar")})

alandipert15:05:51

@pjullah you could make a directory resources/resources and then move your files there

pjullah15:05:13

@alandipert good idea. But, everything works fine when working in the repl. I think Iā€™d end up with two different paths to my files in dev and prod.

alandipert15:05:49

@pjullah it sounds like at the repl you might be referring to items by file, not by classpath

alandipert15:05:12

as long as you refer only to files on the classpath, you should be fine in both cases

pjullah15:05:56

@alandipert thanks. I think I see what you mean. Iā€™ll have a play around and see what mess I can get myself into šŸ™‚

pjullah15:05:03

@alandipert hmm. still no joy. my file is at /resources/config.edn and is used like

(ns app.conf
  (:require [mount.core :as mount :refer [defstate]]
            [clojure.edn :as edn]
            [ :refer [resource]]
            [clojure.tools.logging :refer [info]]))

(defn load-config [path]
  (info "loading config from" path)
  (-> path
      slurp
      edn/read-string))

(defstate config
  :start (load-config "resources/config.edn"))
So I took your advice and have tried both
(resource "config.edn") => nil
(resource "resources/config.edn") => nil
Is this what you meant, or have I misunderstood?

alandipert15:05:12

@pjullah i donā€™t see anything obviously wrong with that

pjullah15:05:50

@alandipert thanks. That works. Given that you didnā€™t need to reference ā€œresources/ā€ would suggest that itā€™s on the classpath. Which leads me to conclude that ā€œresources/ā€ is not on my classpathā€¦ (in my project)

alandipert15:05:56

i recommend working at the repl to troubleshoot, you can call set-env! and resource there

alandipert15:05:44

if you make changes to your build.boot you can also reload it without restarting jvm by callind (load-file "build.boot") at repl

pjullah15:05:32

Thanks. I found the issue. I had changed resource-paths to asset-paths - works now.

pjullah15:05:37

Thanks for all your help.

alandipert16:05:10

no prob, glad you figured it out

pjullah16:05:03

BTW - the jar file is now working as expected too.