diff --git a/README.md b/README.md index 8fa13f0..f182db9 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,6 @@ verbose: false ## Future improvements -* Make 'glue' paths in the config relative to the configuration file. * Generics support * Plain, adapter-less injections * Plug-in system diff --git a/src-java/test/bind.config b/src-java/test/bind.config index 6d15846..d0f6d45 100644 --- a/src-java/test/bind.config +++ b/src-java/test/bind.config @@ -1,7 +1,7 @@ This is a test configuration file. Below, the gluer files are specified. The paths to these files are relative to this configuration file. -glue: src-java/test/bind.gluer +glue: bind.gluer Other options can be specified as well. diff --git a/src/gluer/agent.clj b/src/gluer/agent.clj index 4738f12..c27b5b6 100644 --- a/src/gluer/agent.clj +++ b/src/gluer/agent.clj @@ -12,6 +12,7 @@ [gluer.resources :as r] [gluer.runtime :as runtime] [gluer.config :as c] + [gluer.core :as core] [clojure.string :as s]) (:use [gluer.clauses] [gluer.logging]) @@ -97,7 +98,7 @@ (with-redefs [*verbose* (:verbose config)] (log-verbose "Parsing .gluer files and searching for Adapters...") ;; Parse the files and check for parse errors. - (let [parsed (r/parse-gluer-files (:glue config)) + (let [parsed (r/parse-gluer-files (core/absolutise agent-args (:glue config))) erroneous (filter (comp :error :parsed) parsed)] (if (not (empty? erroneous)) (do (doseq [error erroneous] diff --git a/src/gluer/core.clj b/src/gluer/core.clj index 3cf3012..c1ca6c4 100644 --- a/src/gluer/core.clj +++ b/src/gluer/core.clj @@ -92,6 +92,16 @@ (catch InterruptedException ex (println "Errors detected. Fix above errors and re-run the check.")))) + +;;; Helper functions. + +(defn absolutise ;--- Move this to a utility namespace? + [root-file file-names] + (let [root-url (java.net.URL. (str "file:" root-file))] + (for [file-name file-names] + (.getFile (java.net.URL. root-url file-name))))) + + ;;; The main entry point. (defn -main ;--- Maybe reading a JAR file containing .config, .gluer and Adapters is also nice? @@ -104,6 +114,6 @@ (if-let [config (try (c/read-config (slurp config-file-name)) (catch java.io.IOException ioe))] (with-redefs [*verbose* (or verbose (and (nil? verbose) (:verbose config)))] - (check (:glue config))) + (check (absolutise config-file-name (:glue config)))) (println "Could not find or open file:" config-file-name)) (display-help-text banner)))))