Skip to content

Commit 865f4f7

Browse files
committed
Merge pull request appfuse#22 from appfuse/amp-improvements
EQX-211, EQX-215: Added AMP support to FreeMarker, Stripes and Wicket (AppFuse Light) APF-1417: Add AMP support for Wicket (AppFuse Basic and Modular)
2 parents 0579e1d + 6ee7398 commit 865f4f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2434
-240
lines changed

plugins/appfuse-maven-plugin/build.xml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@
3939
<create-gen-basic archetype="appfuse-basic-tapestry" name="basic-tapestry"/>
4040
</target>
4141

42+
<target name="test-wicket-basic" description="tests plugin with wicket basic archetype">
43+
<create-gen-basic archetype="appfuse-basic-wicket" name="basic-wicket"/>
44+
</target>
45+
4246
<target name="test-basic" description="Runs all basic archetype tests using Ant">
4347
<antcall target="test-jsf-basic"/>
4448
<antcall target="test-spring-basic"/>
4549
<antcall target="test-struts-basic"/>
4650
<antcall target="test-tapestry-basic"/>
51+
<antcall target="test-wicket-basic"/>
4752
</target>
4853

4954
<!-- Modular Archetypes -->
@@ -63,6 +68,10 @@
6368
<create-gen-modular archetype="appfuse-modular-tapestry" name="modular-tapestry"/>
6469
</target>
6570

71+
<target name="test-wicket-modular" description="tests plugin with wicket modular archetype">
72+
<create-gen-modular archetype="appfuse-modular-wicket" name="modular-wicket"/>
73+
</target>
74+
6675
<!-- Light Archetypes -->
6776
<target name="test-jsf-light" description="tests plugin with jsf light archetype">
6877
<create-gen-basic archetype="appfuse-light-jsf" name="light-jsf"/>
@@ -72,6 +81,18 @@
7281
<create-gen-basic archetype="appfuse-light-spring" name="light-spring"/>
7382
</target>
7483

84+
<target name="test-spring-freemarker-light" description="tests plugin with spring light freemarker archetype">
85+
<create-gen-basic archetype="appfuse-light-spring-freemarker" name="light-spring-freemarker"/>
86+
</target>
87+
88+
<target name="test-spring-security-light" description="tests plugin with spring security light archetype">
89+
<create-gen-basic archetype="appfuse-light-spring-security" name="light-spring-security"/>
90+
</target>
91+
92+
<target name="test-stripes-light" description="tests plugin with stripes light archetype">
93+
<create-gen-basic archetype="appfuse-light-stripes" name="light-stripes"/>
94+
</target>
95+
7596
<target name="test-struts-light" description="tests plugin with struts light archetype">
7697
<create-gen-basic archetype="appfuse-light-struts" name="light-struts"/>
7798
</target>
@@ -87,15 +108,20 @@
87108
<target name="test-light" description="Runs all light archetype tests using Ant">
88109
<antcall target="test-jsf-light"/>
89110
<antcall target="test-spring-light"/>
111+
<antcall target="test-spring-freemarker-light"/>
112+
<antcall target="test-spring-security-light"/>
90113
<antcall target="test-struts-light"/>
114+
<antcall target="test-stripes-light"/>
91115
<antcall target="test-tapestry-light"/>
116+
<antcall target="test-wicket-light"/>
92117
</target>
93118

94119
<target name="test-modular" description="Runs all modular archetype tests using Ant">
95120
<antcall target="test-jsf-modular"/>
96121
<antcall target="test-spring-modular"/>
97122
<antcall target="test-struts-modular"/>
98123
<antcall target="test-tapestry-modular"/>
124+
<antcall target="test-wicket-modular"/>
99125
</target>
100126

101127
<target name="test-all" description="Tests AMP, Full Source and JPA with AppFuse archetypes">
@@ -137,7 +163,7 @@
137163

138164
<echo level="info">Generating Generic CRUD for Person entity...</echo>
139165
<!-- run gen install integration-test -->
140-
<property name="test-command" value="verify -Duser.language=en"/>
166+
<property name="test-command" value="verify -Pitest -Duser.language=en"/>
141167

142168
<echo message="Using test command: ${test-command}"/>
143169

@@ -194,7 +220,7 @@
194220

195221
<!-- gen and test web -->
196222
<maven dir="${test.dir}/@{name}/web" command="appfuse:gen -Dentity=Person -Damp.genericCore=false -e"/>
197-
<maven dir="${test.dir}/@{name}/web" command="install -Duser.language=en -Dsurefire.useFile=false -e"/>
223+
<maven dir="${test.dir}/@{name}/web" command="install -Pitest -Duser.language=en -Dsurefire.useFile=false -e"/>
198224
</sequential>
199225
</macrodef>
200226

plugins/appfuse-maven-plugin/src/main/java/org/appfuse/mojo/exporter/AppFuseGeneratorMojo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
193193
File existingConfig = new File(hibernateConfig);
194194
if (!existingConfig.exists()) {
195195
InputStream in = this.getClass().getResourceAsStream("/appfuse/dao/ibatis/hibernate.cfg.ftl");
196-
StringBuffer configFile = new StringBuffer();
196+
StringBuilder configFile = new StringBuilder();
197197
try {
198198
InputStreamReader isr = new InputStreamReader(in);
199199
BufferedReader reader = new BufferedReader(isr);
@@ -283,7 +283,7 @@ protected Exporter configureExporter(Exporter exp) throws MojoExecutionException
283283

284284
exporter.getProperties().setProperty("hasSecurity", String.valueOf(hasSecurity));
285285

286-
// determine if using Home or Home for Tapestry
286+
// determine if using Main or Home for Tapestry
287287
if (webFramework.equals("tapestry")) {
288288
boolean useHome = true;
289289
Collection<File> sourceFiles = FileUtils.listFiles(getProject().getBasedir(), new String[]{"java"}, true);
@@ -302,7 +302,7 @@ protected Exporter configureExporter(Exporter exp) throws MojoExecutionException
302302
/**
303303
* Executes the plugin in an isolated classloader.
304304
*
305-
* @throws MojoExecutionException When there is an erro executing the plugin
305+
* @throws MojoExecutionException When there is an error executing the plugin
306306
*/
307307
@Override
308308
protected void doExecute() throws MojoExecutionException {

plugins/appfuse-maven-plugin/src/main/java/org/appfuse/tool/AppFuseExporter.java

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import org.hibernate.cfg.Configuration;
44
import org.hibernate.tool.hbm2x.GenericExporter;
55
import org.hibernate.tool.hbm2x.pojo.POJOClass;
6+
import org.springframework.core.io.ClassPathResource;
7+
import org.springframework.core.io.Resource;
68

79
import java.io.File;
810
import java.util.Map;
@@ -76,7 +78,7 @@ private void generateCore() {
7678
configureExporter("appfuse/dao/" + daoFramework + "/dao-impl.ftl",
7779
"src/main/java/{basepkg-name}/dao/" + daoFramework + "/{class-name}Dao" +
7880
getDaoFilename(daoFramework) + ".java").start();
79-
81+
8082
// Manager Test
8183
configureExporter("appfuse/service/manager-test.ftl",
8284
"src/test/java/{basepkg-name}/service/impl/{class-name}ManagerImplTest.java").start();
@@ -115,6 +117,7 @@ private void generateWeb() {
115117
if (!webProject) return;
116118

117119
String webFramework = getProperties().getProperty("webframework");
120+
Resource jwebUnitTemplate = new ClassPathResource("appfuse/web/" + webFramework + "/jwebunit-tests.ftl");
118121
if (webFramework.equalsIgnoreCase("jsf")) {
119122
// tests
120123
configureExporter("appfuse/web/jsf/list-test.ftl", "src/test/java/{basepkg-name}/webapp/action/{class-name}ListTest.java").start();
@@ -130,10 +133,7 @@ private void generateWeb() {
130133

131134
// configuration
132135
configureExporter("appfuse/web/jsf/navigation.ftl", "src/main/webapp/WEB-INF/{class-name}-navigation.xml").start();
133-
134-
// JSF managed beans configured by Spring annotations in 2.1+
135-
//configureExporter("appfuse/web/jsf/managed-beans.ftl", "src/main/webapp/WEB-INF/{class-name}-managed-beans.xml").start();
136-
} else if (webFramework.equalsIgnoreCase("spring")) {
136+
} else if (webFramework.equalsIgnoreCase("spring") || webFramework.equalsIgnoreCase("spring-security") || webFramework.equalsIgnoreCase("spring-freemarker")) {
137137
// tests
138138
configureExporter("appfuse/web/spring/controller-test.ftl", "src/test/java/{basepkg-name}/webapp/controller/{class-name}ControllerTest.java").start();
139139
configureExporter("appfuse/web/spring/formcontroller-test.ftl", "src/test/java/{basepkg-name}/webapp/controller/{class-name}FormControllerTest.java").start();
@@ -143,11 +143,13 @@ private void generateWeb() {
143143
configureExporter("appfuse/web/spring/formcontroller.ftl", "src/main/java/{basepkg-name}/webapp/controller/{class-name}FormController.java").start();
144144

145145
// views
146-
configureExporter("appfuse/web/spring/list-view.ftl", "src/main/webapp/WEB-INF/pages/{class-name}s.jsp").start();
147-
configureExporter("appfuse/web/spring/form-view.ftl", "src/main/webapp/WEB-INF/pages/{class-name}form.jsp").start();
148-
149-
// Controllers configured by Spring annotations in 2.1+
150-
//configureExporter("appfuse/web/spring/controller-beans.ftl", "src/main/webapp/WEB-INF/{class-name}-beans.xml").start();
146+
if (!webFramework.equalsIgnoreCase("spring-freemarker")) {
147+
configureExporter("appfuse/web/spring/list-view.ftl", "src/main/webapp/WEB-INF/pages/{class-name}s.jsp").start();
148+
configureExporter("appfuse/web/spring/form-view.ftl", "src/main/webapp/WEB-INF/pages/{class-name}form.jsp").start();
149+
} else {
150+
configureExporter("appfuse/web/spring-freemarker/list-view.ftl", "src/main/webapp/{class-name}list.ftl").start();
151+
configureExporter("appfuse/web/spring-freemarker/form-view.ftl", "src/main/webapp/{class-name}form.ftl").start();
152+
}
151153

152154
// validation
153155
configureExporter("appfuse/web/spring/form-validation.ftl", "src/main/webapp/WEB-INF/{class-name}-validation.xml").start();
@@ -166,33 +168,64 @@ private void generateWeb() {
166168
// This template is not used anymore (APF-798), but retained in case we do want to create definitions by default in the future
167169
configureExporter("appfuse/web/struts/action-beans.ftl", "src/main/webapp/WEB-INF/{class-name}-struts-bean.xml").start();
168170

169-
configureExporter("appfuse/web/struts/struts.ftl", "src/main/resources/{class-name}-struts.xml").start();
171+
GenericExporter exporter = configureExporter("appfuse/web/struts/struts.ftl", "src/main/resources/{class-name}-struts.xml");
172+
exporter.getProperties().put("pagesPath", jwebUnitTemplate.exists() ? "" : "/WEB-INF/pages");
173+
exporter.start();
170174

171175
// validation
172176
configureExporter("appfuse/web/struts/model-validation.ftl", "src/main/resources/{basepkg-name}/model/{class-name}-validation.xml").start();
173177
configureExporter("appfuse/web/struts/action-validation.ftl", "src/main/resources/{basepkg-name}/webapp/action/{class-name}Action-validation.xml").start();
178+
} else if (webFramework.equalsIgnoreCase("stripes")) {
179+
// tests
180+
configureExporter("appfuse/web/stripes/list-action-test.ftl", "src/test/java/{basepkg-name}/webapp/action/{class-name}ListBeanTest.java").start();
181+
configureExporter("appfuse/web/stripes/form-action-test.ftl", "src/test/java/{basepkg-name}/webapp/action/{class-name}FormBeanTest.java").start();
182+
183+
// actions
184+
configureExporter("appfuse/web/stripes/list-action.ftl", "src/main/java/{basepkg-name}/webapp/action/{class-name}ListBean.java").start();
185+
configureExporter("appfuse/web/stripes/form-action.ftl", "src/main/java/{basepkg-name}/webapp/action/{class-name}FormBean.java").start();
186+
187+
// views
188+
configureExporter("appfuse/web/stripes/list-view.ftl", "src/main/webapp/{class-name}List.jsp").start();
189+
configureExporter("appfuse/web/stripes/form-view.ftl", "src/main/webapp/{class-name}Form.jsp").start();
174190
} else if (webFramework.equalsIgnoreCase("tapestry")) {
175191
// tests
176192
configureExporter("appfuse/web/tapestry/list-test.ftl", "src/test/java/{basepkg-name}/webapp/pages/{class-name}ListTest.java").start();
177193
configureExporter("appfuse/web/tapestry/form-test.ftl", "src/test/java/{basepkg-name}/webapp/pages/{class-name}FormTest.java").start();
178194

179-
// managed beans
195+
// pages
180196
configureExporter("appfuse/web/tapestry/list.ftl", "src/main/java/{basepkg-name}/webapp/pages/{class-name}List.java").start();
181197
configureExporter("appfuse/web/tapestry/form.ftl", "src/main/java/{basepkg-name}/webapp/pages/{class-name}Form.java").start();
182198

183199
// views
184200
configureExporter("appfuse/web/tapestry/list-view.ftl", "src/main/webapp/{class-name}List.tml").start();
185201
configureExporter("appfuse/web/tapestry/form-view.ftl", "src/main/webapp/{class-name}Form.tml").start();
202+
} else if (webFramework.equalsIgnoreCase("wicket")) {
203+
// tests
204+
configureExporter("appfuse/web/wicket/list-test.ftl", "src/test/java/{basepkg-name}/webapp/pages/{class-name}ListTest.java").start();
205+
configureExporter("appfuse/web/wicket/form-test.ftl", "src/test/java/{basepkg-name}/webapp/pages/{class-name}FormTest.java").start();
206+
207+
// pages
208+
configureExporter("appfuse/web/wicket/model.ftl", "src/main/java/{basepkg-name}/webapp/pages/{class-name}Model.java").start();
209+
configureExporter("appfuse/web/wicket/data-provider.ftl", "src/main/java/{basepkg-name}/webapp/pages/Sortable{class-name}DataProvider.java").start();
210+
configureExporter("appfuse/web/wicket/list.ftl", "src/main/java/{basepkg-name}/webapp/pages/{class-name}List.java").start();
211+
configureExporter("appfuse/web/wicket/form.ftl", "src/main/java/{basepkg-name}/webapp/pages/{class-name}Form.java").start();
212+
213+
// views
214+
configureExporter("appfuse/web/wicket/list-view.ftl", "src/main/java/{basepkg-name}/webapp/pages/{class-name}List.html").start();
215+
configureExporter("appfuse/web/wicket/form-view.ftl", "src/main/java/{basepkg-name}/webapp/pages/{class-name}Form.html").start();
186216
} else {
187217
log.warn("Your project's web framework '" + webFramework + "' is not supported by AMP at this time.");
188-
log.warn("See http://issues.appfuse.org/browse/EQX-211 for more information.");
189-
218+
log.warn("See enter an issue in JIRA if you'd like to see support. http://issues.appfuse.org/browse/APF");
190219
}
191220

192221
// menu
193222
if (!webFramework.equalsIgnoreCase("tapestry")) {
194223
configureExporter("appfuse/web/menu.ftl", "src/main/webapp/common/{class-name}-menu.jsp").start();
195-
configureExporter("appfuse/web/menu-light.ftl", "src/main/webapp/common/{class-name}-menu-light.jsp").start();
224+
if (webFramework.equalsIgnoreCase("spring-freemarker")) {
225+
configureExporter("appfuse/web/menu-light-freemarker.ftl", "src/main/webapp/common/{class-name}-menu-light.ftl").start();
226+
} else {
227+
configureExporter("appfuse/web/menu-light.ftl", "src/main/webapp/common/{class-name}-menu-light.jsp").start();
228+
}
196229
configureExporter("appfuse/web/menu-config.ftl", "src/main/webapp/WEB-INF/{class-name}-menu-config.xml").start();
197230
} else {
198231
configureExporter("appfuse/web/tapestry/menu.ftl", "src/main/webapp/{class-name}-menu.tml").start();
@@ -201,11 +234,18 @@ private void generateWeb() {
201234
// i18n
202235
configureExporter("appfuse/web/ApplicationResources.ftl", "src/main/resources/{class-name}-ApplicationResources.properties").start();
203236

204-
// ui tests
205-
if (!webFramework.equals("wicket") && !webFramework.equals("spring-security") &&
206-
!webFramework.equals("spring-freemarker") && !webFramework.equals("stripes")) {
237+
// canoo tests
238+
if (!webFramework.equals("spring-security") && !webFramework.equalsIgnoreCase("spring-freemarker") && !webFramework.equalsIgnoreCase("stripes")) {
207239
configureExporter("appfuse/web/" + webFramework + "/web-tests.ftl", "src/test/resources/{class-name}-web-tests.xml").start();
208240
}
241+
// jwebunit tests
242+
if (webFramework.equalsIgnoreCase("spring-freemarker")) {
243+
webFramework = "spring";
244+
jwebUnitTemplate = new ClassPathResource("appfuse/web/" + webFramework + "/jwebunit-tests.ftl");
245+
}
246+
if (jwebUnitTemplate.exists()) {
247+
configureExporter("appfuse/web/" + webFramework + "/jwebunit-tests.ftl", "src/test/java/{basepkg-name}/webapp/{class-name}WebTest.java").start();
248+
}
209249
}
210250

211251
private String getDaoFilename(String daoFramework) {
@@ -231,7 +271,7 @@ private GenericExporter configureExporter(String template, String pattern) {
231271
}
232272
}
233273
} else {
234-
templatePaths = getTemplatePaths();
274+
templatePaths = getTemplatePaths();
235275
}
236276

237277
GenericExporter exporter = new GenericExporter(getConfiguration(), getOutputDirectory()) {

0 commit comments

Comments
 (0)