How to specify the compile time path of boot build tool?

I’m trying to compile some code with macros that require external resources at both compile time & runtime.

For example:

├── build.boot
├── doc
│   └──
├── resources
│   └── String.g4
├── src
│   └── antlr_test
│       └── core.clj
└── test
    └── antlr_test
        └── core_test.clj

6 directories, 8 files

Here’s my project directory. The String.g4 is required for both compiling and running. if I run boot build under the root dir, it will complain that “String.g4” is not found when expanding the macros.

I’ve tired to solve this by copy String.g4 to the root dir of the project and it works, but it might not be the best solution.

I’ll be glad if you could tell me a better solution.

Thanks a lot!

1 Like

Are you setting the :resource-path in your build.boot file?

For example, assuming you are calling set-env! already:

  :resource-paths #{"resources"}

Yeah, I’m using the one generated by the boot template:

(def project 'antlr-test)
(def version "0.1.0-SNAPSHOT")

(set-env! :resource-paths #{"resources" "src"}
          :source-paths   #{"test"}
          :dependencies   '[[org.clojure/clojure "RELEASE"]
                            [clj-antlr "0.2.9"]
                            [adzerk/boot-test "RELEASE" :scope "test"]])

 aot {:namespace   #{'antlr-test.core}}
 pom {:project     project
      :version     version
      :description "FIXME: write description"
      :url         "http://example/FIXME"
      :scm         {:url ""}
      :license     {"Eclipse Public License"
 repl {:init-ns    'antlr-test.core}
 jar {:main        'antlr-test.core
      :file        (str "antlr-test-" version "-standalone.jar")})

(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))))

(deftask run
  "Run the project."
  [a args ARG [str] "the arguments for the application."]
  (with-pass-thru fs
    (require '[antlr-test.core :as app])
    (apply (resolve 'app/-main) args)))

(require '[adzerk.boot-test :refer [test]])

Also, here’s the source code. What I’m trying to do is to test the clj-antlr library.

(ns antlr-test.core
  (:require [clj-antlr.core :as antlr]))

(def grammar (antlr/parser "./String.g4"))
(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (println "Hello, World!")
  (let [input (slurp "input.txt")]
    (prn input)
    (prn (grammar input))))

If you move String.g4 into the resources directory, you should be able to access it via

This works fine, thanks a lot!