gretty.gradle 1.5 KB

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