We saw how to create a java project with gradle in previous article. What good are those if we cannot import them in any IDE, are we going to write code in only text editors? Obviously not. We will see how to create eclipse project with gradle in this article.
Create Eclipse Project With Gradle:
After we have compiled java source code and built necessary files, we want to import the project in eclipse and then continue working with it. But only built code will not be able to get imported in eclipse. Eclipse needs a .project, .classpath files and .settings folder which is essential for project to be recognized as eclipse project. Gradle eclipse plugin helps us create eclipse project with gradle. We simply need to add the plugin in build.gradle file as below.
apply plugin : 'java'
apply plugin : 'eclipse'
If you have not built java project, do it using gradle build command as below
Now we need to run gradle eclipse from command line. Navigate to the root directory where you have kept your java project and run as below.
When we create eclipse project with gradle, all eclipse related tasks are executed and build is successful. Now you can simply open eclipse -> File -> Import -> Existing Projects into Workspace and select the root directory of our java project. Project will get imported successfully and you can see structure as below
I hope the article helped created eclipse project with gradle