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.
1 " Author: Michael Pardo <michael@michaelpardo.com>
2 " Description: Functions for working with Gradle projects.
4 let s:script_path = fnamemodify(resolve(expand('<sfile>:p')), ':h')
5 let s:init_path = has('win32')
6 \ ? s:script_path . '\gradle\init.gradle'
7 \ : s:script_path . '/gradle/init.gradle'
9 function! ale#gradle#GetInitPath() abort
13 " Given a buffer number, find a Gradle project root.
14 function! ale#gradle#FindProjectRoot(buffer) abort
15 let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew')
17 if !empty(l:gradlew_path)
18 return fnamemodify(l:gradlew_path, ':h')
21 let l:settings_path = ale#path#FindNearestFile(a:buffer, 'settings.gradle')
23 if !empty(l:settings_path)
24 return fnamemodify(l:settings_path, ':h')
27 let l:build_path = ale#path#FindNearestFile(a:buffer, 'build.gradle')
29 if !empty(l:build_path)
30 return fnamemodify(l:build_path, ':h')
36 " Given a buffer number, find the path to the executable.
37 " First search on the path for 'gradlew', if nothing is found, try the global
38 " command. Returns an empty string if cannot find the executable.
39 function! ale#gradle#FindExecutable(buffer) abort
40 let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew')
42 if !empty(l:gradlew_path)
46 if executable('gradle')
53 " Given a buffer number, get a working directory and command to print the
54 " classpath of the root project.
56 " Returns an empty string for the command if Gradle is not detected.
57 function! ale#gradle#BuildClasspathCommand(buffer) abort
58 let l:executable = ale#gradle#FindExecutable(a:buffer)
60 if !empty(l:executable)
61 let l:project_root = ale#gradle#FindProjectRoot(a:buffer)
63 if !empty(l:project_root)
66 \ ale#Escape(l:executable)
67 \ . ' -I ' . ale#Escape(s:init_path)
68 \ . ' -q printClasspath'