Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up bash completion loading by packaging it as a file in the ZIP distribution #296

Closed
rmannibucau opened this issue Jan 1, 2021 · 2 comments · Fixed by #307
Closed
Milestone

Comments

@rmannibucau
Copy link
Contributor

Completion setup encourages to add to bashrc:

source <(mvnd --completion bash)

Since I did it, creating a new shell has some latency I hadn't before.
I wonder if it wouldn't encourage to either dump it once and source it (instead of regenerating it) or (better) reuse maven one if ~/.maven_bash_completion.bash exists to avoid the duplication.

side question: current plugin completion is very jboss oriented, is it possible to add meecrowave, winegrower, tomee, jbake - or at least use a ~/.mvn[d]_completion_plugins_customrc ?

@ppalaga
Copy link
Contributor

ppalaga commented Jan 2, 2021

I have not noticed the delay before, but yes, when measuring with time source ~/.bashrc I can clearly see it there:

# with source <(mvndev --completion bash) active
$ time source ~/.bashrc
real    0m0.178s
# with source <(mvndev --completion bash) commented out
$ time source ~/.bashrc
real    0m0.061s

The diff is around 120ms on my rather fast machine. That's indeed quite a lot.

I wonder if it wouldn't encourage to either dump it once and source it (instead of regenerating it)

If Sdkman/Brew had some sort of a hook to regenerate the completion during upgrades, I'd be all for it. Otherwise, the users would have to take care for regenerating the completion themselves.

Maybe we could dump the file into the distribution ZIP, so that it at least has a canonical location. Sdkman users would have to add something like

source ~/.sdkman/candidates/mvnd/current/bin/completion.bash

to their .bashrc. WDYT?

or (better) reuse maven one if ~/.maven_bash_completion.bash exists to avoid the duplication.

Our completion is based on this one: https://github.com/juven/maven-bash-completion/blob/master/bash_completion.bash
We are adding our own options to it, so I do not see any way how we could "reuse" it?
We could contribute our changes there, but that sounds like too much maintenance overhead for both us and our users, because our options will probably evolve with each new release.

side question: current plugin completion is very jboss oriented

Is it? Why do you think so? I am very new to completion scripts. By no means it was an intention from my side :) As noted above, I just took juven's completion and added our option into it.

is it possible to add meecrowave, winegrower, tomee, jbake

Not sure I follow. What kind of "add" do you mean?

  • or at least use a ~/.mvn[d]_completion_plugins_customrc ?

You mean our completion would source some local file? If so, isn't .bashrc alone offering enough flexibility to reach what you need?

@rmannibucau
Copy link
Contributor Author

Guess it is faster to have a small bash script doing the version check from a file in mvnd distro in bashrc rather than launching java...until you make this command a native one with graalvm ;).
The source using current seems tempting and would work too for me.

About the completion: what about doing some PR on the bash_completion.bash to enable some pluggability and reuse of functions?

About jboss: cause wildfly, tomcat (JBoss Web Server ;)), vertx, spring-boot etc are all good jboss business but don't take it personal, it is probably a shortcut I did cause this great tool was contributed a lot by guys working for jboss. Point was not to blame jboss or anyone but more to ask to widen it to apache ecosystem and some common plugins like jbake if possible.

http://tomee.apache.org/tomee-8.0/docs/tomee-embedded-maven-plugin.html
http://tomee.apache.org/tomee-8.0/docs/developer/tools/maven/tomee.html
http://openwebbeans.apache.org/meecrowave/meecrowave-maven/index.html

(at least run, build commands).

About the extension point, i'd like for example to add:

local plugin_goals_meecrowave="meecrowave:bake|meecrowave:run|...."

and mvnd to take it automatically instead of rewriting a real compltion file

Hope it is clearer

@ppalaga ppalaga changed the title reuse mvn completion for bash? Speed up bash completion loading by packaging it as a file in the ZIP distribution Jan 6, 2021
ppalaga added a commit to ppalaga/mvnd that referenced this issue Jan 6, 2021
@ppalaga ppalaga added this to the 0.3.0 milestone Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants