|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +declare -r samples_sources="${PWD}/samples" |
| 6 | +declare -r akka_docs_attachments="${PWD}/akka-docs/src/main/paradox/attachments" |
| 7 | +declare -r target_temporal_attachments="${PWD}/target/akka-docs/_attachments" |
| 8 | + |
| 9 | +declare -r temporal_folder="${PWD}/target/zips" |
| 10 | + |
| 11 | +function sed_command() { |
| 12 | + local platform="$(uname -s | tr '[:upper:]' '[:lower:]')" |
| 13 | + |
| 14 | + if [ "${platform}" != "darwin" ]; then |
| 15 | + echo "sed" |
| 16 | + else |
| 17 | + # using gnu-sed on Mac |
| 18 | + echo "gsed" |
| 19 | + fi |
| 20 | +} |
| 21 | + |
| 22 | +## Remove the tags used by Paradox snippets from the codebase in the current folder |
| 23 | +function removeTags() { |
| 24 | + ## remove tags from code |
| 25 | + find . -type f -print0 | xargs -0 $(sed_command) -i "s/\/\/ #.*//g" |
| 26 | +} |
| 27 | + |
| 28 | + |
| 29 | +## Cleanup the temporal folder from previous executions |
| 30 | +function prepareTemporalFolder() { |
| 31 | + rm -rf ${temporal_folder} |
| 32 | + mkdir -p ${temporal_folder} |
| 33 | +} |
| 34 | + |
| 35 | +## Copy a folder with some code into the temporal folder. The |
| 36 | +## copied folder will be renamed to the folder name we want the |
| 37 | +## user to see when unzipping the file. |
| 38 | +## source_name -> folder in `examples` |
| 39 | +## target_name -> folder name the user should see (must not use a numeric prefix of a laguage suffix) |
| 40 | +function fetchProject() { |
| 41 | + source_name=$1 |
| 42 | + target_name=$2 |
| 43 | + echo "Fetching content from [$1] to [$2]" |
| 44 | + cp -a ${source_name} ${temporal_folder}/${target_name} |
| 45 | + rm -rf ${temporal_folder}/${target_name}/target |
| 46 | +} |
| 47 | + |
| 48 | +## Zip the contents in $temporal_folder and create the |
| 49 | +## attachment file (aka, the zip file on the appropriate location) |
| 50 | +function zipAndAttach() { |
| 51 | + zip_name=$1 |
| 52 | + temporal_attachments=$2 |
| 53 | + echo "Preparing zip $1" |
| 54 | + pushd ${temporal_folder} |
| 55 | + removeTags |
| 56 | + zip --quiet -r ${zip_name} * |
| 57 | + cp ${zip_name} ${temporal_attachments} |
| 58 | + echo "Prepared attachment at ${zip_name}" |
| 59 | + popd |
| 60 | +} |
| 61 | + |
| 62 | +mkdir -p ${akka_docs_attachments} |
| 63 | +mkdir -p ${target_temporal_attachments} |
| 64 | + |
| 65 | +## akka-quickstart-java zip file |
| 66 | +prepareTemporalFolder |
| 67 | +fetchProject ${samples_sources}/akka-quickstart-java akka-quickstart |
| 68 | +zipAndAttach ${akka_docs_attachments}/akka-quickstart-java.zip ${target_temporal_attachments} |
| 69 | + |
| 70 | +## akka-quickstart-scala zip file |
| 71 | +prepareTemporalFolder |
| 72 | +fetchProject ${samples_sources}/akka-quickstart-scala akka-quickstart |
| 73 | +zipAndAttach ${akka_docs_attachments}/akka-quickstart-scala.zip ${target_temporal_attachments} |
| 74 | + |
| 75 | +# akka-sample-cluster-java |
| 76 | +prepareTemporalFolder |
| 77 | +fetchProject ${samples_sources}/akka-sample-cluster-java akka-sample-cluster |
| 78 | +zipAndAttach ${akka_docs_attachments}/akka-sample-cluster-java.zip ${target_temporal_attachments} |
| 79 | + |
| 80 | +# akka-sample-cluster-scala |
| 81 | +prepareTemporalFolder |
| 82 | +fetchProject ${samples_sources}/akka-sample-cluster-scala akka-sample-cluster |
| 83 | +zipAndAttach ${akka_docs_attachments}/akka-sample-cluster-scala.zip ${target_temporal_attachments} |
| 84 | + |
| 85 | +# akka-sample-distributed-data-java |
| 86 | +prepareTemporalFolder |
| 87 | +fetchProject ${samples_sources}/akka-sample-distributed-data-java akka-sample-distributed-data |
| 88 | +zipAndAttach ${akka_docs_attachments}/akka-sample-distributed-data-java.zip ${target_temporal_attachments} |
| 89 | + |
| 90 | +# akka-sample-distributed-data-scala |
| 91 | +prepareTemporalFolder |
| 92 | +fetchProject ${samples_sources}/akka-sample-distributed-data-scala akka-sample-distributed-data |
| 93 | +zipAndAttach ${akka_docs_attachments}/akka-sample-distributed-data-scala.zip ${target_temporal_attachments} |
| 94 | + |
| 95 | +# akka-sample-fsm-java |
| 96 | +prepareTemporalFolder |
| 97 | +fetchProject ${samples_sources}/akka-sample-fsm-java akka-sample-fsm |
| 98 | +zipAndAttach ${akka_docs_attachments}/akka-sample-fsm-java.zip ${target_temporal_attachments} |
| 99 | + |
| 100 | +# akka-sample-fsm-scala |
| 101 | +prepareTemporalFolder |
| 102 | +fetchProject ${samples_sources}/akka-sample-fsm-scala akka-sample-fsm |
| 103 | +zipAndAttach ${akka_docs_attachments}/akka-sample-fsm-scala.zip ${target_temporal_attachments} |
| 104 | + |
| 105 | +# akka-sample-sharding-java |
| 106 | +prepareTemporalFolder |
| 107 | +fetchProject ${samples_sources}/akka-sample-sharding-java akka-sample-sharding |
| 108 | +zipAndAttach ${akka_docs_attachments}/akka-sample-sharding-java.zip ${target_temporal_attachments} |
| 109 | + |
| 110 | +# akka-sample-sharding-scala |
| 111 | +prepareTemporalFolder |
| 112 | +fetchProject ${samples_sources}/akka-sample-sharding-scala akka-sample-sharding |
| 113 | +zipAndAttach ${akka_docs_attachments}/akka-sample-sharding-scala.zip ${target_temporal_attachments} |
| 114 | + |
| 115 | +# akka-sample-kafka-to-sharding-scala |
| 116 | +prepareTemporalFolder |
| 117 | +fetchProject ${samples_sources}/akka-sample-kafka-to-sharding-scala akka-sample-kafka-to-sharding |
| 118 | +zipAndAttach ${akka_docs_attachments}/akka-sample-kafka-to-sharding-scala.zip ${target_temporal_attachments} |
0 commit comments