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.

Tags:  Gradle  Java  Eclipse 
Last blog articles:
Ubuntu 18.04 and unprivileged LXC
Workspaces grid in Ubuntu 18.04
Workspace lover
Pod lampou
Facebook: Odcházení

Tags:
Java Ubuntu Gradle česky Software-architecture personal children React Eclipse DisplayLink DIY AI Spring JavaScript AspectJ neuron SSH JavaFX Immutables Gnome3 FatJar Edison technologies science procrastination pokusy lambda kvas ellipsis destilace chemie alkohol VisualVM Upstart Tomcat Selenium REST PrimeFaces Log4j LXC Jooq Jackson JSF GIT Debug DI CSS

Last tweets: