2.11 -Annotations not preserved on @Managed types

I am trying to work with the new software model. I was trying to add annotations to a managed model and use that metadata in other rules. It doesn’t look like those annotations are present on whatever types are instantiated by the Gradle runtime. here is an example build.gradle that demonstrates what I am talking about:

group 'com.mkobit.gradle'
version '1.0-SNAPSHOT'

import java.lang.annotation.ElementType
import java.lang.annotation.Inherited
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target

task wrapper(type: Wrapper) {
    gradleVersion = '2.11'
}

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface MyAnnotation {
    String value()
}

@Managed
interface MyManagedType {
    String getUnannotatedValue()
    void setUnannotatedValue(String value)

    @MyAnnotation('this is the annotation')
    String getAnnotatedValue()
    void setAnnotatedValue(String value)
}

class MyRuleSource extends RuleSource {
    @Model
    void myElement(MyManagedType type) {}

    @Mutate
    void createElementTask(ModelMap<Task> tasks, MyManagedType type) {
        tasks.create('showType') {
            doLast {
                println "unannotated=${type.unannotatedValue}, annotated=${type.annotatedValue}"
                MyManagedType.class.methods.each { method ->
                    println method
                    println method.annotations
                    println method.declaredAnnotations
                }

                println ''
                println '==== from parameter ===='
                println ''

                type.class.methods.each { method ->
                    println method
                    println method.annotations
                    println method.declaredAnnotations
                }
            }
        }
    }
}

apply plugin: MyRuleSource

model {
    myElement {
        unannotatedValue = 'not me'
        annotatedValue = 'yes me!'
    }
}

And when running it, I noticed that the getAnnotatedValue method did not have the annotation on it. I would think that I would have access to those annotations, but it doesn’t look like it.

Results from running ./gradlew showType:

:showType
unannotated=not me, annotated=yes me!
public abstract void MyManagedType.setAnnotatedValue(java.lang.String)
[]
[]
public abstract java.lang.String MyManagedType.getUnannotatedValue()
[]
[]
public abstract void MyManagedType.setUnannotatedValue(java.lang.String)
[]
[]
public abstract java.lang.String MyManagedType.getAnnotatedValue()
[@MyAnnotation(value=this is the annotation)]
[@MyAnnotation(value=this is the annotation)]

==== from parameter ====

public boolean MyManagedType$NodeView.equals(java.lang.Object)
[]
[]
public java.lang.String MyManagedType$NodeView.toString()
[]
[]
public int MyManagedType$NodeView.hashCode()
[]
[]
public java.lang.Object MyManagedType$NodeView.propertyMissing(java.lang.String)
[]
[]
public java.lang.Object MyManagedType$NodeView.propertyMissing(java.lang.String,java.lang.Object)
[]
[]
public void MyManagedType$NodeView.annotatedValue(java.lang.Object)
[]
[]
public void MyManagedType$NodeView.annotatedValue(groovy.lang.Closure)
[]
[]
public org.gradle.model.internal.core.MutableModelNode MyManagedType$NodeView.getBackingNode()
[]
[]
public java.lang.Object MyManagedType$NodeView.methodMissing(java.lang.String,java.lang.Object)
[]
[]
public org.gradle.model.internal.manage.instance.GeneratedViewState MyManagedType$NodeView.__view_state__()
[]
[]
public org.gradle.model.internal.type.ModelType MyManagedType$NodeView.getManagedType()
[]
[]
public void MyManagedType$NodeView.setAnnotatedValue(java.lang.Object)
[]
[]
public void MyManagedType$NodeView.setAnnotatedValue(java.lang.String)
[]
[]
public java.lang.String MyManagedType$NodeView.getUnannotatedValue()
[]
[]
public void MyManagedType$NodeView.setUnannotatedValue(java.lang.String)
[]
[]
public void MyManagedType$NodeView.setUnannotatedValue(java.lang.Object)
[]
[]
public java.lang.String MyManagedType$NodeView.getAnnotatedValue()
[]
[]
public void MyManagedType$NodeView.unannotatedValue(java.lang.Object)
[]
[]
public void MyManagedType$NodeView.unannotatedValue(groovy.lang.Closure)
[]
[]
public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
[]
[]
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
[]
[]
public final void java.lang.Object.wait() throws java.lang.InterruptedException
[]
[]
public final native java.lang.Class java.lang.Object.getClass()
[]
[]
public final native void java.lang.Object.notify()
[]
[]
public final native void java.lang.Object.notifyAll()
[]
[]

BUILD SUCCESSFUL

Total time: 0.528 secs