Import Gradle projects correctly in Eclipse

I have a set of about 15 interdependent Gradle Java modules / projects that build correctly with Gradle. However, I run into problems importing them into Eclipse.

If I import them through the Gradle Eclipse plug-in (import as a Gradle project) and select "Build Model" in the root folder, it imports the projects, but does not treat them as Java projects. In particular, syntax errors are not recognized.

If I import each project separately, they are recognized as Java projects, but they are not connected properly, and Eclipse shows build errors.

How to correctly import / link Gradle projects in Eclipse?

+5
source share
2 answers

Unfortunately, answering this is not easy, it depends on the details of your project. I found that complex projects often require specific configuration in the build script.

I'm going to assume that your projects have never been used in Eclipse. Here are some tips that may work for such cases (or they may not need more specific settings).

1) do not forget to apply the eclipse plugin to all your projects if they are simple Java projects or the eclipse-wtp plugin if they use war style web projects.

2) import your projects with disabled dependency management (this is one of the options in the import wizard.

If this does not work, I will need additional information about your projects and / or exactly what happens with the import. It looks like your projects do not have the proper Java character, or the source folders are not configured correctly. The contents of the .classpath and .project files for "poorly configured" projects would be helpful.

+1
source

Check if your project has special eclipse files such as .project, .classpath, etc. These are hidden files, so you need to run the $ls -la to confirm this.

If these files are not , you need to convert your project to a valid eclipse project. Gradle provides a plugin for this.

  • Add the eclipse plugin to the Gradle build file (i.e. build.gradle).

      apply plugin: 'eclipse' 
  • Run $gradle eclipse

I presented this data on my blog here .

+1
source

Source: https://habr.com/ru/post/1215301/


All Articles