fixed this
[jprojects-scripts.git] / build-dist-all.sh
1 #!/bin/bash
2
3 . ./.jprojects.sh || exit 255
4
5 for project in ${LIST}; do
6         if [ ! -d "${JPROJECTS_HOME}/${project}" ]
7         then
8                 echo "$0: Project '${project}' does not exist."
9                 continue;
10         fi
11
12         echo "$0: Executing '${project}' ..."
13         P=${project%/*}
14
15         echo "$0: P='${P}'"
16         cd "${JPROJECTS_HOME}/${P}" || exit 255
17
18         if [ ! -e "build.xml" ]
19         then
20                 echo "$0: No build.xml found, skipping project '${P}'."
21                 continue
22         fi
23
24         if [ -x "${ANT_BIN}" -a "$1" != "d" ]
25         then
26                 # Cleanup project and build JAR
27                 ${ANT_BIN} clean jar
28
29                 # Save status
30                 STATUS="$?"
31
32                 # Has it failed?
33                 if [ "${STATUS}" != "0" ]
34                 then
35                         # This has failed, so try "dist"
36                         ${ANT_BIN} clean dist
37                         STATUS="$?"
38
39                         # Still failing? Oh, to bad
40                         if [ "${STATUS}" != "0" ]
41                         then
42                                 echo "$0: Failed to build '${project}'."
43                                 exit 1
44                         fi
45                 fi
46         fi
47
48         if [ ! -f "./dist.sh" ]
49         then
50                 echo "$0: Project '${project}' has no dist.sh"
51         elif [ ! -e "./dist.sh" ]
52         then
53                 echo "$0: Error: Project '${project}' has non-executable dist.sh!"
54                 exit 1
55         else
56                 if [ "$1" = "r" ]
57                 then
58                         ./dist.sh r
59                 else
60                         ./dist.sh
61                 fi
62         fi
63 done
64
65 echo "$0: All done."
66 exit 0