vraptor-scaffold 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.travis.yml +7 -0
  2. data/CHANGELOG.rdoc +164 -0
  3. data/Gemfile.lock +5 -8
  4. data/README.textile +20 -7
  5. data/bin/vraptor +1 -1
  6. data/index.sample.html +169 -0
  7. data/lib/vraptor-scaffold.rb +10 -29
  8. data/lib/vraptor-scaffold/configuration.rb +27 -4
  9. data/lib/vraptor-scaffold/execution.rb +24 -0
  10. data/lib/vraptor-scaffold/generators/app/app_generator.rb +196 -0
  11. data/lib/vraptor-scaffold/generators/{app_generator → app}/dependency.rb +0 -0
  12. data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +53 -0
  13. data/lib/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine.rb +0 -0
  14. data/lib/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine.rb +0 -0
  15. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle.erb +19 -1
  16. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties.erb +0 -0
  17. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.xml +6 -2
  18. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.erb +0 -0
  19. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/classpath.erb +0 -5
  20. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/project.erb +0 -0
  21. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.jdt.core.prefs +0 -0
  22. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.component.tt +0 -0
  23. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +0 -0
  24. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +0 -0
  25. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +0 -0
  26. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/freemarker-web.xml +0 -0
  27. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/infrastructure/FreemarkerPathResolver.java.tt +0 -0
  28. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/macros/html.ftl +0 -0
  29. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/main.ftl +0 -0
  30. data/lib/vraptor-scaffold/generators/app/templates/heroku/Main.java +21 -0
  31. data/lib/vraptor-scaffold/generators/app/templates/heroku/Procfile +1 -0
  32. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy-2.2.0.jar +0 -0
  33. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.erb +1 -1
  34. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/jsp-web.xml +0 -0
  35. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/main.jsp +2 -2
  36. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/prelude.jspf +0 -0
  37. data/lib/vraptor-scaffold/generators/{app_generator/templates/src/models/Entity.java.tt → app/templates/models/Entity.erb} +1 -1
  38. data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-hibernate.java.tt +50 -0
  39. data/lib/vraptor-scaffold/generators/{app_generator/templates/src/repositories/Repository.java.tt → app/templates/orm/Repository-jpa.java.tt} +3 -3
  40. data/lib/vraptor-scaffold/generators/app/templates/orm/hibernate.cfg.xml +7 -0
  41. data/lib/vraptor-scaffold/generators/app/templates/orm/persistence.xml +10 -0
  42. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/pom.erb +29 -13
  43. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources-test/.empty_directory +0 -0
  44. data/lib/vraptor-scaffold/generators/app/templates/resources/hibernate.properties +16 -0
  45. data/lib/vraptor-scaffold/generators/app/templates/resources/log4j.properties +4 -0
  46. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources/messages.properties +0 -0
  47. data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +7 -0
  48. data/lib/vraptor-scaffold/generators/{app_generator/templates/webapp/WEB-INF/web.xml → app/templates/webapp/WEB-INF/web.xml.tt} +2 -2
  49. data/lib/vraptor-scaffold/generators/{app_generator/templates/src-test/controllers → app/templates/webapp/images}/.empty_directory +0 -0
  50. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/index.jsp +0 -0
  51. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/common.css +0 -0
  52. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/scaffold.css +0 -0
  53. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/stylesheets.css +0 -0
  54. data/lib/vraptor-scaffold/generators/plugin/plugin_generator.rb +42 -0
  55. data/lib/vraptor-scaffold/generators/plugin/vraptor_gem.rb +36 -0
  56. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute.rb +1 -1
  57. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/base_scaffold.rb +6 -2
  58. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator.rb +3 -3
  59. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller.erb +3 -3
  60. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller_test.erb +1 -1
  61. data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +20 -0
  62. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model.erb +3 -3
  63. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model_test.erb +1 -1
  64. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +27 -0
  65. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository.erb +3 -3
  66. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb +16 -0
  67. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository_test.erb +1 -1
  68. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator.rb +0 -0
  69. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/freemarker_generator.rb +18 -0
  70. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/edit.erb +0 -0
  71. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/form.erb +4 -4
  72. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/index.erb +36 -0
  73. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/new.erb +0 -0
  74. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/show.erb +14 -0
  75. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/jsp_generator.rb +18 -0
  76. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/edit.erb +0 -0
  77. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/form.erb +4 -4
  78. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/index.erb +6 -6
  79. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/new.erb +0 -0
  80. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/show.erb +14 -0
  81. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/template_engine_generator.rb +21 -0
  82. data/lib/vraptor-scaffold/load_paths.rb +13 -21
  83. data/lib/vraptor-scaffold/runner.rb +11 -0
  84. data/lib/vraptor-scaffold/runner/commands_help.rb +13 -0
  85. data/lib/vraptor-scaffold/runner/configure.rb +21 -0
  86. data/lib/vraptor-scaffold/runner/generator.rb +15 -0
  87. data/lib/vraptor-scaffold/runner/help.rb +12 -0
  88. data/lib/vraptor-scaffold/runner/plugin.rb +19 -0
  89. data/lib/vraptor-scaffold/runner/scaffold.rb +16 -0
  90. data/lib/vraptor-scaffold/version.rb +1 -1
  91. data/spec/resources/vraptor-scaffold.properties +5 -0
  92. data/spec/simple_custom_plugin.rb +10 -0
  93. data/spec/spec_helper.rb +5 -6
  94. data/spec/vraptor-scaffold/configuration_spec.rb +88 -4
  95. data/spec/vraptor-scaffold/execution_spec.rb +47 -0
  96. data/spec/vraptor-scaffold/generators/{app_generator → app}/app_generator_spec.rb +136 -54
  97. data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_manager_spec.rb +1 -1
  98. data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_spec.rb +0 -0
  99. data/spec/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine_spec.rb +1 -1
  100. data/spec/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine_spec.rb +0 -0
  101. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Entity.java +1 -1
  102. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/FreemarkerPathResolver.java +0 -0
  103. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Repository.java +3 -3
  104. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle +24 -5
  105. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties +0 -0
  106. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators-jsp.xml +0 -0
  107. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.xml +0 -0
  108. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker-web.xml +2 -2
  109. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.xml +6 -5
  110. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/jsp-web.xml +1 -1
  111. data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +168 -0
  112. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/pom.xml +11 -14
  113. data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold.properties +7 -0
  114. data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +61 -0
  115. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +61 -0
  116. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +40 -0
  117. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +147 -0
  118. data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +40 -0
  119. data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +147 -0
  120. data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +130 -0
  121. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute_spec.rb +13 -9
  122. data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +73 -0
  123. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator_spec.rb +18 -9
  124. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/ProductController.java +3 -3
  125. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +74 -0
  126. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +75 -0
  127. data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +50 -0
  128. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/Product.java +6 -6
  129. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/hibernate.cfg.xml +8 -0
  130. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +60 -0
  131. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepository.java +22 -0
  132. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepositoryImpl.java +16 -0
  133. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepository.java +3 -3
  134. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepositoryImpl.java +3 -3
  135. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator_spec.rb +0 -0
  136. data/spec/vraptor-scaffold/runner/commands_help_spec.rb +12 -0
  137. data/spec/vraptor-scaffold/runner/configure_spec.rb +12 -0
  138. data/spec/vraptor-scaffold/runner/generator_spec.rb +31 -0
  139. data/spec/vraptor-scaffold/runner/help_spec.rb +29 -0
  140. data/spec/vraptor-scaffold/runner/plugin_spec.rb +45 -0
  141. data/spec/vraptor-scaffold/runner/scaffold_spec.rb +35 -0
  142. data/spec/vraptor-scaffold_spec.rb +1 -94
  143. data/vraptor-scaffold.gemspec +3 -3
  144. metadata +137 -140
  145. data/History.txt +0 -128
  146. data/lib/vraptor-scaffold/generators/app_generator/app_generator.rb +0 -102
  147. data/lib/vraptor-scaffold/generators/app_generator/dependency_manager.rb +0 -37
  148. data/lib/vraptor-scaffold/generators/app_generator/templates/ivysettings.xml +0 -9
  149. data/lib/vraptor-scaffold/generators/app_generator/templates/resources/META-INF/persistence.xml +0 -20
  150. data/lib/vraptor-scaffold/generators/app_generator/templates/resources/log4j.properties +0 -4
  151. data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/models/.empty_directory +0 -0
  152. data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/repositories/.empty_directory +0 -0
  153. data/lib/vraptor-scaffold/generators/app_generator/templates/src/controllers/.empty_directory +0 -0
  154. data/lib/vraptor-scaffold/generators/app_generator/templates/vraptor-scaffold.erb +0 -2
  155. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/images/.empty_directory +0 -0
  156. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/application.js +0 -0
  157. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/jquery.min.js +0 -16
  158. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +0 -22
  159. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/index.erb +0 -36
  160. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/show.erb +0 -14
  161. data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator.rb +0 -22
  162. data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/templates/show.erb +0 -14
  163. data/lib/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator.rb +0 -11
  164. data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator.rb +0 -12
  165. data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/templates/repository_impl.erb +0 -16
  166. data/spec/vraptor-scaffold/generators/scaffold_generator/base_scaffold_spec.rb +0 -41
  167. data/spec/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +0 -36
  168. data/spec/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator_spec.rb +0 -34
  169. data/spec/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator_spec.rb +0 -25
  170. data/spec/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator_spec.rb +0 -31
@@ -9,15 +9,39 @@ class Configuration
9
9
  FILENAME = "#{META_INF}/vraptor-scaffold.properties"
10
10
 
11
11
  def self.config
12
- YAML.load_file Configuration::FILENAME
12
+ YAML.load_file FILENAME
13
13
  end
14
14
 
15
15
  def self.template_engine
16
- config["template_engine"]
16
+ config["template_engine"] ? config["template_engine"] : 'jsp'
17
17
  end
18
18
 
19
19
  def self.package
20
- config["package"]
20
+ config["package"] ? config["package"] : 'app'
21
+ end
22
+
23
+ def self.models_package
24
+ config["models_package"] ? config["models_package"] : 'models'
25
+ end
26
+
27
+ def self.controllers_package
28
+ config["controllers_package"] ? config["controllers_package"] : 'controllers'
29
+ end
30
+
31
+ def self.repositories_package
32
+ config["repositories_package"] ? config["repositories_package"] : 'repositories'
33
+ end
34
+
35
+ def self.full_models_package
36
+ "#{package}.#{models_package}"
37
+ end
38
+
39
+ def self.orm
40
+ config["orm"] ? config["orm"] : 'jpa'
41
+ end
42
+
43
+ def self.hibernate?
44
+ orm.eql? "hibernate"
21
45
  end
22
46
 
23
47
  def self.main_class_path *path
@@ -27,5 +51,4 @@ class Configuration
27
51
  def self.test_class_path *path
28
52
  File.join TEST_SRC, package.gsub(".", File::Separator), path
29
53
  end
30
-
31
54
  end
@@ -0,0 +1,24 @@
1
+ module VraptorScaffold
2
+
3
+ class Execution
4
+
5
+ def run(args)
6
+ action = args.shift
7
+ runner_for(action).new.run(args)
8
+ end
9
+
10
+ def runner_for(action)
11
+ VraptorScaffold::COMMANDS.fetch(action, Runner::CommandsHelp)
12
+ end
13
+
14
+ end
15
+
16
+ COMMANDS = {"--help" => Runner::Generator,
17
+ "-h" => Runner::Generator,
18
+ "new" => Runner::Generator,
19
+ "scaffold" => Runner::Scaffold,
20
+ "plugin" => Runner::Plugin
21
+ #"configure" => Runner::Configure
22
+ }
23
+
24
+ end
@@ -0,0 +1,196 @@
1
+ class AppGenerator < VraptorScaffold::Base
2
+
3
+ TEMPLATE_ENGINES = %w( jsp ftl )
4
+ BUILD_TOOLS = %w( ant mvn gradle )
5
+ ORMS = %w( jpa hibernate )
6
+ IVY_JAR = "ivy-2.2.0.jar"
7
+
8
+ argument :project_path
9
+
10
+ class_option :template_engine, :default => "jsp", :aliases => "-e",
11
+ :desc => "Template engine (options: #{TEMPLATE_ENGINES.join(', ')})"
12
+
13
+ class_option :package, :default => "app", :aliases => "-p",
14
+ :desc => "Define base package"
15
+
16
+ class_option :models_package, :aliases => "-m", :default => "models",
17
+ :desc => "Define models package"
18
+
19
+ class_option :controllers_package, :aliases => "-c", :default => "controllers",
20
+ :desc => "Define controllers package"
21
+
22
+ class_option :heroku, :type => :boolean, :aliases => "-h",
23
+ :desc => "heroku project"
24
+
25
+ class_option :repositories_package, :aliases => "-r", :default => "repositories",
26
+ :desc => "Define repositories package"
27
+
28
+ class_option :build_tool, :default => "ant", :aliases => "-b",
29
+ :desc => "Build tools (options: #{BUILD_TOOLS.join(', ')})"
30
+
31
+ class_option :orm, :default => "jpa", :aliases => "-o",
32
+ :desc => "Object-relational mapping (options: #{ORMS.join(', ')})"
33
+
34
+ class_option :jquery, :aliases => "-j", :default => "latest version",
35
+ :desc => "jQuery version"
36
+
37
+ class_option :skip_eclipse, :type => :boolean, :aliases => "-E",
38
+ :desc => "Skip Eclipse files"
39
+
40
+ def self.source_root
41
+ File.join File.dirname(__FILE__), "templates"
42
+ end
43
+
44
+ def self.banner
45
+ "vraptor new #{self.arguments.map(&:usage).join(' ')} [options]"
46
+ end
47
+
48
+ def initialize(args, opts=[])
49
+ super([args], opts)
50
+ validate
51
+ self.destination_root=(project_path)
52
+ @project_name = project_path.split("/").last
53
+ @dependency_manager = DependencyManager.new(options)
54
+ end
55
+
56
+ def create_root_folder
57
+ empty_directory "."
58
+ if @options[:heroku]
59
+ copy_file("heroku/Procfile", "Procfile")
60
+ end
61
+ end
62
+
63
+ def configure_maven
64
+ template("pom.erb", "pom.xml") if build_tool == "mvn"
65
+ end
66
+
67
+ def configure_ant
68
+ if build_tool == "ant"
69
+ create_eclipse_files unless options[:skip_eclipse]
70
+ copy_file("build.xml")
71
+ template("build.properties.erb", "build.properties")
72
+ template("ivy.erb", "ivy.xml")
73
+ copy_file(IVY_JAR)
74
+ end
75
+ end
76
+
77
+ def configure_gradle
78
+ template("build.gradle.erb", "build.gradle") if build_tool == "gradle"
79
+ end
80
+
81
+ def create_main_java
82
+ empty_directory Configuration::MAIN_SRC
83
+ @src = File.join(Configuration::MAIN_SRC, options[:package].gsub(".", File::Separator))
84
+ if @options[:heroku]
85
+ copy_file("heroku/Main.java", "#{Configuration::MAIN_SRC}/Main.java")
86
+ end
87
+ end
88
+
89
+ def create_controllers_directory
90
+ empty_directory File.join @src, options[:controllers_package]
91
+ end
92
+
93
+ def create_models_directory
94
+ models_folder = File.join @src, options[:models_package]
95
+ empty_directory models_folder
96
+ template("models/Entity.erb", "#{models_folder}/Entity.java")
97
+ end
98
+
99
+ def create_repositories_directory
100
+ repositories_folder = File.join @src, options[:repositories_package]
101
+ empty_directory repositories_folder
102
+ template("orm/Repository-#{options[:orm]}.java.tt", "#{repositories_folder}/Repository.java")
103
+ end
104
+
105
+ def create_main_resources
106
+ directory("resources", Configuration::MAIN_RESOURCES)
107
+ end
108
+
109
+ def configure_orm
110
+ if (options[:orm] == "hibernate")
111
+ copy_file("orm/hibernate.cfg.xml", (File.join Configuration::MAIN_RESOURCES, "hibernate.cfg.xml"))
112
+ else
113
+ metainf = File.join Configuration::MAIN_RESOURCES, 'META-INF'
114
+ empty_directory metainf
115
+ copy_file("orm/persistence.xml", (File.join metainf, "persistence.xml"))
116
+ end
117
+ end
118
+
119
+ def create_webapp
120
+ directory("webapp", Configuration::WEB_APP)
121
+ end
122
+
123
+ def create_javascripts
124
+ javascripts = File.join Configuration::WEB_APP, "javascripts"
125
+ create_file File.join javascripts, "application.js"
126
+ get jquery_url, (File.join javascripts, "jquery.min.js")
127
+ end
128
+
129
+ def configure_scaffold_properties
130
+ template("vraptor-scaffold.erb", Configuration::FILENAME)
131
+ end
132
+
133
+ def configure_template_engine
134
+ templates = {"jsp" => JspTemplateEngine, "ftl" => FreemarkerTemplateEngine}
135
+ templates[options[:template_engine]].new(project_path).configure if templates[options[:template_engine]]
136
+ end
137
+
138
+ def create_test
139
+ empty_directory Configuration::TEST_SRC
140
+ test_src = File.join(Configuration::TEST_SRC, options[:package].gsub(".", File::Separator))
141
+
142
+ empty_directory File.join test_src, options[:controllers_package]
143
+ empty_directory File.join test_src, options[:models_package]
144
+ empty_directory File.join test_src, options[:repositories_package]
145
+
146
+ directory("resources-test", Configuration::TEST_RESOURCES)
147
+ end
148
+
149
+ private
150
+ def build_tool
151
+ return "mvn" if options[:heroku]
152
+ options[:build_tool]
153
+ end
154
+
155
+ def jquery_url
156
+ jquery_version = "1" #this mean get latest version
157
+ jquery_version = options[:jquery] if options[:jquery] != 'latest version'
158
+ "http://ajax.googleapis.com/ajax/libs/jquery/#{jquery_version}/jquery.min.js"
159
+ end
160
+
161
+ def create_eclipse_files
162
+ template("eclipse/project.erb", ".project")
163
+ template("eclipse/classpath.erb", ".classpath")
164
+ directory("eclipse/settings", ".settings")
165
+ end
166
+
167
+ def validate
168
+ unless BUILD_TOOLS.include? options[:build_tool]
169
+ puts "Build tool #{options[:build_tool]} is not supported. The supported build tools are: #{BUILD_TOOLS.join(", ")}"
170
+ Kernel::exit
171
+ end
172
+ unless TEMPLATE_ENGINES.include? options[:template_engine]
173
+ puts "Template engine #{options[:template_engine]} is not supported. The supported template engines are: #{TEMPLATE_ENGINES.join(", ")}"
174
+ Kernel::exit
175
+ end
176
+ unless ORMS.include? options[:orm]
177
+ puts "ORM #{options[:orm]} is not supported. The supported object-relational mapping are: #{ORMS.join(", ")}"
178
+ Kernel::exit
179
+ end
180
+
181
+ if File.directory? project_path
182
+ puts "The project #{project_path} already exist"
183
+ Kernel::exit
184
+ end
185
+
186
+ require 'open-uri'
187
+ begin
188
+ Kernel::open(jquery_url)
189
+ rescue OpenURI::HTTPError => e
190
+ download_url = "http://docs.jquery.com/Downloading_jQuery"
191
+ puts "jQuery version #{options[:jquery]} was not found. Please visit the download page to see the versions available #{download_url}."
192
+ Kernel::exit
193
+ end
194
+
195
+ end
196
+ end
@@ -0,0 +1,53 @@
1
+ class DependencyManager
2
+
3
+ attr_accessor :options
4
+
5
+ def initialize(options)
6
+ @options = options
7
+ end
8
+
9
+ def compile_scope
10
+ dependencies = append_freemarker_dependency_if_necessary default_dependencies
11
+ dependencies = append_heroku_dependencies_if_necessary dependencies
12
+ dependencies
13
+ end
14
+
15
+ def test_scope
16
+ [Dependency.new("junit", "junit", "4.8.2"),
17
+ Dependency.new("org.hamcrest", "hamcrest-all", "1.1"),
18
+ Dependency.new("org.mockito", "mockito-all", "1.8.5")]
19
+ end
20
+
21
+ def provided_scope
22
+ if @options[:heroku]
23
+ return []
24
+ end
25
+ [Dependency.new("javax.servlet", "servlet-api", "2.5"), Dependency.new("javax.servlet.jsp", "jsp-api", "2.1")]
26
+ end
27
+
28
+ private
29
+ def default_dependencies
30
+ hibernate_version = "3.6.7.Final"
31
+ [Dependency.new("br.com.caelum", "vraptor", "3.3.1"),
32
+ Dependency.new("org.hsqldb", "hsqldb", "2.2.4"),
33
+ Dependency.new("opensymphony", "sitemesh", "2.4.2"), Dependency.new("javax.servlet", "jstl", "1.2"),
34
+ Dependency.new("org.hibernate", "hibernate-entitymanager", hibernate_version),
35
+ Dependency.new("org.hibernate", "hibernate-c3p0", hibernate_version),
36
+ Dependency.new("org.hibernate", "hibernate-validator", "4.2.0.Final"),
37
+ Dependency.new("joda-time", "joda-time", "2.0")]
38
+ end
39
+
40
+ def append_heroku_dependencies_if_necessary dependencies
41
+ if @options[:heroku]
42
+ dependencies += [Dependency.new("org.eclipse.jetty", "jetty-webapp", "7.4.4.v20110707"),
43
+ Dependency.new("org.mortbay.jetty", "jsp-2.1-glassfish", "2.1.v20100127"),
44
+ Dependency.new("javax.servlet", "servlet-api", "2.5")]
45
+ end
46
+ dependencies
47
+ end
48
+
49
+ def append_freemarker_dependency_if_necessary dependencies
50
+ dependencies << Dependency.new("org.freemarker", "freemarker", "2.3.18") if @options[:template_engine] == 'ftl'
51
+ dependencies
52
+ end
53
+ end
@@ -1,6 +1,5 @@
1
1
  repositories {
2
2
  mavenCentral()
3
- mavenRepo urls: "https://repository.jboss.org/nexus/content/groups/public-jboss"
4
3
  }
5
4
 
6
5
  apply plugin: 'java'
@@ -13,6 +12,25 @@ sourceCompatibility = 1.6
13
12
  targetCompatibility = 1.6
14
13
  version = '1.0'
15
14
 
15
+ sourceSets {
16
+ main {
17
+ java {
18
+ srcDir '<%= Configuration::MAIN_SRC %>'
19
+ }
20
+ resources {
21
+ srcDir '<%= Configuration::MAIN_RESOURCES %>'
22
+ }
23
+ }
24
+ test {
25
+ java {
26
+ srcDir '<%= Configuration::TEST_SRC %>'
27
+ }
28
+ resources {
29
+ srcDir '<%= Configuration::TEST_RESOURCES %>'
30
+ }
31
+ }
32
+ }
33
+
16
34
  sourceSets.main.classesDir = new File('<%= Configuration::WEB_INF %>/classes')
17
35
 
18
36
  jettyRun.scanIntervalSeconds=3
@@ -91,11 +91,15 @@
91
91
  ================================= -->
92
92
  <target name="jetty.run" description="--> run jetty server" depends="compile">
93
93
  <path id="jetty.path.id">
94
- <fileset dir="lib/jetty" />
94
+ <fileset dir="lib/jetty" />
95
95
  </path>
96
96
  <taskdef classpathref="jetty.path.id" resource="tasks.properties" loaderref="jetty.loader" />
97
97
  <jetty tempDirectory="${output.dir}/jetty-temp">
98
- <webApp name="${project.name}" warfile="${webapp.dir}" contextpath="/" scanIntervalSeconds="3" />
98
+ <webApp name="${project.name}" warfile="${webapp.dir}" contextpath="/" scanIntervalSeconds="3">
99
+ <scanTargets dir="${build.dir}">
100
+ <include name="**/*"/>
101
+ </scanTargets>
102
+ </webApp>
99
103
  </jetty>
100
104
  </target>
101
105
 
@@ -5,11 +5,6 @@
5
5
  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
6
6
  <classpathentry kind="src" path="src/test/resources" output="target/test-classes"/>
7
7
  <classpathentry kind="output" path="src/main/webapp/WEB-INF/classes"/>
8
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_20">
9
- <attributes>
10
- <attribute name="owner.project.facets" value="java"/>
11
- </attributes>
12
- </classpathentry>
13
8
  <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
14
9
  <attributes>
15
10
  <attribute name="owner.project.facets" value="jst.web"/>
@@ -0,0 +1,21 @@
1
+ import org.eclipse.jetty.server.Server;
2
+ import org.eclipse.jetty.webapp.WebAppContext;
3
+
4
+ public class Main {
5
+ public static void main(String[] args) throws Exception {
6
+ String webappDirLocation = "src/main/webapp/";
7
+ String webPort = System.getenv("PORT");
8
+ if (webPort == null || webPort.isEmpty()) {
9
+ webPort = "8080";
10
+ }
11
+ Server server = new Server(Integer.valueOf(webPort));
12
+ WebAppContext root = new WebAppContext();
13
+ root.setContextPath("/");
14
+ root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
15
+ root.setResourceBase(webappDirLocation);
16
+ root.setParentLoaderPriority(true);
17
+ server.setHandler(root);
18
+ server.start();
19
+ server.join();
20
+ }
21
+ }
@@ -0,0 +1 @@
1
+ web: sh target/bin/webapp