Skip to content

Commit

Permalink
Use Leiningen's built-in support for Java agents and simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
qerub committed May 5, 2014
1 parent b49e778 commit bca1e66
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lein-nodisassemble/src/lein_nodisassemble/plugin.clj
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
(ns lein-nodisassemble.plugin
(:require [leiningen.core.classpath :as cp]))
(ns lein-nodisassemble.plugin)

(defn get-version
[project]
(let [[_ version] (first (filter #(re-matches #".*lein-nodisassemble.*" (str (first %)))
(:plugins project)))]
version))

(defn find-dep
[project]
(->> (cp/resolve-dependencies :dependencies project)
(filter #(re-find #".*nodisassemble.*" (.getName %)))
first))

(defn middleware [project]
(let [version (get-version project)
project (update-in project [:dependencies] conj ['nodisassemble version])
path (-> (find-dep project) .toURI .getPath)]
(update-in project [:jvm-opts] conj (str "-javaagent:" path))))
(let [version (get-version project)]
(-> project
(update-in [:dependencies] conj ['nodisassemble version])
(update-in [:java-agents] conj ['nodisassemble version]))))

2 comments on commit bca1e66

@gtrak
Copy link

@gtrak gtrak commented on bca1e66 May 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, neat. I'll test it out soon. Curious if it affects gtrak#2.

@qerub
Copy link
Owner Author

@qerub qerub commented on bca1e66 May 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if it affects gtrak#2.

I already checked and no, it doesn't. :(

So this is purely cosmetic.

Please sign in to comment.