Hello, by now, Gradle only generates basic project/module configurations for IntelliJ IDEA when using “gradle idea”. This is enough for simple projects but not for e.g. war projects (GRADLE-1441). For such projects, you need extended configuration including facets and artifacts (and possibly even more).
I know that if I import a project as Gradle project, IntelliJ IDEA will generate the necessary configurations based on the Gradle tooling API (including the beforementioned facet and artifact). This is very good support as long as you only use built-in functionality (e.g. “war” plugin). In my case I’m writing a GWT plugin (which isn’t known by IntelliJ IDEA) where I would have to configure an additional facet and manipulate the exploded-war artifact. When using IntelliJ IDEA’s built-in support for Gradle, my plugin is simply ignored and I didn’t find a way to adjust the configuration generated by IntelliJ IDEA. When using “gradle idea” there’s much more missing that would have to be added by my plugin (web facet, exploded war artifact). That’s why I’d like to see improved support in Gradle to generate various configuration aspects (facets, artifacts, …) for IDEA using some kind of model instead of hand-coded xml transformations. This would help to improve the configuration produced by “gradle idea” and improve interoperability between plugins that want to manipulate those aspects. I did some research on how this could be implemented and hacked a prototype for the web facet stuff ( https://github.com/steffenschaefer/gradle/compare/idea-facet). The following things are changed to make it work: * The IdeaModule has a new property facets of type “IdeaFacetSet extends DomainObjectSet<IdeaFacet>” that defines some factory methods to create IdeaFacet instances with a given name and class. * Each IdeaFacet creates an associated Facet instace that generates the XML content of the facet configuration. When creating this Facet instance, the PathFactory stuff is also done. * The Module class is extended to create the FacetManager component in the *.iml file and delegates the generation of the Facet’s configuration to the given Facet instances * IdeaWebFacet is the implementation needed to generate the “web” facet (the one that is related to GRADLE-1441). * The IdeaPlugin adds an instance of the IdeaWebFacet with defaults if the “war” plugin is added With those changes, the configuration of new facets would look like this: idea { module { facets { facet('Crazy Facet', MyCustomFacet) { someProperty = ‘someValue’ } } } } The configuration of existing facets (e.g. added by a plugin) would be something like this: idea { module { facets { withType(IdeaWebFacet) { sourceRoots += project.sourceSets.someSourceSet.allSource.srcDirs webroot file('more_webapp_files'), '/' } } } } As mentioned before, It’s only a prototype by now that would need some love regarding JavaDocs/Tests/Documentation. But I think it’s good as a base for discussions. Before doing further changes I would like to ask some questions: * Is this something you would like to see in Gradle? Is there a chance for this to be accepted as PR? * Is it Gradleish? How could it be changed to be more Gradleish? * What other things besides JavaDocs/Tests/Documentation would have to be done? * By now you will have two web facets when importing the project as Gradle project into IntelliJ IDEA as the one added by Gradle isn’t recognized by IDEA. Should the addition of facets be moved to an extra plugin (something like “idea-web”) to ensure interoperability? With kind regards Steffen Schäfer