Class: Mvnizer::Command::NewWarProject

Inherits:
NewProject
  • Object
show all
Defined in:
lib/mvnizer/commands/new_war_project.rb

Constant Summary

Constants included from TaskHelper

TaskHelper::TEMPLATE_DIR

Instance Method Summary collapse

Methods included from TaskHelper

#add_dependency, #create_dir, #generate_file

Methods included from Mvnizer::Configuration

#conf

Instance Method Details

#get_dependenciesObject



28
29
30
# File 'lib/mvnizer/commands/new_war_project.rb', line 28

def get_dependencies
  ["javax:javaee-web-api:6.0:jar:provided"]
end

#run(project) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mvnizer/commands/new_war_project.rb', line 4

def run(project)
  super

  create_dir("#{project.artifact_id}/src/main/webapp/WEB-INF")

  # web.xml is optional in Servlet 3.0
  # Do we keep its generation here?
  generate_file(File.join(TEMPLATE_DIR, "web.xml.erb"),
                "#{project.artifact_id}/src/main/webapp/WEB-INF/web.xml",
                project)


  # The Java class will be generated in the groupId/artifactId folder
  # with the dots replaced by path separators.
  target_directory = project.package_name.gsub(/\./, File::SEPARATOR)

  generate_file(File.join(TEMPLATE_DIR, "war", "ExampleServlet.java.erb"),
                "#{project.artifact_id}/src/main/java/#{target_directory}/ExampleServlet.java",
                project)
  generate_file(File.join(TEMPLATE_DIR, "war", "index.jsp.erb"),
                "#{project.artifact_id}/src/main/webapp/WEB-INF/index.jsp",
                project)
end