]> git.mxchange.org Git - jfinancials-core.git/blob - dist.sh
Continued:
[jfinancials-core.git] / dist.sh
1 #!/bin/bash
2
3 # Name of this project, detected by it's base path
4 NAME="${PWD##*/}"
5
6 # Generated JAR file
7 DIST="dist/${NAME}.jar"
8
9 # Configuration file
10 DIST_CONFIG_FILE="${HOME}/.jprojects-dist.sh"
11
12 # WildFly module base path
13 WILDFLY_MODULE_BASE_PATH="${HOME}/wildfly_domain/modules/org/mxchange"
14
15 # And for this "module" (as WildFly calls it)
16 WILDFLY_MODULE_PATH="${WILDFLY_MODULE_BASE_PATH}/${NAME}/main"
17
18 # module.xml
19 WILDFLY_MODULE_XML_FILE="wildfly/module.xml"
20
21 # Glassfish base path (domain)
22 GLASSFISH_BASE_PATH="${HOME}/gf_domain/lib"
23
24 # Windows personal domain
25 PERSONAL_DOMAIN_PATH="${HOME}/personal_domain/lib"
26
27 # Is the configuration file there?
28 if [ ! -f "${DIST_CONFIG_FILE}" ]
29 then
30         echo "$0: Configuration file '${DIST_CONFIG_FILE}' not found"
31         echo
32         echo "Following variables are needed for SSH upload:"
33         echo "- GLASSFISH_SSH_PATH"
34         echo "- GLASSFISH_SSH_USER"
35         echo "- GLASSFISH_SSH_SERVER"
36         echo
37         echo "And create a password-less SSH key."
38         sleep 3
39 else
40         # Load it
41         source "${DIST_CONFIG_FILE}"
42 fi
43
44 # Generate list
45 LIST=$(find ../*/lib/${NAME}.jar)
46 LIST="${LIST} ${WILDFLY_MODULE_PATH}"
47
48 if [ "${NAME}" != "jcore" -a "${NAME}" != "jcore-swing" ]
49 then
50         if [ -d "${GLASSFISH_BASE_PATH}" ]
51         then
52                 echo "$0: Glassfish personal domain found, adding to LIST ..."
53                 LIST="${LIST} ${GLASSFISH_BASE_PATH}"
54         fi
55
56         if [ -d "${PERSONAL_DOMAIN_PATH}" ]
57         then
58                 echo "$0: Personal domain found, adding to LIST ..."
59                 LIST="${LIST} ${PERSONAL_DOMAIN_PATH}"
60         fi
61 else
62         echo "$0: Not going to add '${NAME}' to distribution list, is JavaSE project."
63 fi
64
65 if [ ! -f "${DIST}" ]
66 then
67         echo "$0: '${DIST}' not found."
68         exit 1
69 elif [ ! -d "${WILDFLY_MODULE_BASE_PATH}" ]
70 then
71         echo "$0: WildFly base path '${WILDFLY_MODULE_BASE_PATH}' not created."
72 elif [ ! -d "${WILDFLY_MODULE_PATH}" ]
73 then
74         mkdir -vp "${WILDFLY_MODULE_PATH}"
75 fi
76
77 for project in ${LIST};
78 do
79         if [ -d "${project}" ]
80         then
81                 cp -v "${DIST}" "${project}"
82         elif [ -f "${project}" ]
83         then
84                 cp -v "${DIST}" "${project}"
85         else
86                 echo "$0: Project '${project}' not found."
87         fi
88 done
89
90 if [ "$1" = "r" -o "${NAME}" = "jcore" -o "${NAME}" = "jcore-swing" ]
91 then
92         echo "$0: Not uploading '${NAME}' or parameter 'r' provided."
93 elif [ -n "${GLASSFISH_SSH_USER}" -a -n "${GLASSFISH_SSH_SERVER}" -a -n "${GLASSFISH_SSH_PATH}" ]
94 then
95         echo "$0: Copying to remote '${GLASSFISH_SSH_SERVER}' ..."
96         scp "${DIST}" "${GLASSFISH_SSH_USER}@${GLASSFISH_SSH_SERVER}:${GLASSFISH_SSH_PATH}" || exit 255
97 else
98         echo "$0: SSH upload disabled."
99 fi
100
101 # Copy module.xml ...
102 if [ -f "${WILDFLY_MODULE_XML_FILE}" ]
103 then
104         echo "$0: Generating module.xml ..."
105         XML_CONTENT=$(cat "${WILDFLY_MODULE_XML_FILE}")
106         XML_CONTENT="${XML_CONTENT//NAME/$NAME}"
107         echo "${XML_CONTENT}" > "${WILDFLY_MODULE_PATH}/module.xml"
108 fi
109
110 echo "$0: All done."
111 exit 0