What is best way to import a gradle non-eclipse project into eclipse using buildship

I am finding this to be rather nightmarish. For example, I do a git clone of https://github.com/nebula-plugins/gradle-ospackage-plugin.git in Eclipse. This project is not eclipse-enabled, has no .project files, etc. If I try to import it as a gradle project, I get a project that does not include the source folders and creates some Library class that I didn’t ask for. So that doesn’t work.

The workaround I’ve found is to create a dummy New Gradle project, import the clone as a “general” project, and then replace the .project file, .settings folder, etc. in the imported project with those from the dummy project, and then manually fixing up the build path.

Is there a better way to do this?

Sounds like you used “New Gradle Project” instead of “Import Gradle Project”.

How then do I bring the code over from the git repository?

There’s still a flaw with this workaround, because even though the project tab shows no errors, the source files are full of import not found errors.

Just run the “Import Gradle Project” on the folder where you checked out the repo.

I don’t have that option. My Eclipse version is Luna. Does that make a difference? I only have this:

which leads to the first scenario described above.

I don’t mean in the git view. Just open the regular “Import” wizard from the Project Explorer, choose “Gradle Project” and then use to the location where you checked out the project.

Thank you! This worked well!

It would be a nice-to-have to have it work from the git view import as well.

Agreed that the ideal situation would be to either directly integrate somehow with the Git Repositories View’s right click and “Import Projects…” dialog, or to potentially add a new item near “Import Projects…” on that right click menu to “Import Gradle Project”.

You realise that the git plugin is a 3rd party Eclipse plugin… right? Do you also expect integration with Subversion, Perforce, RTC and VSS plugins? I’d guess that integrating with 3rd party plugins is either very low down the buildship priority list… or not on the list at all.

I could also be wrong as I’ve never developed an eclipse plugin… perhaps this is a standard extension point?

I don’t know what’s involved either. But it might not be that hard. From a UI point of view, both seem to take you to the same wizards, but initialized somehow with different params so they don’t provide the same results. As I originally suggested, this would be a nice-to-have, not a necessity.

The problem is that eGit takes you to the New Project wizard instead of the Import Project wizard, which would make much more sense. I think you should raise an issue at the eGit project for that.

makes sense, thanks.

I think a better solution would be to add an entry to the “Configure” menu of the Project. Something like “Convert to Gradle Project”.

So the project may checked out from any repository by any plugin and in the next step the project may be converted to a Gradle project. Also may other existing eclipse projects in the workspace be converted without removing AND then importing them.

You don’t need to remove them, just point the import wizard to the project directory and it will configure them.

The fact that this works is also the reason why a “Convert” button is low priority for us. Especially since different people have different expectations attached to the word “Convert”. Some might expect for instance that we read the .classpath and somehow convert that to a .gradle file.

It seems that I never tried that without removing. It works. Thanks for thr tip.