Creating the classpath using the plugin

Hi,

I’m trying to create a text plugin for our eclipse projects.

eclipse.gradle:

allprojects {
    apply plugin:'eclipse'
    eclipse {
        project {
            buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
            buildCommand 'org.eclipse.jdt.core.javabuilder'
            buildCommand 'edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder'
            natures = [
                    'org.eclipse.buildship.core.gradleprojectnature',
                    'org.eclipse.jdt.core.javanature',
                    'org.sonar.ide.eclipse.core.sonarNature',
                    'edu.umd.cs.findbugs.plugin.eclipse.findbugsNature']
        }
        classpath {
            file {
                beforeMerged { classpath ->
                    classpath.entries.removeAll { entry -> entry.kind == 'lib' || entry.kind == 'var' }
                }
                whenMerged { classpath ->
                    classpath.entries.findAll { entry -> entry.kind == 'lib' }*.exported = true
                }
            }

            if (env == 'dev') {
                downloadSources = true
                downloadJavadoc = true
            } else {
                downloadSources = false
                downloadJavadoc = false
            }
        }
    }
}

This produces this very clean .classpath, which is 1000% better than the mess that the default settings do.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="output" path="bin"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>

What I would like to end up with, is this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="src" path="src">
                <attributes>
                        <attribute name="FROM_GRADLE_MODEL" value="true"/>
                </attributes>
        </classpathentry>
        <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry exported="true" kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
        <classpathentry kind="output" path="bin"/>
</classpath>

The same question was asked here: