gretty.gradle 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. gretty {
  2. servletContainer = "tomcat10"
  3. contextPath = "/"
  4. fileLogEnabled = false
  5. integrationTestTask = 'integrationTest'
  6. httpsEnabled = true
  7. sslKeyStorePath = 'certs/server.p12'
  8. sslKeyStorePassword = 'password'
  9. }
  10. Task prepareAppServerForIntegrationTests = project.tasks.create('prepareAppServerForIntegrationTests') {
  11. group = 'Verification'
  12. description = 'Prepares the app server for integration tests'
  13. doFirst {
  14. project.gretty {
  15. httpPort = -1
  16. }
  17. }
  18. }
  19. project.tasks.matching { it.name == "appBeforeIntegrationTest" }.all { task ->
  20. task.dependsOn prepareAppServerForIntegrationTests
  21. }
  22. project.tasks.matching { it.name == "integrationTest" }.all {
  23. task -> task.doFirst {
  24. def gretty = project.gretty
  25. String host = project.gretty.host ?: 'localhost'
  26. boolean isHttps = gretty.httpsEnabled
  27. Integer httpPort = integrationTest.systemProperties['gretty.httpPort']
  28. Integer httpsPort = integrationTest.systemProperties['gretty.httpsPort']
  29. int port = isHttps ? httpsPort : httpPort
  30. String contextPath = project.gretty.contextPath
  31. String httpBaseUrl = "http://${host}:${httpPort}${contextPath}"
  32. String httpsBaseUrl = "https://${host}:${httpsPort}${contextPath}"
  33. String baseUrl = isHttps ? httpsBaseUrl : httpBaseUrl
  34. integrationTest.systemProperty 'app.port', port
  35. integrationTest.systemProperty 'app.httpPort', httpPort
  36. integrationTest.systemProperty 'app.httpsPort', httpsPort
  37. integrationTest.systemProperty 'app.baseURI', baseUrl
  38. integrationTest.systemProperty 'app.httpBaseURI', httpBaseUrl
  39. integrationTest.systemProperty 'app.httpsBaseURI', httpsBaseUrl
  40. }
  41. }