Gradle Support For Spring Framewokr in Intellij

Answered

Hi,

Is there any similar feature in Intellij IDEA for adding spring framework support through Gradle.

Ex: In Eclipse I can add below entry to make a gradle or spring nature. I'm looking for equivalent in IDEA.

 

eclipse.project{
natures "org.springframework.ide.eclipse.core.springnature"
}
1 comment
Comment actions Permalink

Hi,

you can do similar using gradle 'idea' plugin, see details at https://docs.gradle.org/current/userguide/idea_plugin.html 

apply plugin: 'idea'

idea {
    module {
        iml {
            withXml { xml ->
                def moduleRoot = xml.asNode()            
                def builder = NodeBuilder.newInstance();
                builder.current = moduleRoot;
                
                builder.component(name: "FacetManager") {
                    facet(type: "Spring", name: "Spring") {
                        configuration {
                            fileset(id: 'fileset1', name: 'XML Application Context') {
                                file 'file://$MODULE_DIR$/src/main/resources/META-INF/spring/applicationContext.xml'
                            }
                        }
                    }
                }
            }
        }
    }
}

Then, you should run the following task and open generated project in IntelliJ

gradlew idea

Note, IntelliJ builtin Gradle Integration doesn't support such xml manipulations of that 'idea' plugin, because IntelliJ uses gradle tooling API which doesn't provide such data.

That's why you can not use gradle import for such projects and hence features of IntelliJ Gradle integration.

So, maybe better approach can be checking in VCS correct .iml files instead.

 

1

Please sign in to leave a comment.