0
votes

I deployed a project to Clojars the other day in order to be able to effortlessly use it as a dependency in other projects. Today I tried to use it and it broke saying it wasn't able to find a file (let's call it grammar.ebnf). This is a file describing a grammar that is then slurped up in one of my Clojure modules. I made it as a separate file just to separate the grammar from the logic using the grammar. I located it in the same directory as the other source files

Clearly it's not being included in the deployment to Clojars. How do I make sure that this file gets included alongside the .clj files when I deploy using lein deploy clojars?

EDIT: See comments below

1
@AlanThompson Yeah what ended up helping was a resources directory as you suggested, pointing to it with resource-paths in project.clj, and then accessing the resources like this stackoverflow.com/a/32237723/353715 - TomLisankie

1 Answers

0
votes

Please see this template project. What you need is to make a ./resources directory, and place files inside of it. These files will be included on the classpath of your project, running either locally or after creating a JAR file.

For example, we can make a file resources/stuff.txt

> echo "happens" > resources/stuff.txt

and access it like:

(ns tst.demo.core
  (:use tupelo.core tupelo.test)
  (:require
    [clojure.java.io :as io]
    [clojure.string :as str]))

(dotest
  (is= (str/trim (slurp (io/resource "stuff.txt")))
    "happens"))

with result

    > lein clean; lein test
    
    ------------------------------------------
       Clojure 1.10.2-alpha1    Java 14.0.1
    ------------------------------------------
    
    Testing tst.demo.core
    
    Ran 2 tests containing 1 assertions.
    0 failures, 0 errors.