Buildship, how to 'ignore_optional_problems' in annotation (apt) generated classes

Hi. This problem is bugging me for a while on Eclipse (with Buildship). I use AutoValue as annotation processor and annotations in my project to auto generate some classes inside folder MyProject/.apt_generated/. I have configured the Java Compiler to show warnings for “Unqualified access to instance field” (Eclipse-> right click on Project-> properties -> Java Compiler -> Errors/Warnings) but I want the /.apt_generated folder to be excluded from that scan to avoid several hundreds warnings.

I have tried:
eclipse { classpath { file { whenMerged {
def aptSources = entries.find { it.path == ‘.apt_generated’ }
} } } }
but I get an exception on entryAttributes as aptSources turns out to be null (“Cannot get property entryAttributes’ on null object”) and of course the extra attribute is not added to the classpath.

My Classpath file:

<?xml version="1.0" encoding="UTF-8"?>
<classpathentry kind="src" output="bin/main" path="src/main/java">
		<attribute name="gradle_scope" value="main"/>
		<attribute name="gradle_used_by_scope" value="main,test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="src" path=".apt_generated">
		<attribute name="optional" value="true"/>
<classpathentry kind="output" path="bin/default"/>

(As a new forum member, I am prevented from uploading it as a file and thus the in-post presentation)

I actually solved it, this works:

eclipse { classpath { file { whenMerged {
def aptSource = new org.gradle.plugins.ide.eclipse.model.SourceFolder(".apt_generated",“bin/main”)
aptSource.entryAttributes[‘optional’] = ‘true’
aptSource.entryAttributes[‘ignore_optional_problems’] = ‘true’
entries += aptSource

Side note: Initially, I could configure it through Eclipse (Eclipse-> right click on Project-> Properties -> Java Build Path) , but then Buildship/Gradle would remove the attribute ‘ignore_optional_problems’ from the classpath entry (or probably rewrite the whole entry with only the “optional” attribute, as the “.apt_generated” entry appeared under the buildship container). This way, “.apt_generated” is explicitly inserted and is not rewritten.
As for the error given by:
def aptSources = entries.find { it.path == ‘.apt_generated’ }
I guess Buildship writes on the classpath after whenMerged and that’s why aptSources was a null object.