bf6efec8ccb02543ee0866e7bac382dd3b920da3
[jprojects-scripts.git] / make-javadoc.sh
1 #!/bin/bash
2
3 . ./.jprojects.sh || exit 255
4
5 UPLOAD_SERVER="git.mxchange.org"
6 UPLOAD_BASE_PATH="/var/www/virtual/mxchange.org/docs/htdocs/javadoc"
7
8 for project in ${LIST}; do
9         if [ "${project}" = "jprojects-scripts" ]
10         then
11                 echo "$0: Skipping jprojects-scripts ..."
12                 continue
13         elif [ ! -d "${JPROJECTS_HOME}/${project}" ]
14         then
15                 echo "$0: Project '${project}' does not exist."
16                 continue
17         elif [ ! -d "${JPROJECTS_HOME}/${project}/dist" ]
18         then
19                 echo "$0: Project '${project}' is not generated yet."
20                 continue
21         fi
22
23         IS_BASE_PROJECT=$(echo "${BASE_APPLICATION_NAMES}" | grep "${project}")
24
25         if [ -n "${IS_BASE_PROJECT}" ]
26         then
27                 echo "$0: Project '${project}' is a base project, won't have Javadoc. Skipped ..."
28                 continue
29         fi
30
31         echo "$0: Working on project '${project}' ..."
32         cd "${JPROJECTS_HOME}/${project}" || exit 255
33
34         HAS_FILE=$(find src/ -type f)
35
36         if [ -z "${HAS_FILE}" ]
37         then
38                 echo "$0: Project '${project}' has no files, skipping ..."
39                 continue
40         fi
41
42         echo "$0: Cleaning up Javadoc for '${project}' ..."
43         rm -rf dist/javadoc/
44
45         echo "$0: Generating documentation for '${project}' ..."
46         ${ANT_BIN} javadoc > dist/javadoc.log || exit 255
47         rm -fv dist/javadoc.log
48
49         IS_COMPANY_PROJECT=$(echo "${COMPANY_PROJECTS}" | grep "${project}")
50         if [ -n "${IS_COMPANY_PROJECT}" -a -z "$1" ]
51         then
52                 echo "$0: Not uploading company project='${project}'"
53                 continue
54         fi
55
56         echo "$0: Generating 'javadoc/${project}' on remote server ..."
57         ${SSH_BIN} "${UPLOAD_SERVER}" "mkdir -vp \"${UPLOAD_BASE_PATH}/${project}\""
58
59         echo "$0: Cleaning 'javadoc/${project}' on remote server ..."
60         ${SSH_BIN} "${UPLOAD_SERVER}" "rm  -rf \"${UPLOAD_BASE_PATH}/${project}\"/*" || exit 255
61
62         echo "$0: Uploading Javadoc for '${project}' ..."
63         ${SCP_BIN} -r dist/javadoc/* "${UPLOAD_SERVER}:${UPLOAD_BASE_PATH}/${project}" || exit 255
64
65         echo "$0: Cleaning local documentation for '${project}' ..."
66         rm -rf dist/javadoc/
67 done
68
69 echo "$0: All done."
70 exit 0