Create, compile and manage your Gradle projects without leaving vim!
Plug 'hdiniz/vim-gradle'
The plugin will use your project's Gradle wrapper or fallback to a Gradle installation.
Some commands (:GradleInit [args]
, :GradleWrapper [args]
) will require a Gradle installation.
By default, you Gradle project will be loaded you open vim under a Gradle project. See |autoload|.
When the project is detected, the :Gradle <args>
command becomes available:
:Gradle compile
Erros detected during built populate vim's quickfix window:
:copen
Compiles the project passing {args} to the Gradle binary. The build is started asynchronously and the output is redirected to a output window.
quickfix
errors are provided by the Gradle init script.
Manually loads the Gradle project based on current buffer or current directory. Use when autoloading is disabled. See g:vim_gradle_autoload
*Requires Gradle installation
Runs gradle init {args}
on current directory.
*Requires Gradle installation
Runs gradle wrapper {args}
on current directory.
Default: 1
When a new buffer is open search 'build.gradle' and 'build.gradle.kts' files up on the directory tree.
If disabled, projects can be loaded via :GradleLoad.
Default: 1
Allows vim-gradle to load additional gradle init script from vim-gradle extensions.
Default: ''
Absolute path to the Gradle binary. Used for out-of-project commands and projects without a Gradle Wrapper. Overrides |g:vim_gradle_home| and $GRADLE_HOME.
Default: ''
Absolute path to a Gradle installation. Used for out-of-project commands and projects without a Gradle Wrapper. Overrides $GRADLE_HOME.
TODO: support airline parts on project files and compilation window
Extensions can hook into Gradle init scripts by defining the function:
[plugin]/autoload/gradle/extensions/{extension_name}.vim
let s:gradle_folder_path = escape( expand( '<sfile>:p:h:h:h:h' ), '\' ) . '/gradle/'
function! gradle#extensions#{extension_name}#build_scripts()
return [s:gradle_folder_path . 'extension_name.gradle']
endfunction
This can be used to define custom tasks and plugins on the project. The references scripts will load after the rootProject has been evaluated.
def errorListener = {
def match = it =~ /([^:]+):(\d+):(\d*) (?:(e)rror|(w)arning): (.+)/
if (match.size() > 0) {
// Log to vim temp file
vimLog("javac quickfix: $it")
// Populate vim quickfix (type, file, line, column, message)
vimQuickfix(match[0][5], match[0][1], match[0][2], match[0][3], match[0][6])
}
} as StandardOutputListener
allprojects { project ->
project.afterEvaluate {
tasks.withType(JavaCompile).each {
// Enable javac lint options
it.options.compilerArgs << "-Xlint:all"
// Capture javac stderr
it.logging.addStandardErrorListener(errorListener)
}
}
}
MIT