Java bookstore project (Spring Boot + Thymeleaf + JPA + REST)
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.

101 lines
2.3 KiB

  1. # Maintainer: Pekka Helenius <fincer89@hotmail.com>
  2. pkgname=bookstore-project
  3. packagetype=war
  4. # Valid targets for Maven build: dev, prod
  5. #
  6. target='dev'
  7. # Sensitive database credentials file. Please provide separately.
  8. # NOTE: This file is bundled only when 'prod' profile is enabled
  9. #
  10. # Template file: bookstore/src/main/resources/database-prod.default.properties
  11. #
  12. prod_db_credentials_file="${PWD}/database-prod.properties"
  13. # Skip compile time unit tests? 1 = skip; other values = do not skip
  14. #
  15. maven_skip_tests=1
  16. # Compile unit test classes? 0 = do not compile; other values = compile
  17. #
  18. maven_tests_compile=0
  19. packagename=Bookstore.${packagetype}
  20. tomcat_ver=9
  21. java_ver=8
  22. pkgver=287.5d9097f
  23. pkgrel=1
  24. pkgdesc='Bookstore Java server example project'
  25. arch=('any')
  26. url='https://github.com/Fincer/java-bookstore'
  27. license=('GPL')
  28. depends=(
  29. "tomcat${tomcat_ver}"
  30. "mariadb"
  31. "java-runtime>=${java_ver}"
  32. )
  33. makedepends=('maven' 'git')
  34. source=(
  35. "$pkgname::git+${url}.git"
  36. "bookstore-tomcat.xml"
  37. )
  38. sha256sums=('SKIP'
  39. '6a115dc9132cd04f5b740575612d6aeb744db8620e8249776dad8222ca917cbf')
  40. pkgver() {
  41. cd $pkgname
  42. if [[ $(git describe) ]]; then
  43. git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
  44. else
  45. echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
  46. fi
  47. }
  48. prepare() {
  49. cd $pkgname/bookstore
  50. case ${target} in
  51. dev|prod)
  52. sed -r -i "s|^(.*spring\.profiles\.active[ ]*=[ ]*)(.*)$|\1$target|" src/main/resources/application.properties
  53. ;;
  54. *)
  55. echo "Invalid profile configuration.\n"
  56. exit 1
  57. ;;
  58. esac
  59. if [[ ${target} == "prod" ]] && [[ -f ${prod_db_credentials_file} ]]; then
  60. cp ${prod_db_credentials_file} src/main/resources/
  61. fi
  62. }
  63. build() {
  64. MAVEN_PARAMS=()
  65. if [[ ${maven_skip_tests} -eq 1 ]]; then
  66. MAVEN_PARAMS+=("-DskipTests")
  67. fi
  68. if [[ ${maven_tests_compile} -eq 0 ]]; then
  69. tests_compile_boolean="true"
  70. else
  71. tests_compile_boolean="false"
  72. fi
  73. MAVEN_PARAMS+=(-Dmaven.test.skip=${tests_compile_boolean})
  74. cd $pkgname/bookstore
  75. mvn package ${MAVEN_PARAMS[*]}
  76. }
  77. package() {
  78. cd $pkgname/bookstore
  79. install -Dm0644 -t ${pkgdir}/opt/bookstore/ target/${packagename}
  80. install -Dm0644 ../../bookstore-tomcat.xml ${pkgdir}/etc/tomcat${tomcat_ver}/Catalina/localhost/bookstore.xml
  81. }