gradle-completion icon indicating copy to clipboard operation
gradle-completion copied to clipboard

gw completion not working on Linux

Open rwinch opened this issue 8 years ago • 13 comments

It would be nice if the completion worked for https://github.com/dougborg/gdub (or something similar)

rwinch avatar Feb 07 '17 20:02 rwinch

@rwinch gw should be completed the same as gradle achieved by commits 55303d5758f4eb8829f24dc724602e1fb8d0ba95 (zsh) and 146823068a63f1dcdc0686568fb39813bb8391d4 (bash)

If for some reason that's not working for you, could you please tell me a bit about your environment and exactly what command you're trying to complete so I can help debug?

Please note that these scripts don't yet support completion from a subproject directory #3.

eriwen avatar Feb 07 '17 21:02 eriwen

Thanks for the fast reply!

I am using zsh 5.2 (x86_64-ubuntu-linux-gnu). I have the lastest oh-my-zsh installed but I have disabled all plugins.

The project I'm using leverages Gradle 3.3. If I type:

./gradlew --v

and press tab it completes to

./gradlew --version

If I type:

gw --v

and press tab nothing happens.

rwinch avatar Feb 07 '17 21:02 rwinch

Thanks for the thorough context, Rob.

gw --v[TAB] completes correctly for me on macOS. I'll need to check my linux VM soon.

In the meantime, would you tell me if task completion works with gw?

eriwen avatar Feb 08 '17 04:02 eriwen

@eriwen Thanks again for your fast response.

Task completion works for ./gradlew, but pressing gw [TAB] makes it autocomplete my path instead of tasks.

It may be useful to know I am using Ubuntu 16.10.

NOTE: I am running this in the root project of spring framework's master branch with sha f2967467e08a969a4e338c7b9a342bb2dda7f971

rwinch avatar Feb 08 '17 14:02 rwinch

@rwinch Weird question: Does completion complete --status for you?

eriwen avatar Feb 11 '17 04:02 eriwen

@eriwen No it does not. The following does not complete:

gw --statu[TAB]

However the following will complete:

./gradlew --statu[TAB]

So will the following

gradle --statu[TAB]

rwinch avatar Feb 13 '17 03:02 rwinch

I'm able to reproduce this issue, and it seems like gw completion is being overridden. If I hit Ctrl-X ? instead of [tab] I get debug output that shows that completion is ignored and defaults to completing files.

I expect that explicitly declaring gw completion in ~/.zshrc with zstyle may do the trick. I can dig up the command for this after a bit.

eriwen avatar Feb 24 '17 18:02 eriwen

Thanks for the follow up :)

rwinch avatar Mar 01 '17 21:03 rwinch

when gw is an alias, it could also be completed if we check it with type: if hash gw 2>/dev/null; then complete -F _gradle gw elif type gw &>/dev/null; then complete -F _gradle gw fi

The only issue is that it's not guaranteed to be an alias for gradlew, so the output of the type command might have to be parsed to guarantee we complete on the correct alias: ✘ 13:53 ~/git/platform-infrastructure [ bugfix/INFRA-3119 | ⚑ 8 ] $ type gw gw is aliased to ./gradlew'`

NielsDoucet avatar May 17 '17 12:05 NielsDoucet

Adding

compdef gw='gradle'

to ~/.zshrc seems to do the trick for me.

wolfs avatar Aug 11 '17 13:08 wolfs

@eriwen Any news on this? Can't the workraound that @wolfs mentioned to work either. So basically I never use the completion since gw is sp much better than "./gradlew". I also tend to have my gw aliased to this function:

function build_gradlew() {
  if [[ -f ../gradlew ]]; then
    nice -n11 ../gradlew "$@";
  else
   nice -n11 ./gradlew "$@";
  fi
};

But even when removing this, I can't get it to work.

staffanf avatar Oct 16 '17 08:10 staffanf

https://github.com/gradle/gradle-completion/commit/35b500add1db1ca671f4a62d384927f631f74b88

This was implemented in bash last june. Not sure about zsh support.

NielsDoucet avatar Oct 16 '17 13:10 NielsDoucet

@wolfs 's solution https://github.com/gradle/gradle-completion/issues/14#issuecomment-321808909 still works for me, and is the only work around I found so far.

I tried running the if branch directly

if hash gw 2>/dev/null || alias gw >/dev/null 2>&1; then echo yes; fi
# output:
yes

So this line has been already executed complete -F _gradle gw

Don't know what's wrong. Maybe it's a conflict with some other programs.

I'm using Macbook Pro macOS Mojave 10.14.3 zsh 5.5.1 (x86_64-apple-darwin17.5.0)

QinMing avatar Apr 02 '19 02:04 QinMing