简体   繁体   中英

Can't run Gradle Tasks on project

I'm trying to run a Gradle Task by double clicking it on Eclipse, but the task is greyed out and says "Cannot run tasks for included builds" if I right click it as you can see in the image below:

摇篮错误

What's that supposed to mean? Suddenly I can't run tasks for no apparent reason when I was able a few hours ago.

My project is Liferay based. I'm under JDK 1.8 and Windows 10.

I tried restarting Eclipse, cleaning project, deleting .gradle folder, changing Gradle version to 4.10 and refreshing tasks but nothing changes.

Please consider the following (It works fine in my case):

  1. Delete the project on eclipse (just check delete nested projects), do not delete the project on the disk
  2. Go the the project on the disk, find and delete all .project files
  3. Re-Import Liferay workspace on eclipse (File > Import > Liferay Workspace Project) and select your project folder

That did the trick ! Gradle tasks are now refreshed in green.

My project was set up as a Gradle multi-project. I found that the build tasks for the parent and nested projects were greyed out. The fix was to remove the Eclipse Gradle Project Nature ( Project Natures -> Gradle Project Nature) project nature on the parent project, delete the .gradle folder of the parent project and then add the Gradle Project Nature again via Eclipse.

Posting this in case it helps anyone. For me, this problem arose when I added a new Java project and manually converted it to gradle and then added it as a sub-project.

Doing so changed the following line in /.settings/org.eclipse.buildship.core.prefs from this:

connection.project.dir=

to this:

connection.project.dir=mynewproject

Once I changed that line back, I could run all sub-project tasks again.

I think I found a solution, in case someone's having the same problem:

  1. Copy project folder into another place
  2. Delete project on Eclipse (check "Delete project contents on disk")
  3. Delete .gradle folder inside the project folder
  4. File > Import > Existing Gradle Project
  5. Look for the project folder

Now you should be able to run Gradle Tasks again.

I hope this helps ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM