167 (interactive) |
167 (interactive) |
168 (shell-command |
168 (shell-command |
169 (format "%s dependency:tree" maven.command) |
169 (format "%s dependency:tree" maven.command) |
170 (switch-to-buffer maven.help-buffer-name)) ) |
170 (switch-to-buffer maven.help-buffer-name)) ) |
171 |
171 |
|
172 (defun maven.project-root () |
|
173 "Root of project." |
|
174 (let ( (dir default-directory) (found nil) ) |
|
175 (while (and (not found) (> (length dir) 5)) |
|
176 (when (file-exists-p (concat dir "/pom.xml")) |
|
177 (setq found dir)) |
|
178 (setq dir (expand-file-name (concat dir "/..")))) |
|
179 found)) |
|
180 |
|
181 (defun maven.file-package () |
|
182 "Return file package." |
|
183 (save-excursion |
|
184 (goto-char (point-min)) |
|
185 (let (pkg cls) |
|
186 (re-search-forward "package +\\([[:alnum:]_.]+\\) *;" nil t) |
|
187 (setq pkg (match-string-no-properties 1)) |
|
188 (re-search-forward "class +\\([[:alnum:]_]+\\)\s *" nil t) |
|
189 (setq cls (match-string-no-properties 1)) |
|
190 (when (and pkg cls) |
|
191 (concat pkg "." cls))) )) |
|
192 |
|
193 (defun maven.run-file () |
|
194 "Run exec:java for current file." |
|
195 (interactive) |
|
196 (let* ( (default-directory (concat (maven.project-root) "/")) ) |
|
197 (if (not default-directory) |
|
198 (message "Can't find maven project root") |
|
199 (compilation-start |
|
200 (format "%s exec:java -Dexec.mainClass=%s" maven.command (maven.file-package)))))) |
|
201 |
172 ;; (maven-central.last-version "junit" "junit") |
202 ;; (maven-central.last-version "junit" "junit") |
173 |
203 |
174 (provide 'maven-central) |
204 (provide 'maven-central) |
175 |
205 |
176 (provide 'maven-central) |
206 (provide 'maven-central) |