Is there a maven plugin which automatically calculates and updates serial version uid for all java class files implementing the Serializable interface?
+2
A:
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.
Jason Gritman
2009-11-17 06:48:31
Did you mean `process-sources`?
Pascal Thivent
2009-11-17 10:17:30
Yes that is what I meant. Editing now. Thanks!
Jason Gritman
2009-11-17 14:05:11
I will probably go with antrun for the time being. thanks very much
Joshua
2009-11-23 12:00:41
+2
A:
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).
Pascal Thivent
2009-11-17 10:15:47