Common utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. #
  3. # patchjar - for quick patching jar files in a world of maven projects
  4. #
  5. # Usage: patchjar <jar-file> <destination> <dir> [<dir2> <dir3> ...]
  6. #
  7. # jar-file: path to a jar file. you can use relative paths
  8. # destination: a local path or user@host:path
  9. # dirs: any directory with a maven pom.xml file
  10. #
  11. # Rationale: building uber-jars is time-consuming. Uber-jars are wonderful for
  12. # deployment, but can sometimes feel like the slow down iteration cycles.
  13. #
  14. # patchjar runs "mvn compile" in each maven directory, then directly updates
  15. # the jar via "jar uvf". Only the class files that changed are updated.
  16. #
  17. # Once all patches are applied, patchjar copies the jar file to the destination.
  18. #
  19. function die () {
  20. echo >&2 "${1}"
  21. exit 1
  22. }
  23. START_DIR=$(pwd)
  24. JAR="$(cd $(dirname ${1}) && pwd)/$(basename ${1})"
  25. DESTINATION="${2}"
  26. shift 2
  27. MAVEN="mvn -DskipTests=true -Dcheckstyle.skip=true"
  28. for dir in ${@} ; do
  29. cd ${START_DIR} && cd $(cd ${dir} && pwd) \
  30. && ${MAVEN} compile \
  31. && cd target/classes \
  32. && classes="$(find . -type f -mmin -3)" && if [ -z "${classes}" ] ; then classes="./*" ; fi \
  33. && jar uvf ${JAR} ${classes} \
  34. || die "Error building: ${dir}"
  35. done
  36. cd ${START_DIR}
  37. scp ${JAR} ${DESTINATION}