All Downloads are FREE. Search and download functionalities are using the official Maven repository.

meyvn.nrepl_middleware.resources.clj Maven / Gradle / Ivy

The newest version!
(ns meyvn.nrepl-middleware.resources
  (:require [watch.man :refer [watch!]]
            [clojure.java.io :as io])
  (:import [org.apache.maven.shared.invoker DefaultInvoker DefaultInvocationRequest InvocationResult]))

(defn invoke-resources []
  (let [pom-file (io/file ".meyvn-pom.xml")
        invocation-request (doto (DefaultInvocationRequest.)
                             (.setPomFile pom-file)
                             (.setGoals ["process-resources"])
                             (.setBatchMode true))
        invoker (DefaultInvoker.)]
    (.execute invoker invocation-request)))

(defn resource-dirs []
  (let [resources (io/file "resources")
        dirs (file-seq resources)]
    (filter #(.isDirectory %) dirs)))

(defn start-watching []
  (let [dirs (resource-dirs)]
    (doseq [dir dirs
            :let [file (str dir)]]
      (watch! file (fn [event] (let [type (first (:types event))]
                                (when (= :modify type)
                                  (invoke-resources))))))))






© 2015 - 2024 Weber Informatics LLC | Privacy Policy