1 | ;; Maven 2 utilities |
2 | ;; |
3 | ;; |
4 | ;; |
5 | ;; (map :name (mvn-plugins)) |
6 |
|
7 | ;; => ("clean" "compiler" "deploy" "install" "resources" "site" |
8 | ;; "surefire" "verifier" "ear" "ejb" "jar" "rar" "war" "shade" |
9 | ;; "changelog" "changes" "checkstyle" "clover" "doap" "docck" |
10 | ;; "javadoc" "jxr" "pmd" "project-info-reports" "surefire-report" |
11 | ;; "ant" "antrun" "archetype" "assembly" "dependency" "enforcer" "gpg" |
12 | ;; "help" "invoker" "one" "patch" "plugin" "release" "reactor" |
13 | ;; "remote-resources" "repository" "scm" "source" "stage" "eclipse" |
14 | ;; "idea") |
15 |
|
16 | ;; |
17 | ;; (map :name (mvn-plugin-goals "release")) |
18 | ;; => ("release:branch" "release:clean" "release:help" "release:perform" |
19 | ;; "release:prepare" "release:rollback" "release:stage") |
20 | ;; |
21 | ;;;; (map :name (mvn-plugin-goals "dependency")) |
22 | ;; (filter #(.contains (:name %) "copy") (mvn-plugin-goals "dependency")) |
23 |
|
24 | (ns com.github.kyleburton.sandbox.mvn |
25 | (:require [com.github.kyleburton.sandbox.utils :as kutils] |
26 | [com.github.kyleburton.sandbox.landmark-parser :as lparse] |
27 | [com.github.kyleburton.sandbox.web :as web] |
28 | [clojure.contrib.duck-streams :as ds] |
29 | [clojure.contrib.str-utils :as str]) |
30 | (:use [com.github.kyleburton.sandbox.memoize :only [def-once-only]])) |
31 |
|
32 | (def *mvn-plugins-url* "http://maven.apache.org/plugins/") |
33 |
|
34 | (def-once-only mvn-plugins-html [& [url]] |
35 | (web/get->string (or url *mvn-plugins-url*))) |
36 |
|
37 | (def-once-only mvn-plugins-grid [] |
38 | (filter #(and (not (empty? %)) (.contains (nth % 0) "href")) |
39 | (lparse/html-table->matrix |
40 | (first |
41 | (filter |
42 | ;; NB: this hard-coded string might go away at some point... |
43 | #(.contains % "Clean up after the build.") |
44 | (lparse/html->tables (mvn-plugins-html))))))) |
45 |
|
46 | (def-once-only mvn-plugins [] |
47 | (map (fn [row] |
48 | { |
49 | :name (.trim (web/strip-html (nth row 0))) |
50 | :url (first (lparse/html->links (nth row 0))) |
51 | :version (nth row 1) |
52 | :release-date (nth row 2) |
53 | :description (nth row 3) |
54 | :source-repo (first (lparse/html->links (nth row 4))) |
55 | :issue-tracking (first (lparse/html->links (nth row 5))) |
56 | }) |
57 | (mvn-plugins-grid))) |
58 |
|
59 | ;; (map :name (mvn-plugins)) |
60 |
|
61 | (defn mvn-plugin-goals [plugin-name] |
62 | (let [entry (first (filter #(= plugin-name (:name %)) |
63 | (mvn-plugins))) |
64 | url (str "http://maven.apache.org" (:url entry)) |
65 | plugin-page (web/memoized-get->string url) |
66 | goal-url (str url (lparse/html-find-link-with-body plugin-page "Goal")) |
67 | goal-page (web/memoized-get->string goal-url) |
68 | goal-table (drop 1 (lparse/html-table->matrix |
69 | (first (filter #(.contains % "Goal") |
70 | (lparse/html->tables goal-page)))))] |
71 | (map (fn [row] |
72 | { |
73 | :name (.trim (web/strip-html (nth row 0))) |
74 | :url (first (lparse/html->links (nth row 0))) |
75 | :plugin-url goal-url |
76 | :description (nth row 1);(web/html-decode (nth row 1)) |
77 | }) |
78 | goal-table))) |
79 |
|
80 | ;; (filter (mvn-plugin-goals "dependency")) |
81 | ;; (map :plugin-url (mvn-plugin-goals "dependency")) |
82 | ;; (filter #(.contains (:name %) "dependency") (mvn-plugins)) |