Fork me on GitHub

I'm using boot watch with my test runner to have it auto-rerun tests after files are saved, but it progressively gets slower with each run, about 1/3rd of a second each time. Is this expected or any kind of known issue?


@mattly there have been some issues with pods not being disposed properly resulting in a memory leak. What test runner are you using? I think @juhoteperi made boot-alt-test or so which does not use pods


ah, I'm using boot-test


Boot-alt-test uses a pod, but doesn't create a new pod each each test run like boot-test


So it is to be expected that boot-test can be slow with larger projects as it has to recompile even unchanged namespaces each time, but there shouldn't be reason why it gets slower each time


I'm trying to do some simple image resizing using this library,

(ns util.resize
    [image-resizer.core :as core]
    [image-resizer.format :as format]
    [ :as io])

(defn myresize []
      (io/file "sketch.png")
      100 100)
sketch.png is in my resources folder, specified like : (set-env! :resource-paths #{"rsc" "src"}) Invoking myresize froma task:
(deftask resize []
When I run boot resize, I get error:





               clojure.core/binding-conveyor-fn/fn                          core.clj: 1938
                                 boot.core/boot/fn                          core.clj: 1030

                         boot.core/construct-tasks                          core.clj:
                                clojure.core/apply                          core.clj:

                             boot.user/eval6228/fn  boot.user4743533291956162745.clj:
                              util.resize/myresize                        resize.clj:
                         image-resizer.core/resize                          core.clj:
                 image-resizer.resize/resize-fn/fn                        resize.clj:
                 image-resizer.util/buffered-image                          util.clj:

javax.imageio.IIOException: Can't read input file!
clojure.lang.ExceptionInfo: Can't read input file!
    file: "C:\\Users\\rigalo\\AppData\\Local\\Temp\\boot.user4743533291956162745.clj"

    line: 37
Any hints? Seems like the function does not see the file in my resource folder. Something to do with boot temp file structures? Do I need to explicitly use (target)? Thanks!


chromalchemy: if the file is in your resource path, you may need to use io/resource instead of io/file


@U0AHJUHJN That worked! Now I'm able to get though that part of function!


I'm still having trouble saving the resized image with given function:

(ns image-resizer.format
   [image-resizer.fs :as fs]
   [image-resizer.core :refer :all])
   [ File ByteArrayOutputStream ByteArrayInputStream]
   [java.awt.image BufferedImage]
   [javax.imageio ImageIO ImageWriter]))

(defn as-file [^BufferedImage buffered-file file-with-path & rest]
  (let [flags (into #{} rest)
        new-dimensions (dimensions buffered-file)
        file-name (if (contains? flags :verbatim)
                    (fs/new-filename file-with-path new-dimensions))
        file-ext (fs/extension file-name)
        resized-file (File. file-name)]
    (ImageIO/write buffered-file file-ext resized-file)
    (.getAbsolutePath resized-file)))


I noticed it used File internally


Is there a way to specify my boot config to play nice with the io/file function? Or do I need to re-write the function using io/resource to get this working with boot?


the thing about boot is that you're working with a temporary "fileset" that lives in an arbitrary directory somewhere


so io/file doesn't work because it needs to know the path to the file


io/resource works because it knows about anything in your resource path


you can still access the paths to files via .getAbsolutePath


i would guess that you need to use that earlier on to get the right path to where you're writing the file


Ok, to paraphrase: my resource folder is abstracted into the classpath by boot. io/resource knows what's in there, but io/file is looking for an absolute path. So I need to provide that path by inspecting a given resource file at compile-time.


This sounds a bit convoluted, there must be a way for io/file to see relative to boot folders, or for boot to provide environment variables to create path string as such...? I'll try it out though. Thanks for your help!


just a followup. io/resource is working to read the file. I can use the given library functions to write the files with a path like ./folder/file.png. I just need to figure out how to manage files better in the context of boot middleware so I can pass the fileset to other tasks.


thanks for the help though. I never would have figured that out in short term.


Hey. I have been looking through the boot docs.. but cannot find what I need. It (should) be pretty simple - so I thought I'd ask here. I would like to specify a dependency and give it an alias within my project. My use case, I have forked a library to fix a bug - and until that is merged back I have to stay with my fork. I do not want to update all of my code to "require" to forked version, id rather make my version accessible using the same name as the original.


@jamesmintram are you talking about the name of the clojure namespace you forked? or the library name? if you forked and have your own library (maven artifact name), there’s nothing to stop you from using the original namespace name


So I forked the repo and published it to clojars under my own account. Then updated the build.boot file to reference the new clojars dependency. So you are saying that should just work?


(Because I haven't made any changes to the code.. yet)


Ok thanks - that makes sense! I think I was confusing the artifact name with the namespaces it exports!


@jamesmintram np, and yup that’s the idea :thumbsup: