gradle / gradle/gradle-completion

Does not work nicely with custom build script names created by variables

Open
#32 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

a:feature
Dominant language
Shell
Stars
1.1k
Forks
154
Avg merge
4d 18h
Merged PRs (30d)
4

Description

The completion works fine if your root build script is either named `build.gradle` or its name is set via `rootProject.buildFileName = '...'` or `rootProject.buildFileName = "..."` (actually also `rootProject.buildFileName = "...'` and `rootProject.buildFileName = '..."`, but those will not compile anyway) exactly like that.
You cannot use a variable for the name, you cannot leave out the spaces around the equals sign or add more, it has to be at the start of a line without any preceding whitespaces, and you cannot use other constructs to set the name that are perfectly legal. In my case I do it for all projects like this which of course also does not work:

```
def setBuildFileNameRecursively
setBuildFileNameRecursively = { it ->
it.buildFileName = "${it.name}.gradle"
it.children.each { setBuildFileNameRecursively it }
}
setBuildFileNameRecursively rootProject
```

It would be nice if the completion would not require some narrow range of modification options but simply work. Is it really necessary to determine the root project filename upfront? Can't you use `-p` instead of `-b` for the call and use the project dir as cache key instead of the build file?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named in the issue. Start by finding the bash and zsh completion code that parses rootProject.buildFileName, then compare the proposed -b and -p approaches; done means variable-based and otherwise legal build-file names complete without the listed formatting restrictions.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli, tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.