Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Custom Facets #103

Open
dgeissl opened this issue Mar 24, 2020 · 4 comments
Open

Implement Custom Facets #103

dgeissl opened this issue Mar 24, 2020 · 4 comments

Comments

@dgeissl
Copy link

dgeissl commented Mar 24, 2020

As mentioned here #36 many users have the need for custom Facets and many of them can not be autodetected.

So i was wondering if there is a way to provide pull requests that support the types of Facets we'd like to support or even enhance the plugin in our own plugin to add even more (non-public) Facet types.

From the Plugins implementation side a facet seems to be just a map (containing other maps and so on), so I tried adding such a custom Facet in a local Plugin:

private void configureIdea(Project project) {
        final IdeaModel model = project.getExtensions().getByType(IdeaModel.class);
        ModuleSettings moduleSettings = ProjectUtils.getExtensionOfType(model.getModule(), ModuleSettings.class);
        moduleSettings.getFacets().create("ejb", EjbFacet.class);
    }

    public static class EjbFacet implements org.jetbrains.gradle.ext.Facet {
        String name = "EJB";
        String type = "ejb";

        public String getType() {
            return type;
        }
        public String getName() {
            return name;
        }
        public Map<String, ?> toMap() {
            Map<String, Object> map = new HashMap<>();
            map.put("type", type);
            map.put("name", name);
            return map;
        }
    }

Unfortunately this did not work - or had no visible effect on the modules settings or the created iml files. So I wonder where is that magic happening that applies the setting from this plugin into intellij? If we know the interface we may provide the pull requests or even the configuration on our own and help this plugin to grow.

@ingokegel
Copy link

In #127 I did this for web resource directories in the web facet. Apart from support in this Gradle plugin, it also needs explicit support in the IDE using the externalSystem.facetConfigurationImporter extension point, so you have to write an IDEA plugin for that.

@nskvortsov
Copy link
Collaborator

@dgeissl indeed, you need to provide the support on IDEA side as well.
This extensibility is mostly targeting third party plugins that would like to have their facets configured via IDEA Ext dsl in build.gradle file. For IDEA's built-in/bundled facets, I'd expect native sync to work. Please report an issue to our Youtrack instance if some bundled facet does not get detected (without IDEA Ext)

@dgeissl
Copy link
Author

dgeissl commented May 6, 2022

@nskvortsov while the facet autodetection is ok - it's still annoying if you have to wait for intellij to detect the projects nature and click the automatic configuration to happen.
The gradle build can configure it right away and in many cases even better as it knows best what deployment descriptors to use and where to find them (even if they haven't been created yet).

If I get it correctly then everything that has a autodetect feature does not have a tooling api importer?

@nskvortsov
Copy link
Collaborator

Acutally, almost none have a tooling api importer at the moment. Regardless of autodetect implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants