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