12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #!/bin/bash
- #set -x
- args=("$@")
- function printHelp() {
- echo 'Shell Script utility to publish the modules of this project to Maven using the Gradle Wrapper'
- echo 'You can decide what to publish with the following arguments:'
- echo ' 1) all : tells the script to publish all the modules'
- echo ' 2) A list of modules (ex. components, core,...)'
- echo ''
- echo 'Options:'
- echo '-r to also automatically release the artifacts once they are published'
- echo '-c to clean the project before everything else'
- echo ''
- echo ''
- echo 'Before running this script makes sure that your JAVA_HOME environment variable is set and correct'
- }
- function checkArgs() {
- for var in "${args[@]}"; do
- if [ "$var" == "$1" ]; then
- ret="true"
- return
- fi
- done
- ret="false"
- }
- function checkRelease() {
- local ret=""
- checkArgs '-r'
- if [ "$ret" == "true" ]; then
- rel_ret='closeAndReleaseRepository'
- else
- rel_ret=''
- fi
- }
- function publishModules() {
- local rel_ret=""
- local tmp=""
- checkRelease
- if [ "$rel_ret" != "" ]; then
- echo 'Publishing and RELEASING specified modules!'
- else
- echo 'Publishing specified modules!'
- fi
- for var in "${args[@]}"; do
- tmp=$var # I don't fucking know why, it just works this way
- if [ "$var" != "all" ] && [ "$var" != "-h" ] && [ "$var" != "-r" ] && [ "$var" != "-c" ]; then
- ./gradlew "$tmp:publish"
- if [ "$rel_ret" != "" ]; then
- ./gradlew "$tmp:closeAndReleaseRepository"
- fi
- fi
- done
- }
- function main() {
- local ret=""
- if [ $# == 0 ]; then
- echo "No args provided"
- exit 1
- else
- cd ..
- fi
- checkArgs '-h'
- if [ "$ret" == "true" ]; then
- printHelp
- exit 1
- fi
- checkArgs '-c'
- if [ "$ret" == "true" ]; then
- ./gradlew clean
- fi
- checkArgs 'all'
- if [ "$ret" == "true" ]; then
- checkRelease
- ./gradlew publish "$rel_ret"
- exit 0
- fi
- publishModules
- }
- main "$@"
|