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
@@ -24,7 +24,7 @@
24
24
  <dependency org="org.mortbay.jetty" name="jsp-api-2.1" rev="6.1.14" conf="jetty->default" />
25
25
  <dependency org="org.mortbay.jetty" name="jsp-2.1" rev="6.1.14" conf="jetty->default" />
26
26
  <dependency org="org.mortbay.jetty" name="jetty-ant" rev="6.1.14" conf="jetty->default" />
27
-
27
+
28
28
  <!-- Minify dependencies -->
29
29
  <dependency org="com.yahoo.platform.yui" name="yuicompressor" rev="2.3.6" conf="minify->default" />
30
30
  </dependencies>
@@ -11,7 +11,7 @@
11
11
  </head>
12
12
  <body>
13
13
  <decorator:body/>
14
- <script type="text/javascript" src="${pageContext.request.contextPath}/javascripts/jquery.min.js"/></script>
15
- <script type="text/javascript" src="${pageContext.request.contextPath}/javascripts/application.js"/></script>
14
+ <script type="text/javascript" src="${pageContext.request.contextPath}/javascripts/jquery.min.js"></script>
15
+ <script type="text/javascript" src="${pageContext.request.contextPath}/javascripts/application.js"></script>
16
16
  </body>
17
17
  </html>
@@ -1,4 +1,4 @@
1
- package <%= options[:package] %>.models;
1
+ package <%= options[:package] %>.<%= options[:models_package] %>;
2
2
 
3
3
  import javax.persistence.GeneratedValue;
4
4
  import javax.persistence.Id;
@@ -0,0 +1,50 @@
1
+ package <%= options[:package] %>.<%= options[:repositories_package] %>;
2
+
3
+ import java.io.Serializable;
4
+ import java.lang.reflect.ParameterizedType;
5
+ import java.util.List;
6
+
7
+ import org.hibernate.Query;
8
+ import org.hibernate.Session;
9
+
10
+ public abstract class Repository<T, I extends Serializable> {
11
+
12
+ protected final Session session;
13
+ protected final Class<T> clazz;
14
+
15
+ protected Repository(Session session) {
16
+ this.session = session;
17
+
18
+ @SuppressWarnings("unchecked")
19
+ Class<T> clazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
20
+
21
+ this.clazz = clazz;
22
+ }
23
+
24
+ public void create(T entity) {
25
+ session.persist(entity);
26
+ }
27
+
28
+ @SuppressWarnings("unchecked")
29
+ public T update(T entity) {
30
+ return (T) session.merge(entity);
31
+ }
32
+
33
+ public void destroy(T entity) {
34
+ session.delete(entity);
35
+ }
36
+
37
+ @SuppressWarnings("unchecked")
38
+ public T find(I id) {
39
+ return (T) session.get(clazz, id);
40
+ }
41
+
42
+ public List<T> findAll() {
43
+ Query query = session.createQuery("from " + clazz.getName());
44
+
45
+ @SuppressWarnings("unchecked")
46
+ List<T> resultList = query.list();
47
+
48
+ return resultList;
49
+ }
50
+ }
@@ -1,4 +1,4 @@
1
- package <%= options[:package] %>.repositories;
1
+ package <%= options[:package] %>.<%= options[:repositories_package] %>;
2
2
 
3
3
  import java.io.Serializable;
4
4
  import java.lang.reflect.ParameterizedType;
@@ -25,8 +25,8 @@ public abstract class Repository<T, I extends Serializable> {
25
25
  entityManager.persist(entity);
26
26
  }
27
27
 
28
- public void update(T entity) {
29
- entityManager.merge(entity);
28
+ public T update(T entity) {
29
+ return entityManager.merge(entity);
30
30
  }
31
31
 
32
32
  public void destroy(T entity) {
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
3
+
4
+ <hibernate-configuration>
5
+ <session-factory>
6
+ </session-factory>
7
+ </hibernate-configuration>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
5
+ version="2.0">
6
+
7
+ <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
8
+ </persistence-unit>
9
+
10
+ </persistence>
@@ -2,19 +2,11 @@
2
2
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
3
  <modelVersion>4.0.0</modelVersion>
4
4
  <groupId><%= @project_name %></groupId>
5
- <artifactId><%= @project_name %></artifactId>
6
- <packaging>war</packaging>
5
+ <artifactId><%= @project_name %></artifactId><%- unless @options[:heroku] %>
6
+ <packaging>war</packaging><%- end %>
7
7
  <version>0.0.1-SNAPSHOT</version>
8
8
  <name><%= @project_name %></name>
9
9
 
10
- <repositories>
11
- <repository>
12
- <id>JBoss</id>
13
- <name>JBoss repository</name>
14
- <url>https://repository.jboss.org/nexus/content/groups/public-jboss</url>
15
- </repository>
16
- </repositories>
17
-
18
10
  <properties>
19
11
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20
12
  </properties>
@@ -43,7 +35,7 @@
43
35
  <plugin>
44
36
  <groupId>org.apache.maven.plugins</groupId>
45
37
  <artifactId>maven-war-plugin</artifactId>
46
- <version>2.1</version>
38
+ <version>2.1.1</version>
47
39
  </plugin>
48
40
  <plugin>
49
41
  <groupId>org.mortbay.jetty</groupId>
@@ -57,7 +49,31 @@
57
49
  <contextPath>/</contextPath>
58
50
  </webAppConfig>
59
51
  </configuration>
60
- </plugin>
52
+ </plugin><%- if @options[:heroku] %>
53
+ <plugin>
54
+ <groupId>org.codehaus.mojo</groupId>
55
+ <artifactId>appassembler-maven-plugin</artifactId>
56
+ <version>1.1.1</version>
57
+ <executions>
58
+ <execution>
59
+ <phase>package</phase>
60
+ <goals>
61
+ <goal>assemble</goal>
62
+ </goals>
63
+ <configuration>
64
+ <assembleDirectory>target</assembleDirectory>
65
+ <generateRepository>false</generateRepository>
66
+ <extraJvmArguments>-Xmx512m</extraJvmArguments>
67
+ <programs>
68
+ <program>
69
+ <mainClass>Main</mainClass>
70
+ <name>webapp</name>
71
+ </program>
72
+ </programs>
73
+ </configuration>
74
+ </execution>
75
+ </executions>
76
+ </plugin><%- end %>
61
77
  </plugins>
62
78
  </build>
63
79
 
@@ -96,7 +112,7 @@
96
112
  <plugin>
97
113
  <groupId>org.codehaus.mojo</groupId>
98
114
  <artifactId>cobertura-maven-plugin</artifactId>
99
- <version>2.4</version>
115
+ <version>2.5.1</version>
100
116
  </plugin>
101
117
  </plugins>
102
118
  </reporting>
@@ -0,0 +1,16 @@
1
+ hibernate.connection.driver_class=org.hsqldb.jdbcDriver
2
+ hibernate.connection.url=jdbc:hsqldb:file:tmp/devdb
3
+ hibernate.hbm2ddl.auto=update
4
+ hibernate.query.substitutions=true=1, false=0
5
+ hibernate.show_sql=true
6
+ hibernate.format_sql=true
7
+
8
+ #DATASOURCE POOL CONFIGURATIONS
9
+ hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
10
+ maxPoolSize=20
11
+ minPoolSize=3
12
+ initialPoolSize=3
13
+ timeout=25200
14
+ acquireIncrement=5
15
+ preferredTestQuery=select 1
16
+ idleConnectionTestPeriod=100
@@ -0,0 +1,4 @@
1
+ log4j.appender.console=org.apache.log4j.ConsoleAppender
2
+ log4j.appender.console.layout=org.apache.log4j.PatternLayout
3
+ log4j.appender.console.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss,SSS} [%p] %c - %m%n
4
+ log4j.rootLogger=info, console
@@ -0,0 +1,7 @@
1
+ build_tool: <%= options[:build_tool] %>
2
+ package: <%= options[:package] %>
3
+ template_engine: <%= options[:template_engine] %>
4
+ orm: <%= options[:orm] %>
5
+ models_package: <%= options[:models_package] %>
6
+ controllers_package: <%= options[:controllers_package] %>
7
+ repositories_package: <%= options[:repositories_package] %>
@@ -3,11 +3,11 @@
3
3
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
4
  id="WebApp_ID" version="2.5">
5
5
 
6
- <display-name>vraptor-scaffold-project</display-name>
6
+ <display-name><%= @project_name %></display-name>
7
7
 
8
8
  <context-param>
9
9
  <param-name>br.com.caelum.vraptor.packages</param-name>
10
- <param-value>br.com.caelum.vraptor.util.jpa</param-value>
10
+ <param-value>br.com.caelum.vraptor.util.<%= options[:orm] %></param-value>
11
11
  </context-param>
12
12
 
13
13
  <context-param>
@@ -0,0 +1,42 @@
1
+ class PluginGenerator < VraptorScaffold::Base
2
+
3
+ argument :name
4
+
5
+ class_option :group, :default => "br.com.caelum.vraptor", :aliases => "-g",
6
+ :desc => "Plugin group"
7
+
8
+ class_option :version, :aliases => "-v",
9
+ :desc => "Plugin version"
10
+
11
+ def self.banner
12
+ "vraptor plugin #{self.arguments.map(&:usage).join(' ')} [options]"
13
+ end
14
+
15
+ def initialize(args, opts=[])
16
+ super([args], opts)
17
+ @version = options[:version]
18
+ @group = options[:group]
19
+ end
20
+
21
+ def build
22
+ if is_ivy?
23
+ plugin = "\n\t\t<dependency org=\"#{@group}\" name=\"#{name}\" rev=\"#{@version}\" conf=\"default\" />"
24
+ inject_into_file("ivy.xml", plugin, :after => "<dependencies>")
25
+ elsif is_maven?
26
+ plugin = "\n\t\t<dependency>\n\t\t\t<groupId>#{@group}</groupId>\n\t\t\t<artifactId>#{name}</artifactId>\n\t\t\t<version>#{@version}</version>\n\t\t</dependency>"
27
+ inject_into_file("pom.xml", plugin, :after => "<dependencies>")
28
+ else
29
+ plugin = "\n compile group: '#{@group}', name: '#{name}', version: '#{@version}'\n"
30
+ inject_into_file("build.gradle", plugin, :after => "dependencies {")
31
+ end
32
+ end
33
+
34
+ def is_ivy?
35
+ File.exist?("ivy.xml")
36
+ end
37
+
38
+ def is_maven?
39
+ File.exist?("pom.xml")
40
+ end
41
+
42
+ end
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'rubygems/gem_runner'
3
+ require 'net/http'
4
+
5
+ class VRaptorGem
6
+ #def initialize(who)
7
+ # @who = who
8
+ #end
9
+ #def install_and_configure
10
+ # if is_installed?
11
+ # configure
12
+ # elsif exists?
13
+ # install
14
+ # configure
15
+ # end
16
+ #end
17
+ #
18
+ #private
19
+ #def is_installed?
20
+ # Gem::GemPathSearcher.new.find(@who)
21
+ #end
22
+ #def exists?
23
+ # url = URI.parse("http://rubygems.org/gems/#{@who}")
24
+ # req = Net::HTTP::Get.new(url.path)
25
+ # res = Net::HTTP.start(url.host, url.port) {|http|
26
+ # http.request(req)
27
+ # }
28
+ # res.code == '200'
29
+ #end
30
+ #def install
31
+ # Gem::GemRunner.new.run ["install", @who]
32
+ #end
33
+ #def configure
34
+ # VraptorScaffold::Execution.new.run(["configure", @who])
35
+ #end
36
+ end
@@ -2,7 +2,7 @@ class Attribute
2
2
  attr_accessor :name, :type
3
3
 
4
4
  def initialize(name, type)
5
- @name = name.underscore.camelize(:lower)
5
+ @name = name.underscore.camelize(:lower)
6
6
  @type = type.downcase
7
7
  validate
8
8
  end
@@ -7,11 +7,11 @@ class BaseScaffold < VraptorScaffold::Base
7
7
  end
8
8
 
9
9
  def model_parameter_name
10
- @model.downcase
10
+ @model.camelize(:lower)
11
11
  end
12
12
 
13
13
  def class_name
14
- @model.capitalize
14
+ @model.camelize
15
15
  end
16
16
 
17
17
  def test_class_name
@@ -37,4 +37,8 @@ class BaseScaffold < VraptorScaffold::Base
37
37
  def controller_test_class_name
38
38
  "#{controller_class_name}Test"
39
39
  end
40
+
41
+ def base_path
42
+ model_parameter_name.pluralize
43
+ end
40
44
  end
@@ -5,11 +5,11 @@ class ControllerGenerator < BaseScaffold
5
5
  end
6
6
 
7
7
  def build
8
- template("controller.erb", Configuration.main_class_path("controllers", "#{controller_class_name}.java"))
9
- template("controller_test.erb", Configuration.test_class_path("controllers", "#{controller_test_class_name}.java"))
8
+ template("controller.erb", Configuration.main_class_path(Configuration.controllers_package, "#{controller_class_name}.java"))
9
+ template("controller_test.erb", Configuration.test_class_path(Configuration.controllers_package, "#{controller_test_class_name}.java"))
10
10
  end
11
11
 
12
12
  def path
13
- "/#{@model.downcase.pluralize}"
13
+ "/#{base_path}"
14
14
  end
15
15
  end
@@ -1,9 +1,9 @@
1
- package <%= Configuration.package %>.controllers;
1
+ package <%= Configuration.package %>.<%= Configuration.controllers_package %>;
2
2
 
3
3
  import java.util.List;
4
4
 
5
- import <%= Configuration.package %>.models.<%= class_name %>;
6
- import <%= Configuration.package %>.repositories.<%= repository_interface_name %>;
5
+ import <%= Configuration.full_models_package %>.<%= class_name %>;
6
+ import <%= Configuration.package %>.<%= Configuration.repositories_package %>.<%= repository_interface_name %>;
7
7
  import br.com.caelum.vraptor.Delete;
8
8
  import br.com.caelum.vraptor.Get;
9
9
  import br.com.caelum.vraptor.Post;
@@ -1,4 +1,4 @@
1
- package <%= Configuration.package %>.controllers;
1
+ package <%= Configuration.package %>.<%= Configuration.controllers_package %>;
2
2
 
3
3
  import static org.junit.Assert.assertNotNull;
4
4
 
@@ -0,0 +1,20 @@
1
+ class ModelGenerator < BaseScaffold
2
+
3
+ def self.source_root
4
+ File.join File.dirname(__FILE__), "templates"
5
+ end
6
+
7
+ def build
8
+ template("model.erb", Configuration.main_class_path(Configuration.models_package, "#{class_name}.java"))
9
+ template("model_test.erb", Configuration.test_class_path(Configuration.models_package, "#{test_class_name}.java"))
10
+ map_orm_class if Configuration.hibernate?
11
+ end
12
+
13
+ private
14
+ def map_orm_class
15
+ file = File.join Configuration::MAIN_RESOURCES, "hibernate.cfg.xml"
16
+ model = "#{Configuration.full_models_package}.#{class_name}"
17
+ line_break = "\n "
18
+ inject_into_file(file, " <mapping class='#{model}'/>#{line_break}", :before => "</session-factory>")
19
+ end
20
+ end
@@ -1,4 +1,4 @@
1
- package <%= Configuration.package %>.models;
1
+ package <%= Configuration.full_models_package %>;
2
2
 
3
3
  @javax.persistence.Entity
4
4
  public class <%= class_name %> extends Entity {
@@ -8,11 +8,11 @@ public class <%= class_name %> extends Entity {
8
8
  <% end -%>
9
9
 
10
10
  <% @attributes.each do |att| -%>
11
- public void set<%= att.name.capitalize %>(<%= att.java_type %> <%= att.name %>) {
11
+ public void set<%= att.name.camelize %>(<%= att.java_type %> <%= att.name %>) {
12
12
  this.<%= att.name %> = <%= att.name %>;
13
13
  }
14
14
 
15
- public <%= att.java_type %> <%= att.getter_prefix + att.name.capitalize %>() {
15
+ public <%= att.java_type %> <%= att.getter_prefix + att.name.camelize %>() {
16
16
  return <%= att.name %>;
17
17
  }
18
18