|
24 | 24 |
|
25 | 25 | config.include RequestsHelper
|
26 | 26 |
|
| 27 | + should_build_and_install_on_vagrant = true |
| 28 | + has_built_and_installed_on_vagrant = false |
| 29 | + |
27 | 30 | config.before :all do
|
28 | 31 | root_project_path = File.expand_path('../../', __FILE__)
|
29 | 32 | vagrant_path = File.join(root_project_path, 'vagrant', 'tomcat-redis-example')
|
|
32 | 35 | # raise "Expected vagrant to be running."
|
33 | 36 | #end
|
34 | 37 |
|
35 |
| - # build manager |
36 |
| - build_manager_command = <<-eos |
37 |
| - cd #{root_project_path} \ |
38 |
| - && gradle clean \ |
39 |
| - && gradle build |
40 |
| - eos |
41 |
| - `#{build_manager_command}` |
| 38 | + if should_build_and_install_on_vagrant && !has_built_and_installed_on_vagrant |
| 39 | + # build manager |
| 40 | + build_manager_command = <<-eos |
| 41 | + cd #{root_project_path} \ |
| 42 | + && gradle clean \ |
| 43 | + && gradle build |
| 44 | + eos |
| 45 | + `#{build_manager_command}` |
| 46 | + |
| 47 | + # build example app |
| 48 | + build_example_app_command = <<-eos |
| 49 | + cd #{example_app_path} \ |
| 50 | + && gradle clean \ |
| 51 | + && gradle war |
| 52 | + eos |
| 53 | + `#{build_example_app_command}` |
42 | 54 |
|
43 |
| - # build example app |
44 |
| - build_example_app_command = <<-eos |
45 |
| - cd #{example_app_path} \ |
46 |
| - && gradle clean \ |
47 |
| - && gradle war |
48 |
| - eos |
49 |
| - `#{build_example_app_command}` |
| 55 | + deploy_command = <<-eos |
| 56 | + cd #{vagrant_path} \ |
| 57 | + && vagrant ssh -c "\ |
| 58 | + sudo service tomcat7 stop \ |
| 59 | + && sudo mkdir -p /var/lib/tomcat7/lib \ |
| 60 | + && sudo rm -rf /var/lib/tomcat7/lib/tomcat-redis-session-manager* \ |
| 61 | + && sudo cp /opt/tomcat-redis-session-manager/build/libs/tomcat-redis-session-manager*.jar /var/lib/tomcat7/lib/ \ |
| 62 | + && sudo rm -rf /var/lib/tomcat7/webapps/example* \ |
| 63 | + && sudo cp /opt/tomcat-redis-session-manager/example-app/build/libs/example-app*.war /var/lib/tomcat7/webapps/example.war \ |
| 64 | + && sudo rm -f /var/log/tomcat7/* \ |
| 65 | + && sudo service tomcat7 start \ |
| 66 | + " |
| 67 | + eos |
| 68 | + `#{deploy_command}` |
50 | 69 |
|
51 |
| - deploy_command = <<-eos |
52 |
| - cd #{vagrant_path} \ |
53 |
| - && vagrant ssh -c "\ |
54 |
| - sudo service tomcat7 stop \ |
55 |
| - && sudo mkdir -p /var/lib/tomcat7/lib \ |
56 |
| - && sudo rm -rf /var/lib/tomcat7/lib/tomcat-redis-session-manager* \ |
57 |
| - && sudo cp /opt/tomcat-redis-session-manager/build/libs/tomcat-redis-session-manager*.jar /var/lib/tomcat7/lib/ \ |
58 |
| - && sudo rm -rf /var/lib/tomcat7/webapps/example* \ |
59 |
| - && sudo cp /opt/tomcat-redis-session-manager/example-app/build/libs/example-app*.war /var/lib/tomcat7/webapps/example.war \ |
60 |
| - && sudo rm -f /var/log/tomcat7/* \ |
61 |
| - && sudo service tomcat7 start \ |
62 |
| - " |
63 |
| - eos |
64 |
| - `#{deploy_command}` |
| 70 | + has_built_and_installed_on_vagrant = true |
| 71 | + end |
65 | 72 | end
|
66 | 73 | end
|
0 commit comments