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

Problem with multiproject without build.gradle in root. #137

Open
alcarraz opened this issue Apr 13, 2023 · 3 comments
Open

Problem with multiproject without build.gradle in root. #137

alcarraz opened this issue Apr 13, 2023 · 3 comments

Comments

@alcarraz
Copy link

alcarraz commented Apr 13, 2023

Hi, this was working wonderfully for me until now, thank you for the great work.

I started a multi project build according to Structuring and Building a Software Component with Gradle
and it doesn't have a build.gradle in the project root. The gradle init command doesn't generate a build.gradle in the project root, either.

In that case, the gradle-completion doesn't find the build file and defaults to assuming it is not an initialized gradle project, giving only the common options.

Maybe it can be assumed that if the settings file is found, the project is initialized, even if the build file is not found? I'm willing to add a PR, or a patch, if I manage to solve this and it works.

I found a workaround for this creating an empty build.gradle, but before that, well I'll tell the story because it may be worthy to add a warning or something in the README.md about that.

There is also the possibility that the script works, and somehow I did something to break it, in that case, please excuse me and let me know.

To reproduce, try this:

mkdir test-project
cd test-project
gradle init # select application, java, **yes** on multiple subprojects, groovy.

And then try to autocomplete gradle there. It will only show the default tasks.

alcarraz added a commit to alcarraz/gradle-completion that referenced this issue Apr 14, 2023
Such as muli project builds

Issue: gradle#137
Signed-off-by: Andrés Alcarraz <[email protected]>
@alcarraz alcarraz changed the title Problem with multproject without build.gradle in root. Problem with multiproject without build.gradle in root. Sep 1, 2023
@vvvlasov
Copy link

vvvlasov commented Apr 8, 2024

Hi! We're facing the same issue and would like to see this fixed. Do you need any help with your pull request?

@vvvlasov
Copy link

vvvlasov commented Apr 8, 2024

Ok, actually, what I found out is that the culprit is this command

$("$gradle_cmd" -b "$gradle_build_file" --daemon --no-scan --console=plain -q tasks --all)

tasks --all only lists the tasks for sub-projects. If one wants the root project tasks tasks without --all args is what you need. However tasks doesn't list sub-project tasks. What a surprising behaviour! Basically all I did to make it work is concatenated two outputs.

  if [[ ! -z "$("$gradle_cmd" --status 2>/dev/null | grep IDLE)" ]]; then
      gradle_tasks_output="$("$gradle_cmd" -b "$gradle_build_file" --daemon --no-scan --console=plain -q tasks --all) << $("$gradle_cmd" -b "$gradle_build_file" --daemon --no-scan --console=plain -q tasks)"
  else
      gradle_tasks_output="$("$gradle_cmd" -b "$gradle_build_file" --no-daemon --no-scan --console=plain -q tasks --all) << $("$gradle_cmd" -b "$gradle_build_file" --no-daemon --no-scan --console=plain -q tasks)"
  fi

@alcarraz
Copy link
Author

alcarraz commented Apr 8, 2024

Thank you, @vvvlasov, I actually made a PR (#138), showing a possible naive solution, but I didn't get any feedback on that. But I'm not sure if this is the same issue.

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

No branches or pull requests

2 participants