title: Is it possible to let ProGuard keep elements with RetentionPolicy.SOURCE?
body: <p>I'm using the <code>@VisibleForTesting</code> annotation located in the Android Support Annotations library, and it looks like this:</p>
  
  <pre><code>@Retention(SOURCE)
  public @interface VisibleForTesting {
  }
  </code></pre>
  
  <p>As I understand it, ProGuard operates on the .class files and since this annotation isn't available at compile time due to its retention policy,  all the annotated methods are stripped away. I'd like to run automated tests on my app and use the methods exposed for testing to verify that the ProGuard configuration doesn't break any use cases.</p>
  
  <p>Is it possible to configure ProGuard to keep these elements somehow? So far I've tried:</p>
  
  <pre><code>-keep @android.support.annotation.VisibleForTesting class *
  -keep class android.support.annotation.** {
      @**.VisibleForTesting *;
  }
  -keep interface android.support.annotation.** {
      @**.VisibleForTesting *;
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>-keep interface android.support.annotation.VisibleForTesting
  
  -keepclasseswithmembers class * {
      @android.support.annotation.VisibleForTesting *;
  }
  
  -keepclassmembers class ** {
      @android.support.annotation.VisibleForTesting *;
  }
  </code></pre>
  
  <p>These two configurations do not work. If I annotate the methods with <code>@Keep</code> as well, and configure ProGuard to keep those methods, the methods are kept and the tests pass. However, by doing that I have to annotate all methods with two annotations.</p>
  
  <p>Is it possible to hook into the annotation processor and override the retention policy for <code>@VisibleForTesting</code>? Or is that already too late in the build process?</p>
  
  <p>Guava's <code>@VisibleForTesting</code> uses <code>RetentionPolicy.CLASS</code>, while Android Support Annotations Library uses <code>RetentionPolicy.SOURCE</code>. I'm considering posting a request to change the policy, but I suppose it's set to <code>SOURCE</code> for a reason, possibly due to performance and a very slightly increased file size?</p>
  
  <p>Are there any options other than using two annotations (<code>@VisibleForTesting</code> and <code>@Keep</code>)?</p>