Added docs and wildfly paths
[jprojects-scripts.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 # WildFly module base path
10 WILDFLY_MODULE_BASE_PATH="${HOME}/wildfly_domain/modules/org/mxchange"
11
12 # And for this "module" (as WildFly calls it)
13 WILDFLY_MODULE_PATH="${WILDFLY_MODULE_BASE_PATH}/${NAME}/main"
14
15 # module.xml
16 WILDFLY_MODULE_XML_FILE="wildfly/module.xml"
17
18 # Glassfish base path (domain)
19 GLASSFISH_BASE_PATH="${HOME}/gf_domain/domain/lib"
20
21 # Generate list
22 LIST=`find ../*/lib/${NAME}.jar`
23 LIST="${LIST} `find ../*/*-ejb/lib/${NAME}.jar`"
24 LIST="${LIST} ${WILDFLY_MODULE_PATH}"
25
26 if [ -d "${GLASSFISH_BASE_PATH}" ]
27 then
28         echo "$0: Glassfish personal domain found, adding to LIST ..."
29         LIST="${LIST} ${GLASSFISH_BASE_PATH}"
30 fi
31
32 if [ ! -f "${DIST}" ]
33 then
34         echo "$0: '${DIST}' not found."
35         exit 1
36 elif [ ! -d "${WILDFLY_MODULE_BASE_PATH}" ]
37 then
38         echo "$0: WildFly base path '${WILDFLY_MODULE_BASE_PATH}' not created."
39         exit 1
40 elif [ ! -d "${WILDFLY_MODULE_PATH}" ]
41 then
42         mkdir -vp "${WILDFLY_MODULE_PATH}"
43 fi
44
45 for target in ${LIST};
46 do
47         if [ -d "${target}" ]
48         then
49                 cp -v "${DIST}" "${target}"
50         elif [ -f "${target}" ]
51         then
52                 cp -v "${DIST}" "${target}"
53         else
54                 echo "$0: Target '${target}' not found."
55         fi
56 done
57
58 # Copy module.xml ...
59 if [ -f "${WILDFLY_MODULE_XML_FILE}" ]
60 then
61         echo "$0: Generating module.xml ..."
62         XML_CONTENT=`cat "${WILDFLY_MODULE_XML_FILE}"`
63         XML_CONTENT="${XML_CONTENT//NAME/$NAME}"
64         echo "${XML_CONTENT}" > "${WILDFLY_MODULE_PATH}/module.xml"
65 fi
66
67 echo "$0: All done."
68 exit 0