Continued:
[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 [ "${project}" = "jprojects-scripts" ]
7         then
8                 echo "$0: Skipping jprojects-scripts ..."
9                 continue
10         elif [ ! -d "${JPROJECTS_HOME}/${project}" ]
11         then
12                 echo "$0: Project '${project}' does not exist."
13                 continue
14         fi
15
16         echo "$0: Executing '${project}' ..."
17         P=${project%/*}
18
19         echo "$0: P='${P}'"
20         cd "${JPROJECTS_HOME}/${P}" || exit 255
21
22         if [ ! -e "build.xml" ]
23         then
24                 echo "$0: No build.xml found, skipping project '${P}'."
25                 continue
26         fi
27
28         if [ -x "${ANT_BIN}" -a "$1" != "d" ]
29         then
30                 if [ "$1" = "c" ]
31                 then
32                         # Cleanup
33                         ${ANT_BIN} clean
34                 fi
35
36                 # Build JAR
37                 "${ANT_BIN}" jar
38
39                 # Save status
40                 STATUS="$?"
41
42                 # Has it failed?
43                 if [ "${STATUS}" != "0" ]
44                 then
45                         # This has failed, so try "dist"
46                         "${ANT_BIN}" dist
47                         STATUS="$?"
48
49                         # Still failing? Oh, to bad
50                         if [ "${STATUS}" != "0" ]
51                         then
52                                 echo "$0: Failed to build '${project}'."
53                                 exit 1
54                         fi
55                 fi
56         fi
57
58         if [ ! -f "./dist.sh" ]
59         then
60                 echo "$0: Project '${project}' has no dist.sh"
61         elif [ ! -e "./dist.sh" ]
62         then
63                 echo "$0: Error: Project '${project}' has non-executable dist.sh!"
64                 exit 1
65         else
66                 if [ "$1" = "r" ]
67                 then
68                         ./dist.sh r
69                 else
70                         ./dist.sh
71                 fi
72         fi
73 done
74
75 echo "$0: All done."
76 exit 0