Skip to content

Commit

Permalink
(PE-37713) Remove useless copy of additional directory to resources dir
Browse files Browse the repository at this point in the history
  • Loading branch information
rileynewton committed Jun 11, 2024
1 parent 4ea92de commit 35de5ab
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
## [Unreleased]

## [2.6.1]
* Complete the ability to add a resources directory to a project with :include-dir by copying the resources to the staging directory.
* Fix the ability to add a resources directory to a project with :include-dir by copying the resources to the staging directory directly.

## [2.6.0]
* Add the ability to add a directory for project resources (such as build templates) by specifying the :include-dir option under {:lein-ezbake {:resources :include-dir "resources"}}.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ configuration necessary.
:resources {

; The resources type indicates where lein-ezbake gets resources from.
; With the :jar type resources can be copied from the jars composed with lein-ezbake. The :include-dir option allows a project to specify an additional resource directory as well. This is useful where a project needs to specify resources outside of what is included in the jars. When specified, the :include-dir resources will replace files from the included jars of the same name.
; Future versions of lein-ezbake may support pulling these resources from a
; With the :jar type resources can be copied from the jars composed with
; lein-ezbake. The :include-dir option allows a project to specify an additional
; resource directory as well. This is useful where a project needs to specify
; resources outside of what is included in the jars. When specified, the
; :include-dir resources will replace files from the included jars of the same
; name. Future versions of lein-ezbake may support pulling these resources from a
; specific version of some git repository.
:type :jar
;; optionally specify a directory path in the project to include resources from
Expand Down
27 changes: 2 additions & 25 deletions src/leiningen/ezbake_core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@
jar-file-path resource-path))
(deputils/cp-files-from-jar jar-entries jar-file resource-path)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Resource Directory Type Helpers
(defn copy-dir [src-dir dest-dir]
(let [src (io/file src-dir)
dest (io/file dest-dir)]
(if (.exists src)
(if (.isDirectory src)
(do
(.mkdirs dest)
(doseq [file (.listFiles src)]
(copy-dir (.getPath file) (str (io/file dest (.getName file))))))
(do
(lein-main/info (format "Copying lein-ezbake resources from included directory: %s to %s."
src-dir dest-dir))
(io/copy src dest)))
(throw (RuntimeException. (format "Resource directory %s does not exist." (str src-dir)))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Consumable API

Expand All @@ -63,15 +46,9 @@
(let [template-type (get-in project [:lein-ezbake
:resources
:type]
:jar)
include-resource-dir (get-in project [:lein-ezbake
:resources
:include-dir]
nil)]
:jar)]
(case template-type
:git (throw (RuntimeException.
(format "Resource type, %s, not implemented."
(str template-type))))
:jar (copy-jar-resources core/resource-prefix core/resource-path))
(when (some? include-resource-dir)
(copy-dir include-resource-dir core/resource-path))))
:jar (copy-jar-resources core/resource-prefix core/resource-path))))
2 changes: 1 addition & 1 deletion src/puppetlabs/ezbake/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ Additional uberjar dependencies:
(cp-doc-files lein-project)
(when additional-uberjar-info
(copy-additional-uberjars! additional-uberjar-info))
;; if :include-dir is specified, copy directory's files into staging
;; if :include-dir is specified, copy directory's resource files into staging
(when (some? include-resources-dir)
(deputils/copy-files-to-dir (get-bin-files-in-directory include-resources-dir) staging-dir include-resources-dir)
(deputils/copy-files-to-dir (get-build-scripts-files-in-directory include-resources-dir) staging-dir include-resources-dir)
Expand Down
2 changes: 1 addition & 1 deletion src/puppetlabs/ezbake/dependency_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@

(defn copy-files-to-dir
"Given a sequence of java.io.File, a destination path to copy to, copy all files including directory
structure except the directory, specified by exclude-dir-prefix."
structure except the directory specified by exclude-dir-prefix."
[file-seq dest-dir exclude-dir-prefix]
{:pre [(seq? file-seq) (string? dest-dir)]}
(let [dest (io/file dest-dir)]
Expand Down

0 comments on commit 35de5ab

Please sign in to comment.