Reputation: 15311
Is there a maven plugin which automatically calculates and updates serial version uid for all java class files implementing the Serializable interface?
Upvotes: 5
Views: 3515
Reputation: 570305
The compile mojo of the AspectJ compiler Maven Plugin has a XaddSerialVersionUI parameter that:
Causes the compiler to calculate and add the
SerialVersionUID
field to any type implementingSerializable
that is affected by an aspect. The field is calculated based on the class before weaving has taken place.
So you could apply a fake or empty aspect and use this plugin to weave your classes (it's not ideal but I don't think that modifying Java sources directly is really a good practice neither).
Upvotes: 2
Reputation: 14401
A Maven module named maven-svuid-plugin is available to do what you want. Please look at https://bitbucket.org/lp/maven-svuid-plugin/wiki/Home
Upvotes: 4
Reputation: 5301
I don't know of any Maven plugin that can add this functionality, but you could call the Serialver Ant task using the Maven AntRun Plugin in the process-sources
phase of the lifecycle.
Upvotes: 3