Cannot run tasks from gradle view (dependent projects)

Hi,
I have a gradle web project (say Project Web) and a gradle java project, say (Project Java). Both projects are in the same level in Eclipse STS and Project Web refers to Project Java via the settings.gradle file (includeFlat). I am able to run the gradle tasks for Project Web from the Gradle Task view in eclipse but i cannot run the build (or any tasks) form the Project Java project from under the tasks view. But i can the task from the command line (gradlew.bat build). Is this a problem with the buildship plugin or something to do with dependencies setup. If i run the build taks from project web, it compiled and adds the jar of Project JAVA into the web project. I just cannot run the tasks at the java project level. Hopefully this makes sense?

Hi,

Do you use Eclipse STS? If so, I’m afraid we can’t help much, because that’s another tooling for Gradle.

Buildship is a supported tool for Gradle right. That is what i am using to execute tasks. But can only run it from Project Web

If you use includeFlat your root project has to be called ‘master’. Otherwise Gradle cannot execute tasks in the included project, because it cannot find the root.

This will improve in the future. Meanwhile I recommend using a nested project layout.

buildship can call and execute tasks in the included projects if i execute the ‘build’ task from the root project (via gradle task view tab on STS). The problem is when i try to execute ‘build’ from the sub project that it refuses to trigger. I need to run build from the included project to i can send the jar for use elsewhere. I can successfully run the build from the command line. Its just from the gradle tasks view tab that i have a problem.

As I said, running tasks in subprojects with a non-standard layout is not supported. As a workaround either run the tasks in the root or switch to a hierarchical layout.

As a third alternative, if you only want to launch a task in a single project, you can activate “Show project tasks” in the task view’s menu and use those.

1 Like

Thanks!!! “Show project tasks” option worked for me. Thanks a lot for your help Stefan!

Happy I could help. Just be aware that this will only launch the task in the single project and ignore any subprojects. (It behaves like calling gradle :jar instead of gradle jar)