|
|
@ -7,7 +7,8 @@
|
|
|
|
; You must not remove this notice, or any other, from this software.
|
|
|
|
; You must not remove this notice, or any other, from this software.
|
|
|
|
|
|
|
|
|
|
|
|
(ns cryogen-core.classpath-able-io
|
|
|
|
(ns cryogen-core.classpath-able-io
|
|
|
|
(:require [cryogen-core.classpath-able-io.fs :as fs]
|
|
|
|
(:require [clojure.string :as st]
|
|
|
|
|
|
|
|
[cryogen-core.classpath-able-io.fs :as fs]
|
|
|
|
[cryogen-core.classpath-able-io.cp :as cp]
|
|
|
|
[cryogen-core.classpath-able-io.cp :as cp]
|
|
|
|
[cryogen-core.classpath-able-io.this :as this]
|
|
|
|
[cryogen-core.classpath-able-io.this :as this]
|
|
|
|
[schema.core :as s])
|
|
|
|
[schema.core :as s])
|
|
|
@ -21,10 +22,27 @@
|
|
|
|
(def JavaPath this/JavaPath) ; java.nio.Path
|
|
|
|
(def JavaPath this/JavaPath) ; java.nio.Path
|
|
|
|
(def Resource this/Resource)
|
|
|
|
(def Resource this/Resource)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn get-file-extension-from-resource
|
|
|
|
|
|
|
|
[resource]
|
|
|
|
|
|
|
|
(str "." (last (st/split (:virtual-path resource) #"\."))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn get-filename-from-resource
|
|
|
|
|
|
|
|
[resource]
|
|
|
|
|
|
|
|
(last (st/split (:virtual-path resource) #"\/")))
|
|
|
|
|
|
|
|
|
|
|
|
(defn filter-for-ignore-patterns
|
|
|
|
(defn filter-for-ignore-patterns
|
|
|
|
[ignore-patterns source-list]
|
|
|
|
[ignore-patterns source-list]
|
|
|
|
(filter #(not (re-matches ignore-patterns %)) source-list))
|
|
|
|
(filter #(not (re-matches ignore-patterns %)) source-list))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn filter-resources-for-ignore-patterns
|
|
|
|
|
|
|
|
[ignore-patterns resources]
|
|
|
|
|
|
|
|
(let [files (filter #(= (:resource-type %) :file) resources)
|
|
|
|
|
|
|
|
dirs (filter #(= (:resource-type %) :dir) resources)
|
|
|
|
|
|
|
|
filtered-files (filter
|
|
|
|
|
|
|
|
#(not (re-matches (re-pattern ignore-patterns) (get-filename-from-resource %)))
|
|
|
|
|
|
|
|
files)]
|
|
|
|
|
|
|
|
(concat dirs filtered-files)))
|
|
|
|
|
|
|
|
|
|
|
|
(defn resource-from-cp-or-fs ;:- Resource
|
|
|
|
(defn resource-from-cp-or-fs ;:- Resource
|
|
|
|
[fs-prefix ;:- Prefix
|
|
|
|
[fs-prefix ;:- Prefix
|
|
|
|
base-path ;:- VirtualPath
|
|
|
|
base-path ;:- VirtualPath
|
|
|
@ -106,7 +124,6 @@
|
|
|
|
(doseq [resource-path resource-paths]
|
|
|
|
(doseq [resource-path resource-paths]
|
|
|
|
(Files/delete (fs/absolut-path virtual-path resource-path))))))
|
|
|
|
(Files/delete (fs/absolut-path virtual-path resource-path))))))
|
|
|
|
|
|
|
|
|
|
|
|
; TODO: add ignore patterns filtering
|
|
|
|
|
|
|
|
(defn copy-resources!
|
|
|
|
(defn copy-resources!
|
|
|
|
[fs-prefix ;:- Prefix
|
|
|
|
[fs-prefix ;:- Prefix
|
|
|
|
base-path ;:- VirtualPath
|
|
|
|
base-path ;:- VirtualPath
|
|
|
@ -114,10 +131,8 @@
|
|
|
|
target-path ;:- VirtualPath
|
|
|
|
target-path ;:- VirtualPath
|
|
|
|
ignore-patterns ;:- s/Str
|
|
|
|
ignore-patterns ;:- s/Str
|
|
|
|
]
|
|
|
|
]
|
|
|
|
(let [resources
|
|
|
|
(let [resources (sort this/compare-resource (get-resources fs-prefix base-path source-paths))
|
|
|
|
(sort
|
|
|
|
resources (filter-resources-for-ignore-patterns ignore-patterns resources) ]
|
|
|
|
this/compare-resource
|
|
|
|
|
|
|
|
(get-resources fs-prefix base-path source-paths))]
|
|
|
|
|
|
|
|
(if (empty? resources)
|
|
|
|
(if (empty? resources)
|
|
|
|
(throw (IllegalArgumentException. (str "resource " base-path ", "
|
|
|
|
(throw (IllegalArgumentException. (str "resource " base-path ", "
|
|
|
|
source-paths " not found")))
|
|
|
|
source-paths " not found")))
|
|
|
|