forked from eclipse-embed-cdt/eclipse-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_project_settings.sh
executable file
·103 lines (94 loc) · 5.46 KB
/
do_project_settings.sh
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
99
100
101
102
#!/bin/bash
###############################################################################
# Copyright (c) 2018, 2020 Kichwa Coders Ltd and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
###############################################################################
set -e
##
# This script is reused by other projects, if so, COREPROJECT should be set
# to the project to use a basis for project settings
##
: ${COREPROJECT:=plugins/org.eclipse.embedcdt.core}
##
# Setup Eclipse Core Preferences
##
git ls-files -- \*\*/.project | while read i ; do
d=`dirname $i`;
mkdir -p $d/.settings
if ! test -e $d/.settings/org.eclipse.core.resources.prefs; then
echo 'eclipse.preferences.version=1' > $d/.settings/org.eclipse.core.resources.prefs
echo 'encoding/<project>=UTF-8' >> $d/.settings/org.eclipse.core.resources.prefs
fi
if ! grep 'encoding/<project>=UTF-8' $d/.settings/org.eclipse.core.resources.prefs > /dev/null; then
echo 'encoding/<project>=UTF-8' >> $d/.settings/org.eclipse.core.resources.prefs
fi
if ! grep 'eclipse.preferences.version=1' $d/.settings/org.eclipse.core.resources.prefs > /dev/null; then
echo 'eclipse.preferences.version=1' >> $d/.settings/org.eclipse.core.resources.prefs
fi
done
##
# Copy JDT/PDE preferences
##
git ls-files -- \*\*/.project ":!$COREPROJECT/.project" | while read i ; do
d=`dirname $i`;
natures=$(xmllint --xpath 'string(//projectDescription/natures)' $i)
mkdir -p $d/.settings
# JDT
if [[ $natures == *"org.eclipse.jdt.core.javanature"* ]]; then
cp $COREPROJECT/.settings/org.eclipse.jdt.* $d/.settings
# For test plug-ins we are more lenient so don't warn on some items
if echo $i | grep -E '\.tests?[/\.]' > /dev/null; then
sed -i \
'-es@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore@' \
'[email protected]=warning@org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore@' \
'[email protected][email protected]=ignore@' \
'[email protected]=warning@org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore@' \
'[email protected][email protected]=ignore@' \
'[email protected][email protected]=ignore@' \
'[email protected]=warning@org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore@' \
'[email protected][email protected]=warning@' \
'[email protected]=warning@org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore@' \
'[email protected][email protected]=ignore@' \
'[email protected]=warning@org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore@' \
'[email protected]=warning@org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore@' \
'[email protected][email protected]=ignore@' \
'[email protected]=warning@org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore@' \
$d/.settings/org.eclipse.jdt.core.prefs
fi
else
rm -f $d/.settings/org.eclipse.jdt*.prefs
fi
# PDE
if [[ $natures == *"org.eclipse.pde.PluginNature"* ]]; then
cp $COREPROJECT/.settings/org.eclipse.pde.prefs $d/.settings
cp $COREPROJECT/.settings/org.eclipse.pde.api.tools.prefs $d/.settings
if echo $i | grep -E '\.tests?[/\.]' > /dev/null; then
sed -i \
$d/.settings/org.eclipse.pde.prefs
fi
else
rm -f $d/.settings/org.eclipse.pde*.prefs
fi
done
##
# Verify API Tooling is enabled for all non-test/example bundles
##
git ls-files -- \*\*/.project | while read i ; do
d=`dirname $i`;
natures=$(xmllint --xpath 'string(//projectDescription/natures)' $i)
if [[ $natures == *"org.eclipse.pde.PluginNature"* ]] && [[ $natures == *"org.eclipse.jdt.core.javanature"* ]]; then
if [[ $natures != *"org.eclipse.pde.api.tools.apiAnalysisNature"* ]]; then
if ! echo $i | grep -E '\.tests?[/\.]' > /dev/null && ! echo $i | grep -E '\.examples?[/\.]' > /dev/null; then
echo "$d is missing API Tools Nature - Turn it on in Eclipse by 1) Right-click project 2) Plug-in tools -> API Tools Setup"
exit 1
fi
fi
fi
done