How to attach a facet on new project creation?

I would recommend not designing the settings this way. Facets should be created by users only when some manual customization is needed.

There are numerous ways how modules appear in project:

  • created via UI
  • imported from Gradle/Maven
  • loaded from .iml on VCS update

It is super hard to cover all those cases and make something consistent.

Previously, IntelliJ IDEA used some auto-import of facets, for Spring and JPA technologies. It was implemented as import handler for Gradle/Maven to make sure it always in sync with build settings. Nowadays, we don’t do that, we auto-discover and cache such automatic settings if there are no facets - making features always available without excessive configuration. Facets are considered only user-overrides / customizations then.

We also do not introduce any new facet types now, prefer technology-native configuration or Project settings instead.

As you may notice Facets exist only in IntelliJ IDEA and do not exist in other JetBrains IDEs