Remove old versions of plugins at plugin install time. Fixes #301.
This won't fix duplicate plugins that have already been installed unfortunately, but it'll fix it going forward.
This commit is contained in:
parent
51f76dfa24
commit
29ca3564f7
3 changed files with 23 additions and 18 deletions
|
@ -21,14 +21,34 @@
|
|||
(defn extract-name-and-group [project-name]
|
||||
((juxt name namespace) (symbol project-name)))
|
||||
|
||||
(defn uninstall
|
||||
"Delete the plugin jarfile
|
||||
Syntax: lein plugin uninstall [GROUP/]ARTIFACT-ID VERSION"
|
||||
[project-name version]
|
||||
(let [[name group] (extract-name-and-group project-name)
|
||||
jarfile (file plugins-path
|
||||
(plugin-standalone-filename group name version))]
|
||||
(if (.exists jarfile)
|
||||
(if (.delete jarfile)
|
||||
(println (format "Uninstalled %s %s." project-name version))
|
||||
(abort (format "Failed to delete \"%s\"." (.getAbsolutePath jarfile))))
|
||||
(abort (format "Plugin \"%s %s\" doesn't appear to be installed."
|
||||
project-name version)))))
|
||||
|
||||
(defn- uninstall-old [project-name]
|
||||
(doseq [plugin (.list plugins-path)
|
||||
:let [pat (re-pattern (format "^\\Q%s\\E-.*\\.jar$" project-name))]
|
||||
:when (re-find pat plugin)]
|
||||
(.delete (file plugins-path plugin))))
|
||||
|
||||
;; TODO: extract shared behavior between this and the install task
|
||||
(defn install
|
||||
"Download, package, and install plugin jarfile into
|
||||
~/.lein/plugins
|
||||
"Download, package, and install plugin jarfile into ~/.lein/plugins
|
||||
Syntax: lein plugin install [GROUP/]ARTIFACT-ID VERSION
|
||||
You can use the same syntax here as when listing Leiningen
|
||||
dependencies."
|
||||
[project-name version]
|
||||
(uninstall-old project-name)
|
||||
(leiningen.install/install project-name version)
|
||||
(.mkdirs plugins-path)
|
||||
(let [[name group] (extract-name-and-group project-name)
|
||||
|
@ -50,20 +70,6 @@ Syntax: lein plugin install [GROUP/]ARTIFACT-ID VERSION
|
|||
(delete-file-recursively temp-project)
|
||||
(println "Created" standalone-filename)))
|
||||
|
||||
(defn uninstall
|
||||
"Delete the plugin jarfile
|
||||
Syntax: lein plugin uninstall [GROUP/]ARTIFACT-ID VERSION"
|
||||
[project-name version]
|
||||
(let [[name group] (extract-name-and-group project-name)
|
||||
jarfile (file plugins-path
|
||||
(plugin-standalone-filename group name version))]
|
||||
(if (.exists jarfile)
|
||||
(if (.delete jarfile)
|
||||
(println (format "Uninstalled %s %s." project-name version))
|
||||
(abort (format "Failed to delete \"%s\"." (.getAbsolutePath jarfile))))
|
||||
(abort (format "Plugin \"%s %s\" doesn't appear to be installed."
|
||||
project-name version)))))
|
||||
|
||||
(defn ^{:doc "Manage user-level plugins."
|
||||
:help-arglists '([subtask project-name version])
|
||||
:subtasks [#'install #'uninstall]}
|
||||
|
|
|
@ -83,7 +83,7 @@ indices.
|
|||
|
||||
The query is evaluated as a lucene search. You can search for simple
|
||||
string matches or do more advanced queries such as this
|
||||
'lein \"clojure AND http AND NOT g:org.clojars*\"'
|
||||
'lein search \"clojure AND http AND NOT g:org.clojars*\"'
|
||||
|
||||
Also accepts a second parameter for fetching successive
|
||||
pages."
|
||||
|
|
1
todo.org
1
todo.org
|
@ -39,7 +39,6 @@ See also https://github.com/technomancy/leiningen/issues
|
|||
- [ ] windows issues with plugin install swank (#252)
|
||||
- [ ] non-jar deps on classpath (#244)
|
||||
- [ ] use java class for :main (#249)
|
||||
- [ ] self-install in current directory (#254)
|
||||
* For 1.6.1
|
||||
- [X] upgrade hooke
|
||||
- [X] make it easier to use :repl-options [:print clojure.pprint/pprint]
|
||||
|
|
Loading…
Reference in a new issue