Working with classpath entries in eclipse plugin issues


(Zbyszek Sokolowski) #1

I prepared workaround for gradle bug GRADLE-1315 eclipse.classpath.file {

whenMerged { classpath ->

def containers = classpath.entries.findAll {

entry -> entry.kind == ‘con’ &&

entry.path == ‘org.eclipse.jdt.launching.JRE_CONTAINER’ &&

entry.exported == ‘true’}

classpath.entries.removeAll (containers)

classpath.entries.findAll { entry -> entry.kind == ‘con’ &&

entry.path == ‘org.eclipse.jdt.launching.JRE_CONTAINER’}*.exported = false

} }

I don’t get why method findAll doesn’t find a class path with exported = true but just the opposite, so I have to add another line to remove exported flag, I don’t get it. Could you explain it or find a bug in my code?

Thanks, Zbigniew


(Szczepan Faber) #2

‘exported’ is a boolean field but the code above checks for equality with String.

Hope that helps!


(Zbyszek Sokolowski) #3

Hi Szczepan!

Unfortunately it works even worse"

eclipse.classpath.file {
  whenMerged { classpath ->
    def containers = classpath.entries.findAll {
      entry -> entry.kind == 'con' &&
      entry.path == 'org.eclipse.jdt.launching.JRE_CONTAINER' &&
      entry.exported == true}
      classpath.entries.removeAll (containers)
    /*classpath.entries.findAll { entry -> entry.kind == 'con' &&
            entry.path == 'org.eclipse.jdt.launching.JRE_CONTAINER'}*.exported = false*/
  }
}

it deletes both entries whether exported is true or not. So my previous version works only by accident but still works.