5

We have a project based on Maven Tycho and we recently eliminated all these seemingly redundant pom.xml files. The command line build works fine, so this seemed like a good improvement to remove useless clutter.

Later we found out that these projects cannot be easily imported into Eclipse any more -- at least not the way we were used to. So far, we used the import “Existing Maven Projects” command and all directories which contained a pom.xml got imported. As there are not pom.xml files any more, this does not work. D’oh!

What’s the recommended way to import pomless Tycho projects into Eclipse?

qqilihq
  • 10,794
  • 7
  • 48
  • 89
  • 3
    Probably you just missed to share the `.project` files and the `.settings` folders. Having the `.project` files you can just import it as exisiting Eclipse projects (e.g. via _File > Open Projects from File System..._). – howlger Oct 06 '20 at 17:00
  • @howlger Ha. Admittedly this hadn’t even come to my mind, as I’m normally always used to just `.gitignore` these. I’ll try this, thank you! :-) – qqilihq Oct 06 '20 at 20:02
  • The `.project` files and the `.settings` folders are intended to be shared. That is why Eclipse stores them in the project directory. [It is a common misconception to .gitignore them](https://stackoverflow.com/a/60669809/6505250). – howlger Sep 07 '21 at 09:16

1 Answers1

4

The Maven import is only for (plain Java) projects that contain a pom.xml file, not for projects that will be build with Tycho (independent whether they are POM-less or not).

A Maven build with the Maven plugin Tycho behaves quite differently than a regular Maven build. Resolving dependencies, downloading dependencies and compiling is done by Tycho and also the phases differ from a regular Maven build. You need some basic OSGi knowledge (where in contrast to Maven, dependencies are also resolved at runtime since bundles/plugins can be started and stopped at runtime). The vogella company provides a quite good Tycho tutorial with a sample Git repository which might a good start (requires basic OSGi knowledge): Maven Tycho for building Eclipse plug-ins, OSGi bundles and Eclipse applications with the command line - Tutorial

A .project file per project is needed to be able to import such Plug-in, Fragment, Feature, Update Site, etc. projects e.g.

  • in the Git Repositories view, by right-clicking a repository and choosing Import Projects... or
  • via File > Open Projects from File System....

If you have lost the .project files, copy them from a project of the same kind/nature and adapt <name>...</name> (this is the name that is shown in Eclipse, in most cases the name of the project folder, and it must be unique; two projects with the same name cannot be opened).

A Plug-in project that contains Java code also needs a .classpath file, which you can add in the same way after importing.

By not sharing the .settings folders you lost the settings that can be done in Project > Properties (it is recommended to have project specific settings at least for Java Compiler and Java Compiler > Errors/Warnings).

howlger
  • 31,050
  • 11
  • 59
  • 99