Jepp, no more these projects
[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                 # Cleanup project and build JAR
31                 ${ANT_BIN} clean jar
32
33                 # Save status
34                 STATUS="$?"
35
36                 # Has it failed?
37                 if [ "${STATUS}" != "0" ]
38                 then
39                         # This has failed, so try "dist"
40                         ${ANT_BIN} clean dist
41                         STATUS="$?"
42
43                         # Still failing? Oh, to bad
44                         if [ "${STATUS}" != "0" ]
45                         then
46                                 echo "$0: Failed to build '${project}'."
47                                 exit 1
48                         fi
49                 fi
50         fi
51
52         if [ ! -f "./dist.sh" ]
53         then
54                 echo "$0: Project '${project}' has no dist.sh"
55         elif [ ! -e "./dist.sh" ]
56         then
57                 echo "$0: Error: Project '${project}' has non-executable dist.sh!"
58                 exit 1
59         else
60                 if [ "$1" = "r" ]
61                 then
62                         ./dist.sh r
63                 else
64                         ./dist.sh
65                 fi
66         fi
67 done
68
69 echo "$0: All done."
70 exit 0