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.

87 lines
2.7 KiB

10 years ago
  1. #!/bin/bash
  2. # restore maven dependencies downloaded in a previous build,
  3. # so they do not have to be downloaded again.
  4. # /tmp/artifacts will only be present in the incremental build scenario
  5. # in which the target image name is an existing docker image which contains
  6. # dependencies from a prior build execution.
  7. function restore_saved_artifacts() {
  8. if [ -f /tmp/artifacts/maven.tar.gz ]; then
  9. pushd / &> /dev/null
  10. echo -n "Restoring saved artifacts from prior build..."
  11. tar zxf /tmp/artifacts/maven.tar.gz
  12. echo "...done"
  13. popd &> /dev/null
  14. fi
  15. }
  16. # Source code provided to STI will be bind-mounted at /tmp/src
  17. # and then copied into /opt/wildfly/source for building.
  18. local_source_dir=/opt/wildfly/source
  19. mkdir -p $local_source_dir
  20. # Resulting WAR files will be deployed to /wildfly/standalone/deployments
  21. deploy_dir=/wildfly/standalone/deployments
  22. mkdir -p $deploy_dir
  23. # Copy the source from the bind mount in preparation for compilation
  24. cp -ad /tmp/src/* $local_source_dir
  25. # If a pom.xml is present, this is a normal build scenario
  26. # so run maven.
  27. if [ -f "$local_source_dir/pom.xml" ]; then
  28. # restore any maven dependencies which will be present if this is an
  29. # incremental build
  30. restore_saved_artifacts
  31. pushd $local_source_dir &> /dev/null
  32. JAVA_HOME=/etc/alternatives/java_sdk_1.7.0
  33. mvn clean package -Popenshift -DskipTests
  34. err=$?
  35. if [ $err -ne 0 ]; then
  36. echo "Aborting due to error code $err from mvn package"
  37. exit $err
  38. fi
  39. echo "Copying built war files into $deploy_dir for later deployment..."
  40. if [ -d $local_source_dir/target ]; then
  41. cp $local_source_dir/target/*.war $deploy_dir >& /dev/null
  42. fi
  43. if [ -d $local_source_dir/deployments ]; then
  44. cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null
  45. fi
  46. if [ -d $local_source_dir/cfg ]; then
  47. echo "Copying config files from project..."
  48. cp cfg/* /wildfly/standalone/configuration
  49. fi
  50. if [ -d $local_source_dir/modules ]; then
  51. echo "Copying modules from project..."
  52. mkdir /wildfly/provided_modules
  53. cp -r modules/* /wildfly/provided_modules
  54. fi
  55. echo "...done"
  56. popd &> /dev/null
  57. else
  58. echo "Copying binaries in source directory into $deploy_dir for later deployment..."
  59. if [ -d $local_source_dir/target ]; then
  60. cp $local_source_dir/target/*.war $deploy_dir >& /dev/null
  61. fi
  62. if [ -d $local_source_dir/deployments ]; then
  63. cp $local_source_dir/deployments/*.war $deploy_dir >& /dev/null
  64. fi
  65. if [ -d $local_source_dir/cfg ]; then
  66. echo "Copying config files from project..."
  67. cp cfg/* /wildfly/standalone/configuration
  68. fi
  69. if [ -d $local_source_dir/modules ]; then
  70. echo "Copying modules from project..."
  71. mkdir /wildfly/provided_modules
  72. cp -r modules/* /wildfly/provided_modules
  73. fi
  74. echo "...done"
  75. fi