Created
May 23, 2018 12:54
-
-
Save sasuw/c92787de5ef72aa43183c69bb76fd133 to your computer and use it in GitHub Desktop.
Automatically modify Java files adding serialVersionUID for all classes implementing Serializable, if they do not already contain serialVersionUID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !#!/bin/bash | |
| grep -lir --include \*.java -e 'implements java.io.Serializable' -e 'implements Serializable' . | xargs grep -Lir -e 'serialVersionUID' | while read -r line ; do awk '/implements (java.io.)?Serializable/{print;print "\n\t\nprivate static final long serialVersionUID = 1L;";next}1' $line > temp.java && mv temp.java $line ; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment