Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto generation of serial version uid using maven2 plugin

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

like image 989
Joe Avatar asked Nov 17 '09 03:11

Joe


People also ask

How do you generate unique serialVersionUID?

File -> Settings -> Editor -> Inspections -> Java -> Serialization issues : Find serialization class without serialVersionUID and check it. Back to the editor, clicks on the class name, ALT + ENTER (Windows), it will prompts the Add serialVersionUID field option. A new serialVersionUID is auto-generated.

How do I generate serialization version ID in Intellij?

You can generate SerialVersionUID in intellij by pressing ctrl + shift +A (find action) and then typing Serializable class without serialVersionUID and toggle it from Off to On.

What is use of serial version UID?

Simply put, we use the serialVersionUID attribute to remember versions of a Serializable class to verify that a loaded class and the serialized object are compatible. The serialVersionUID attributes of different classes are independent. Therefore, it is not necessary for different classes to have unique values.

What is serial version UID in Java?

The serialization at runtime associates with each serializable class a version number called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization.


2 Answers

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

like image 129
Laurent Avatar answered Oct 03 '22 08:10

Laurent


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.

like image 25
Jason Gritman Avatar answered Oct 03 '22 06:10

Jason Gritman