]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/autoload/ale/maven.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / autoload / ale / maven.vim
1 " Description: Functions for working with Maven projects.
2 "
3 " Given a buffer number, find a Maven project root.
4 function! ale#maven#FindProjectRoot(buffer) abort
5     let l:wrapper_path = ale#path#FindNearestFile(a:buffer, 'mvnw')
6
7     if !empty(l:wrapper_path)
8         return fnamemodify(l:wrapper_path, ':h')
9     endif
10
11     let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
12
13     if !empty(l:pom_path)
14         return fnamemodify(l:pom_path, ':h')
15     endif
16
17     return ''
18 endfunction
19
20 " Given a buffer number, find the path to the executable.
21 " First search on the path for 'mvnw' (mvnw.cmd on Windows), if nothing is found,
22 " try the global command. Returns an empty string if cannot find the executable.
23 function! ale#maven#FindExecutable(buffer) abort
24     let l:wrapper_cmd = has('unix') ? 'mvnw' : 'mvnw.cmd'
25     let l:wrapper_path = ale#path#FindNearestFile(a:buffer, l:wrapper_cmd)
26
27     if !empty(l:wrapper_path) && executable(l:wrapper_path)
28         return l:wrapper_path
29     endif
30
31     if executable('mvn')
32         return 'mvn'
33     endif
34
35     return ''
36 endfunction
37
38 " Given a buffer number, get a working directory and command to print the
39 " classpath of the root project.
40 "
41 " Returns an empty string for the command if Maven is not detected.
42 function! ale#maven#BuildClasspathCommand(buffer) abort
43     let l:executable = ale#maven#FindExecutable(a:buffer)
44
45     if !empty(l:executable)
46         let l:project_root = ale#maven#FindProjectRoot(a:buffer)
47
48         if !empty(l:project_root)
49             return [
50             \   l:project_root,
51             \   ale#Escape(l:executable) . ' dependency:build-classpath'
52             \]
53         endif
54     endif
55
56     return ['', '']
57 endfunction