]> git.mxchange.org Git - jcountry-lib.git/blob - dist.sh
updated dist.sh/.gitattributes
[jcountry-lib.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 [ -d "${GLASSFISH_BASE_PATH}" ]
49 then
50         echo "$0: Glassfish personal domain found, adding to LIST ..."
51         LIST="${LIST} ${GLASSFISH_BASE_PATH}"
52 fi
53
54 if [ -d "${PERSONAL_DOMAIN_PATH}" ]
55 then
56         echo "$0: Personal domain found, adding to LIST ..."
57         LIST="${LIST} ${PERSONAL_DOMAIN_PATH}"
58 fi
59
60 if [ ! -f "${DIST}" ]
61 then
62         echo "$0: '${DIST}' not found."
63         exit 1
64 elif [ ! -d "${WILDFLY_MODULE_BASE_PATH}" ]
65 then
66         echo "$0: WildFly base path '${WILDFLY_MODULE_BASE_PATH}' not created."
67 elif [ ! -d "${WILDFLY_MODULE_PATH}" ]
68 then
69         mkdir -vp "${WILDFLY_MODULE_PATH}"
70 fi
71
72 for project in ${LIST};
73 do
74         if [ -d "${project}" ]
75         then
76                 cp -v "${DIST}" "${project}"
77         elif [ -f "${project}" ]
78         then
79                 cp -v "${DIST}" "${project}"
80         else
81                 echo "$0: Project '${project}' not found."
82         fi
83 done
84
85 if [ -n "${GLASSFISH_SSH_USER}" -a -n "${GLASSFISH_SSH_SERVER}" -a -n "${GLASSFISH_SSH_PATH}" ]
86 then
87         if [ "$1" != "r" -a "${NAME}" != "jcore" -a "${NAME}" != "jcore-swing" ]
88         then
89                 echo "$0: Copying to remote '${GLASSFISH_SSH_SERVER}' ..."
90                 scp "${DIST}" "${GLASSFISH_SSH_USER}@${GLASSFISH_SSH_SERVER}:${GLASSFISH_SSH_PATH}" || exit 255
91         fi
92 else
93         echo "$0: SSH upload disabled."
94 fi
95
96 # Copy module.xml ...
97 if [ -f "${WILDFLY_MODULE_XML_FILE}" ]
98 then
99         echo "$0: Generating module.xml ..."
100         XML_CONTENT=$(cat "${WILDFLY_MODULE_XML_FILE}")
101         XML_CONTENT="${XML_CONTENT//NAME/$NAME}"
102         echo "${XML_CONTENT}" > "${WILDFLY_MODULE_PATH}/module.xml"
103 fi
104
105 echo "$0: All done."
106 exit 0