gradle IntelliJ IDEA Task Customization


  • groovy.util.Node = node.find { childNode -> return true || false }
  • node.append(nodeYouWantAsAChild)
  • groovy.util.Node parsedNode = (new XmlParser()).parseText(someRawXMLString)
  • ''' mutli-line string (not interpolated) '''


The three basic files of an IntelliJ project - the ipr, iws, and iml files - can be accessed as in gradle in the idea task through


using the .withXml lets you access the xml. Using the .asNode() on that turns it into a groovy xml node.


project.ipr.withXml { provider ->
    def node = provider.asNode()

From there it's pretty simple - to modify gradle to configure IntelliJ projects for you, take the file as it starts, perform the actions you'd like gradle to take (inside IntelliJ), and then diff the new file with the old file. You should see what XML you'll need to customize the idea job. You'll also need to take note of where in the xml it's located.

One other thing to consider is that you don't want duplicate nodes within the IntelliJ files if you run the gradle idea multiple times. So, you'll want to search for the node you'd like to make and if it's not there, you can create and insert it.


Sometimes, when using == for string comparison in the find method, it fails. When testing and I find that to be the case, I use .contains.

When searching for nodes, not all nodes have the attribute you're using as a criteria, so be sure to check for null.