Tag Archives: Eclipse

Gradle + Immutables + Eclipse

There is some documentation about IDE integration directly on Immutable web. Unfortunately none of proposed approaches works.

Fortunately there is Gradle plugin gradle-processors. Usage is deadly simple:

plugins {
  id 'org.inferred.processors' version '1.2.3'

dependencies {
  processor group: 'org.immutables', name: 'value', version: '2.2.6'

(Please not usage of processor instead of compile in dependencies)

That’s it! Just do gradle eclipse and restart Eclipse.

Gradle + Eclipse plugin: Add AspectJ nature into projects

I have found nice script for adding AspectJ nature into Eclipse project using Gradle. See https://github.com/breskeby/gradleplugins/blob/0.9-upgrade/aspectjPlugin/aspectJ.gradle#L29 . Unfortunately each run of ‘gradle eclipse’ adds new nodes into project XML. Here is my fix of that issue:

eclipse.project.file.withXml { xmlProvider->
  def projectDescription = xmlProvider.asNode()
  def xmlparser = new XmlParser()

  def builders = projectDescription.buildSpec[0]

  if (!builders.buildCommand.any {it.name[0].value()=='org.eclipse.ajdt.core.ajbuilder'}) {
    def ajbuilder = xmlparser.createNode(builders, 'buildCommand', [:])
    xmlparser.createNode(ajbuilder, 'name', [:]).setValue('org.eclipse.ajdt.core.ajbuilder')
    xmlparser.createNode(ajbuilder, 'arguments', [:]);

  def natures = projectDescription.natures[0]

  if (!natures.nature.any {it.value()=='org.eclipse.ajdt.ui.ajnature'}) {
    def ajnature = xmlparser.createNode(null, 'nature', [:])
    natures.children().add(0, ajnature)

Then all nodes are created only once.

Gradle + Eclipse plugin: Remove build folder from Eclipse project

By default Eclipse plugin does not add /build folder into ignored resources and that may cause /build folder to be validated. Then many warnings will appear in Markers tab of Eclipse. Beside that it may be performance problem.

I found almost suitable solution here: https://discuss.gradle.org/t/eclipse-pluging-adding-resource-filters/5408 Unfortunately it adds new filter into configuration during each ‘gradle eclipse’. Here is my fix for that situation:

eclipse.project.file.withXml { xmlProvider ->
  Node project = xmlProvider.asNode()
  Node node = project

  if (node.filteredResources.isEmpty()) {
    node = node.appendNode('filteredResources')
  } else {
    node = node.filteredResources[0]

  if (!node.filter.any {it.id[0].value()[0]=='1447321705713'}) {
    Node filter = node.appendNode('filter')

    filter.appendNode('id', '1447321705713')
    filter.appendNode('name', '')
    filter.appendNode('type', 10)
    Node matcher = filter.appendNode('matcher')
    matcher.appendNode('id', 'org.eclipse.ui.ide.multiFilter')
    matcher.appendNode('arguments', '1.0-name-matches-false-false-build')

So filter node is added only in case it does not already exists.