Skip to content

Gradle build automation utility

Zeioth edited this page May 7, 2024 · 19 revisions

When compiler.nvim detects one of the files gradlew, build.gradle.kts, or build.gradle file in the current working directory (by priority of detection), Telescope will be populated with all its task entries.

Hello world

Create a kotlin build.gradle.kts file in your working directory and copy/paste this:

// Example of a task
tasks.register("hello_world") {
    doLast {
        println("Hello, World!")
    }
}

// Example of a custom task to run all tasks
tasks.register("build_all") {
    dependsOn("hello_world")
}

Or this instead, if you are using a groovy build.gradle file:

// Example of a task
task hello_world {
    doLast {
        println 'Hello, World!'
    }
}

// Example of a custom task to run all tasks
task build_all {
    dependsOn hello_world
}

When you open the compiler you will see the option to run it screenshot_2023-11-13_23-36-37_628173599

And this is the result screenshot_2023-11-13_23-41-12_672880397

In the same way you can run hello world, you can execute any command necessary to build your program.

More info

(optionally) You can define the next globals

global defaut value
GRADLE_BUILD_TYPE ""

Example:

let g:GRADLE_BUILD_TYPE='release'

Globals persist between Neovim sessions.

FAQ

  • I can't see the tasks added by gradle plugins: We only parse the tasks defined in your gradle file, as specified above. We don't currently parse plugin tasks automatically. See #40.