forked from eclipse-birt/birt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-settings
executable file
·98 lines (98 loc) · 3.61 KB
/
copy-settings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
function addLine() {
new_file="$1"
line="$2"
echo "file: $new_file, line: $line"
re='(.*)=(.*)'
if [[ $line =~ $re ]]
then
key=${BASH_REMATCH[1]}
value=${BASH_REMATCH[2]}
echo " new: $key = $value"
if grep -q "$key=.*" "$new_file"
then
old_pat="$key=.*"
new_pat="$key=$value"
echo " s/$old_pat/$new_pat/"
sed --quiet -i -e "s/$old_pat/$new_pat/ ; p" "$new_file"
else
new_pat="$key=$value"
echo " appending $new_pat"
echo "$new_pat" >> "$new_file"
fi
fi
}
for filename in $(find . -name ".project")
do
dir="$(dirname $filename)"
if grep -q "org\.eclipse\.jdt\.core\.javanature" "$dir/.project"; then
echo "java nature found in $dir"
#save previous settings
if [ -d "$dir/.settings" ]
then
if [ -d "/tmp/previous-settings" ]
then
rm -rf "/tmp/previous-settings"
fi
mkdir -p "/tmp/previous-settings"
for f in "org.eclipse.core.runtime.prefs" "org.eclipse.jdt.core.prefs" "org.eclipse.jdt.ui.prefs" "org.eclipse.pde.api.tools.prefs" "org.eclipse.pde.prefs"
do
file="$dir/.settings/$f"
if [ -f "$file" ]; then
mv "$file" "/tmp/previous-settings"
fi
done
fi
cp -r $HOME/git/eclipse.platform.ui/bundles/org.eclipse.ui/.settings "$dir"
#use java 1.8 instead of java 11
# was 11
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8"
# was 11
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.compliance=1.8"
# was 11
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.source=1.8"
#copy back previous settings
if [ -d "/tmp/previous-settings" ]
then
for file in $(find /tmp/previous-settings -name "*.prefs")
do
new_file="$dir/.settings/$(basename $file)"
cat $file | while read line || [[ -n $line ]]
do
re='^org\.eclipse\.jdt\.core\.formatter\.*'
if [[ ! $line =~ $re ]]
then
addLine "$new_file" "$line"
fi
done
done
fi
#new settings - relax problem severity
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.discouragedReference=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.incompleteClasspath=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.unusedImport=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning"
# was error
addLine "$dir/.settings/org.eclipse.jdt.core.prefs" "org.eclipse.jdt.core.compiler.problem.unusedLocal=warning"
# was 0
addLine "$dir/.settings/org.eclipse.pde.prefs" "compilers.p.not-externalized-att=1"
# was 0
addLine "$dir/.settings/org.eclipse.pde.prefs" "compilers.p.deprecated=1"
# was 0
addLine "$dir/.settings/org.eclipse.pde.prefs" "compilers.p.unknown-attribute=1"
fi
done