[GRADLE-1069] Provide bash completion support Created: 28/Jul/10 Updated: 23/Jan/17 Resolved: 23/Jan/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | ||
Reporter: | Chris Beams | Assignee: | Eric Wendelin |
Resolution: | Fixed | Votes: | 29 |
Description |
Ideally, a user should be able to type gradle <Tab><Tab> and see a list of available
gradle :projA:<Tab><Tab> would list tasks available in projA ... and so on. This information is perhaps difficult to create because of Gradle's dynamic nature, but with the advent of the Gradle Daemon forthcoming in 0.9.1, this information should be queryable with great speed (especially if the Gradle model caching gets implemented). |
Comments |
Comment by Chris Beams [ 28/Jul/10 ] |
A huge bonus would be supporting gradle -D<Tab><Tab> To see what properties are available to be set. For example, a user may not know about or remember the name for the -Dtest.single property (see |
Comment by Hans Dockter [ 28/Jul/10 ] |
Fully agree. Although we see the -Dtest.single as a temporary solution anyway (which will continue to work!). To have more consistency we want to provide a generic mechanism to configure tasks via the command line by their API. Completion would still be awesome to have. But at least you don't have magic props any more. And using the API should also make it easier to provide a generic way to provide tab completion. |
Comment by Adam Murdoch [ 28/Jul/10 ] |
Excellent ideas. The GUI should make all this stuff discoverable too, and also provide auto-completion in the command text box. |
Comment by Ingo Fischer [ 24/Jan/12 ] |
I'm currently building a Bash completion for Gradle, I'll send a Pull request as soon as I'm finished. Currently I'm trying to get all available tasks. As I don't know Gradle internals yet, my current approach is to extract the tasks with a Regex from the output of gradle tasks , but of course that's an ugly way. Is there a way to get all available tasks programmatically by using some kind of Gradle API? |
Comment by Adam Murdoch [ 24/Jan/12 ] |
@Ingo, you should use the tooling API: http://gradle.org/docs/nightly/userguide/embedding.html |
Comment by Chris Beams [ 25/Jan/12 ] |
@Ingo - glad to hear you're working on this. Good luck. @Adam, I would hope that any such solution could communicate with the Gradle daemon (if one is running). Is that implied in your comment about the tooling API? Is there any precedent yet for a non-gradle process communicating with the daemon? It's the only way I can imagine getting snappy performance out of the autocompletion process. |
Comment by Ingo Fischer [ 25/Jan/12 ] |
@Chris thanks! I have been thinking a lot about performance of the completion. My approach is to implement a small caching-mechanism for the completion. |
Comment by Chris Beams [ 25/Jan/12 ] |
Yeah, the trouble is that it's hard to know "when the buildfile changed", as there could be any number of buildfiles having any variety of names, especially in a multi-project build. The need for a caching mechanism is obvious; I would suggest the Daemon is the natural place to do it as it has the opportunity to know everything already and be quite up-to-date when the autocompletion script queries it. Should be a perfect kind of service interface for you to get what you need without unnecessary hacks. It's probably good timing for this too, given that the daemon will soon be out of it's 'experimental phase' (or so that's my understanding). This means that it's probably quite reasonable to expect that it already exists, or to trigger it's creation in the background. Adam may have more input here... In any case, even if you start out with something quick and dirty for caching, you'll be able to flesh out the actual autocompletion code in bash. I'd love to give it a try when you have something working! |
Comment by Adam Murdoch [ 26/Jan/12 ] |
@Chris, the tooling API uses the daemon. However, there are a few things that aren't quite right for the purposes of command-line completion:
@Ingo, it would be much better if the caching and change detection happened in the tooling API or daemon, for a couple of reasons:
I'd suggest first just using the tooling API as is. It will do the job, but may not be super performant. Then, make it performant by improving the tooling API implementation, eg introducing caching. |
Comment by Ingo Fischer [ 27/Jan/12 ] |
@Adam: Makes sense to move caching to the daemon and just let the bash completion script use the tooling API as is. I'm really curious how such a C daemon client looks like, I don't have any experiences with C->Java interaction yet. Would you mind publishing the sources? |
Comment by Adam Murdoch [ 27/Jan/12 ] |
@Ingo, the source is here: https://github.com/gradle/gradle/tree/native-client/subprojects/native-client. It needs some tweaks to the daemon to make it work (found in this branch), so it won't work with a vanilla Gradle daemon. It's also a spike, so I wouldn't go trying to use it to actually build anything. Should work on linux and mac. |
Comment by Eric Berry [ 24/Apr/12 ] |
@Ingo, did you ever publish your completion script? I've been looking for something like this. |
Comment by Ingo Fischer [ 25/Apr/12 ] |
@Eric its still in my Backlog. Thanks for reminding me. Will try to publish an initial solution this weekend and report here. |
Comment by Robert Kuhar [ 10/Oct/12 ] |
Come-on, come-on, publish a solution. This feature is sorely lacking. |
Comment by Mattias Olofsson [ 28/Dec/13 ] |
This will really make the gradle adoption rate to increase a lot. Should be great if it works in the same way as spring roo and grails does. |
Comment by Eran Samocha [ 09/Jul/14 ] |
Still nothing? this would be extremely useful.. |
Comment by Henrik [ 22/Sep/14 ] |
Can this be used? https://github.com/devmop/gradle-bash-completion |
Comment by Dominik Stadler [ 02/Oct/14 ] |
I like the solution at https://gist.github.com/nolanlawson/8694399 as it does not require me to adjust my build files (and potentially build-files of third party projects) |
Comment by Yannick Welsch [ 30/Oct/15 ] |
I wrote a bash completion script with multi-project support: |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Tadayoshi Sato [ 15/Nov/16 ] |
Benjamin Muschko I think it's still valid and actionable. All the requisite info should be there. |
Comment by Eric Wendelin [ 23/Jan/17 ] |
Announcing bash and zsh completion support for Gradle => git.io/gradle-completion |