Browse Source

Script to add headers to specified files

OvermindDL1 2 years ago
parent
commit
18d07faad3
3 changed files with 33 additions and 0 deletions
  1. 0
    0
      .meta/LICENSE.header
  2. 13
    0
      .meta/update_all_license_headers.sh
  3. 20
    0
      .meta/update_license_header.sh

src/LICENSE.template → .meta/LICENSE.header View File


+ 13
- 0
.meta/update_all_license_headers.sh View File

@@ -0,0 +1,13 @@
1
+#!/bin/sh
2
+
3
+SOURCE_DIR=`dirname $0`
4
+
5
+export LICENSE_HEADER="$(cat "$SOURCE_DIR/LICENSE.header")"
6
+
7
+if [ -z "$1" ]; then
8
+	find "$SOURCE_DIR/../src/main/java" -iname "*.java" -exec "$SOURCE_DIR/update_license_header.sh" {} \;
9
+else
10
+	for f in "${@}"; do
11
+	 	"$SOURCE_DIR"/update_license_header.sh "$f"
12
+	done
13
+fi

+ 20
- 0
.meta/update_license_header.sh View File

@@ -0,0 +1,20 @@
1
+#!/bin/sh
2
+
3
+SOURCE_DIR=`dirname $0`
4
+
5
+[ -z "$LICENSE_HEADER" ] && export LICENSE_HEADER="$(cat "$SOURCE_DIR/LICENSE.header")"
6
+
7
+ORIGINAL_HEADER="$(sed '/^package/Q' "$1")"
8
+
9
+if [ "$LICENSE_HEADER" = "$ORIGINAL_HEADER" ]; then
10
+	echo "Already has header: $1"
11
+	exit 0
12
+fi
13
+
14
+echo "Adding header to: $1"
15
+
16
+cp "$SOURCE_DIR/LICENSE.header" "~$1.tmp"
17
+echo "" >> "~$1.tmp"
18
+awk '/^package/{i++}i' "$1" >> "~$1.tmp"
19
+mv "~$1.tmp" "$1"
20
+

Loading…
Cancel
Save