Search code examples
jpaannotationsproguardshrinknegate

How to unkeep or force remove @javax.persistence.Transient annotated methods in JPA entities in ProGuard?


I'm extracting JPA entities into a separate Fat/Uber jar for external system to use. ProGuard is used through com.github.wvengen:proguard-maven-plugin to shrink all other unused code. I want to keep all methods in JPA entities except ones annotated by @javax.persistence.Transient annotation. I've found "!transient" for field modifiers in ProGuard rules, but seems that [email protected] for methods does not work :( Can I reach the same effect somehow for methods by other way ?


Solution

  • Unfortunately I've not got an answer on this question and was not be able to solve this by ProGuard+MavenPlugin directly, but I've resolved this problem with one additional step before run a ProGuard. I've just used ByteBuddy + Maven plugin on Maven phase before you run ProGuard Maven plugin and it will then optimize/remove the rest unused stuff, see details about byte-buddy instrumentation step here: byte-buddy remove/strip methods