Question

Is there a maven plugin which automatically calculates and updates serial version uid for all java class files implementing the Serializable interface?

Was it helpful?

Solution

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.

OTHER TIPS

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

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 implementing Serializable 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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top