No java plugin tasks for Java project

Pardon the noob question; I’m sure it’s something dumb.

I’ve installed Buildship1.0.7.v20151214-0917 in Eclipse Mars. I have added a build.gradle file to my project that includes "apply plugin: ‘java’ ". Then deleted and reimported the project as a Gradle project. The task list for the project is showing only the generic Gradle tasks and none of the Java plugin tasks (i.e. “classes”.) There’s nothing in the error log.

System: Windows 7 Professional.
Gradle 2.10
Eclipse Mars

If you already have an Eclipse .project file in the project that you import, the classpath is not taken from the Gradle build (intentionally). In Gradle 1.0.8 will show a notification dialog in that case and, before the actual import starts, the user can choose whether to keep or replace an existing .project file.

I’m afraid you missed my point. I haven’t gotten to the point of worrying about the classpath. I can’t execute a Gradle build because the appropriate tasks aren’t available.

If you already have a .project file before you import as a Gradle project, the existing .project file is not replaced. I think this means that the import doesn’t behave as you expect, and is why in the next version of Buildship a warning will be raised.

Try deleting the existing .project file and then re-importing the project as a Gradle build.

Hmmm. I looked at the .project file and it looks like the Gradle import added the Gradle nature. I’ll try deleting and reimporting to see how that would be different.

I just tried this on a test project:

  1. Crate a Java project in Eclipse
  2. Add build.gradle to the project
  3. Delete the project from the workspace
  4. Manually delete the .project file from the project
  5. Import as Gradle project

I still don’t see any of the Java plugin tasks. Also, Eclipse isn’t recognizing this as a Java project – my source folder is no longer marked as such and I just have the plain directory structure rather than packages. Plus, the icon for the .java file is the one Eclipse uses for “Java, but not one I know about.”

I followed your instructions and after the import, I see all the Java tasks and the project also has the Java nature, classpath container etc.

Can you share the example that does not work for you after importing?

Sure. I’m attaching the project before import and after import. Notice that the .project that was generated doesn’t have the Java nature in it. (6.9 KB) (5.3 KB)

The standard build script name is “build.gradle”. If you want to change that convention, you can do so in settings.gradle.

To Buildship your project looks like it has no build script.

Thank you. Renaming worked.