Class: Circus::Profiles::MavenWebApp
- Defined in:
- lib/circus/profiles/maven_webapp.rb
Constant Summary collapse
- MAVEN_WEBAPP_PROPERTY =
'maven-webapp'
Instance Attribute Summary collapse
-
#app_final_name ⇒ Object
readonly
Returns the value of attribute app_final_name.
Class Method Summary collapse
-
.accepts?(name, dir, props) ⇒ Boolean
Checks if this is a shell applcation.
Instance Method Summary collapse
- #deploy_run_script_content ⇒ Object
- #dev_run_script_content ⇒ Object
-
#initialize(name, dir, props) ⇒ MavenWebApp
constructor
A new instance of MavenWebApp.
-
#name ⇒ Object
The name of this profile.
- #package_base_dir? ⇒ Boolean
- #prepare_for_deploy(logger, overlay_dir) ⇒ Object
Methods inherited from Base
#cleanup_after_deploy, #extra_dirs, #mark_for_persistent_run?, #package_for_deploy, #package_for_dev, #requirements, #supported_for_development?
Constructor Details
#initialize(name, dir, props) ⇒ MavenWebApp
Returns a new instance of MavenWebApp.
26 27 28 29 30 |
# File 'lib/circus/profiles/maven_webapp.rb', line 26 def initialize(name, dir, props) super(name, dir, props) @app_final_name = props[MAVEN_WEBAPP_PROPERTY] || detect_app_name end |
Instance Attribute Details
#app_final_name ⇒ Object (readonly)
Returns the value of attribute app_final_name.
24 25 26 |
# File 'lib/circus/profiles/maven_webapp.rb', line 24 def app_final_name @app_final_name end |
Class Method Details
.accepts?(name, dir, props) ⇒ Boolean
Checks if this is a shell applcation. Will accept the application if it has a file named <name>.sh, or has a ‘shell-app’ property describing the entry point.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/circus/profiles/maven_webapp.rb', line 11 def self.accepts?(name, dir, props) pom_path = File.join(dir, "pom.xml") return true if props.include? MAVEN_WEBAPP_PROPERTY return false unless File.exists?(pom_path) pom_content = REXML::Document.new(File.new(pom_path)) packaging_el = pom_content.root.elements['packaging'] return false unless packaging_el packaging_el.text.strip == 'war' end |
Instance Method Details
#deploy_run_script_content ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/circus/profiles/maven_webapp.rb', line 67 def deploy_run_script_content shell_run_script do <<-EOT exec java -jar /opt/jetty-7.1/start.jar -Djetty.home=/opt/jetty-7.1 OPTIONS=Server,plus,jndi `pwd`/jetty.properties `pwd`/jetty.xml `pwd`/jetty-app.xml EOT end end |
#dev_run_script_content ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/circus/profiles/maven_webapp.rb', line 37 def dev_run_script_content shell_run_script do <<-EOT cd #{@dir} exec mvn jetty:run EOT end end |
#name ⇒ Object
The name of this profile
33 34 35 |
# File 'lib/circus/profiles/maven_webapp.rb', line 33 def name "maven-war" end |
#package_base_dir? ⇒ Boolean
75 76 77 |
# File 'lib/circus/profiles/maven_webapp.rb', line 75 def package_base_dir? false end |
#prepare_for_deploy(logger, overlay_dir) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/circus/profiles/maven_webapp.rb', line 46 def prepare_for_deploy(logger, ) # Build the maven package, then copy the output into the overlay directory logger.info("Building maven application #{@name}") return false unless run_external(logger, 'Perform maven packaging', "cd #{@dir}; mvn package -Dmaven.test.skip=true") logger.info("Expanding artifact #{app_final_name}.war") final_full_path = File.("target/#{app_final_name}.war") return false unless run_external(logger, 'Expand application artifact', "mkdir #{}/#{@name} && unzip #{@dir}/target/#{app_final_name}.war -d #{}/#{@name}/") logger.info("Generating configuration files for #{@name}") write_template('maven_webapp_jetty.xml.erb', "#{}/jetty.xml") write_template('maven_webapp_jetty_app.xml.erb', "#{}/jetty-app.xml") File.open("#{}/jetty.properties", 'w') do |f| f << "jetty.home=/opt/jetty-7.1" end true end |