<commit_before>(def +version+ "0.5.0")

(set-env!
  :resource-paths #{"src" "boot-less/src" "lein-less4j/src"}
  :source-paths #{"test" "test-resources"}
  :dependencies   '[[org.clojure/clojure "1.7.0" :scope "provided"]
                    [boot/core "2.5.2" :scope "provided"]
                    [adzerk/boot-test "1.0.7" :scope "test"]
                    ;; Webjars-locator uses logging
                    [org.slf4j/slf4j-nop "1.7.12" :scope "test"]

                    [com.github.sommeri/less4j "1.15.4"]
                    [com.github.sommeri/less4j-javascript "0.0.1" :exclusions [com.github.sommeri/less4j]]
                    [org.webjars/webjars-locator "0.29"]

                    ;; For testing the webjars asset locator implementation
                    [org.webjars/bootstrap "3.3.6" :scope "test"]])

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

(task-options!
  pom {:version     +version+
       :url         "https://github.com/deraen/less4clj"
       :scm         {:url "https://github.com/deraen/less4clj"}
       :license     {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}})

(defn with-files
  "Runs middleware with filtered fileset and merges the result back into complete fileset."
  [p middleware]
  (fn [next-handler]
    (fn [fileset]
      (let [merge-fileset-handler (fn [fileset']
                                    (next-handler (commit! (assoc fileset :tree (merge (:tree fileset) (:tree fileset'))))))
            handler (middleware merge-fileset-handler)
            fileset (assoc fileset :tree (reduce-kv
                                          (fn [tree path x]
                                            (if (p x)
                                              (assoc tree path x)
                                              tree))
                                          (empty (:tree fileset))
                                          (:tree fileset)))]
        (handler fileset)))))

(deftask write-version-file
  [n namespace NAMESPACE sym "Namespace"]
  (let [d (tmp-dir!)]
    (fn [next-handler]
      (fn [fileset]
        (let [f (clojure.java.io/file d (-> (name namespace)
                                            (clojure.string/replace #"\." "/")
                                            (clojure.string/replace #"-" "_")
                                            (str ".clj")))]
          (clojure.java.io/make-parents f)
          (spit f (format "(ns %s)\n\n(def +version+ \"%s\")" (name namespace) +version+)))
        (next-handler (-> fileset (add-resource d) commit!))))))

(deftask build []
  (comp
   (with-files
    (fn [x] (re-find #"less4clj" (tmp-path x)))
    (comp
     (pom
      :project 'deraen/less4clj
      :description "Clojure wrapper for Less4j.")
     (jar)
     (install)))

   (with-files
    (fn [x] (re-find #"boot_less" (tmp-path x)))
    (comp
     (pom
      :project 'deraen/boot-less
      :description "Boot task to compile {less}"
      :dependencies [])
     (write-version-file :namespace 'deraen.boot-less.version)
     (jar)
     (install)))

   (with-files
    (fn [x] (re-find #"less4j" (tmp-path x)))
    (comp
     (pom
      :project 'deraen/lein-less4j
      :description "Leinigen task to compile {less}"
      :dependencies [])
     (write-version-file :namespace 'leiningen.less4j.version)<commit_msg>Simplify lein artifact filter<commit_after>(def +version+ "0.5.0")

(set-env!
  :resource-paths #{"src" "boot-less/src" "lein-less4j/src"}
  :source-paths #{"test" "test-resources"}
  :dependencies   '[[org.clojure/clojure "1.7.0" :scope "provided"]
                    [boot/core "2.5.2" :scope "provided"]
                    [adzerk/boot-test "1.0.7" :scope "test"]
                    ;; Webjars-locator uses logging
                    [org.slf4j/slf4j-nop "1.7.12" :scope "test"]

                    [com.github.sommeri/less4j "1.15.4"]
                    [com.github.sommeri/less4j-javascript "0.0.1" :exclusions [com.github.sommeri/less4j]]
                    [org.webjars/webjars-locator "0.29"]

                    ;; For testing the webjars asset locator implementation
                    [org.webjars/bootstrap "3.3.6" :scope "test"]])

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

(task-options!
  pom {:version     +version+
       :url         "https://github.com/deraen/less4clj"
       :scm         {:url "https://github.com/deraen/less4clj"}
       :license     {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}})

(defn with-files
  "Runs middleware with filtered fileset and merges the result back into complete fileset."
  [p middleware]
  (fn [next-handler]
    (fn [fileset]
      (let [merge-fileset-handler (fn [fileset']
                                    (next-handler (commit! (assoc fileset :tree (merge (:tree fileset) (:tree fileset'))))))
            handler (middleware merge-fileset-handler)
            fileset (assoc fileset :tree (reduce-kv
                                          (fn [tree path x]
                                            (if (p x)
                                              (assoc tree path x)
                                              tree))
                                          (empty (:tree fileset))
                                          (:tree fileset)))]
        (handler fileset)))))

(deftask write-version-file
  [n namespace NAMESPACE sym "Namespace"]
  (let [d (tmp-dir!)]
    (fn [next-handler]
      (fn [fileset]
        (let [f (clojure.java.io/file d (-> (name namespace)
                                            (clojure.string/replace #"\." "/")
                                            (clojure.string/replace #"-" "_")
                                            (str ".clj")))]
          (clojure.java.io/make-parents f)
          (spit f (format "(ns %s)\n\n(def +version+ \"%s\")" (name namespace) +version+)))
        (next-handler (-> fileset (add-resource d) commit!))))))

(deftask build []
  (comp
   (with-files
    (fn [x] (re-find #"less4clj" (tmp-path x)))
    (comp
     (pom
      :project 'deraen/less4clj
      :description "Clojure wrapper for Less4j.")
     (jar)
     (install)))

   (with-files
    (fn [x] (re-find #"boot_less" (tmp-path x)))
    (comp
     (pom
      :project 'deraen/boot-less
      :description "Boot task to compile {less}"
      :dependencies [])
     (write-version-file :namespace 'deraen.boot-less.version)
     (jar)
     (install)))

   (with-files
    (fn [x] (re-find #"leiningen" (tmp-path x)))
    (comp
     (pom
      :project 'deraen/lein-less4j
      :description "Leinigen task to compile {less}"
      :dependencies [])
     (write-version-file :namespace 'leiningen.less4j.version)
{'fraction_non_alphanumeric': 0.14729950900163666, 'fraction_numerical': 0.013242077071864306, 'mean_word_length': 1.62578125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3971673', 'n_tokens_mistral': 2160, 'n_tokens_neox': 2083, 'n_words': 474}