diff --git a/genapp/project.xml b/genapp/project.xml index ef9834d8..252e9584 100644 --- a/genapp/project.xml +++ b/genapp/project.xml @@ -23,7 +23,7 @@ 3 maven-genapp-plugin Maven Genapp Plugin - 2.2 + 2.3-SNAPSHOT A collection of example projects showing how to use maven in different situations http://maven.apache.org/reference/plugins/genapp/ /www/maven.apache.org/reference/plugins/genapp/ @@ -65,6 +65,16 @@ Java Developer + + Felipe Leme + felipeal + maven@felipeal.net + Falcon Informatica + + Java Developer + + -3 + @@ -82,6 +92,9 @@ trajano trajano@yahoo.com + + Miguel Griffa + diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/.cvsignore b/genapp/src/plugin-resources/web-velocity/template-resources/.cvsignore new file mode 100644 index 00000000..0bc9c34e --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/.cvsignore @@ -0,0 +1,6 @@ +target +.classpath +.project +*.log +build.xml +build.properties diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/maven.xml b/genapp/src/plugin-resources/web-velocity/template-resources/maven.xml new file mode 100644 index 00000000..17c85416 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/maven.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/project.properties b/genapp/src/plugin-resources/web-velocity/template-resources/project.properties new file mode 100644 index 00000000..fbb43c70 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/project.properties @@ -0,0 +1,20 @@ +# ------------------------------------------------------------------- +# Copyright 2001-2004 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------- + +maven.xdoc.date=left +maven.eclipse.classpath.include=src/test-cactus +maven.war.webapp.dir=${maven.src.dir}/webapp/WEB-INF +cactus.src.mergewebxml = src/conf/cactus-web.xml diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/project.xml b/genapp/src/plugin-resources/web-velocity/template-resources/project.xml new file mode 100644 index 00000000..952d9990 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/project.xml @@ -0,0 +1,208 @@ + + + + + + + + 3 + + + @ID@ + @ID@ + + + @NAME@ + + + 1.0 + + + + Apache Software Foundation + http://www.apache.org/ + http://maven.apache.org/images/jakarta-logo-blue.gif + + + + 2004 + @PACKAGE@ + http://maven.apache.org/images/maven.jpg + A collection of example projects showing how to use maven in different situations + + + How to use maven in different situations + + + http://maven.apache.org/reference/plugins/examples/ + http://nagoya.apache.org/scarab/servlet/scarab/ + jakarta.apache.org + /www/maven.apache.org/reference/plugins/examples/ + /www/maven.apache.org/builds/ + + + + scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/examples + http://cvs.apache.org/viewcvs/maven-plugins/examples/ + + + + + + + + + + + + + junit + 3.8.1 + + + + servletapi + 2.3 + + + + cactus + cactus + 13-1.6 + + + + commons-collections + commons-collections + 3.1 + + true + + + + + commons-beanutils + commons-beanutils + 1.7.0 + + true + + + + + commons-logging + commons-logging + 1.0.3 + + true + + + + + commons-digester + commons-digester + 1.6 + + true + + + + + velocity + velocity + 1.4 + + true + + + + + velocity + velocity-dep + 1.4 + + true + + + + + velocity-tools + velocity-tools + 1.1 + + true + + + + + dom4j + dom4j + 1.5 + + true + + + + + + + httpunit + httpunit + 1.5.4 + + true + + + + + jtidy + jtidy + 4aug2000r7-dev + + true + + + + + + + turbine-maven-dev@jakarta.apache.org + src/java + src/test + + + **/*Test.java + + + **/NaughtyTest.java + + + + + src/conf + + *.properties + + + + + diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/conf/app.properties b/genapp/src/plugin-resources/web-velocity/template-resources/src/conf/app.properties new file mode 100644 index 00000000..fbe70646 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/conf/app.properties @@ -0,0 +1,18 @@ +# ------------------------------------------------------------------- +# Copyright 2004 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------- + +# Sample app properties. +foo=bar diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/conf/cactus-web.xml b/genapp/src/plugin-resources/web-velocity/template-resources/src/conf/cactus-web.xml new file mode 100644 index 00000000..25a9225d --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/conf/cactus-web.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/java/HelloWorld.java b/genapp/src/plugin-resources/web-velocity/template-resources/src/java/HelloWorld.java new file mode 100644 index 00000000..f876c728 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/java/HelloWorld.java @@ -0,0 +1,37 @@ +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import java.io.IOException; +import java.util.Date; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Example java class to put in velocity context for presentation. + * + */ +public class HelloWorld { + + public HelloWorld() { + } + + public String hello() { + return "Hello world!"; + } +} diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/test-cactus/HelloWorldServletTest.java b/genapp/src/plugin-resources/web-velocity/template-resources/src/test-cactus/HelloWorldServletTest.java new file mode 100644 index 00000000..94e7fda3 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/test-cactus/HelloWorldServletTest.java @@ -0,0 +1,38 @@ +package @PACKAGE@; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import org.apache.cactus.ServletTestCase; +import org.apache.cactus.WebResponse; + +import @PACKAGE@.HelloWorldServlet; + +/** + * This tests that the HelloWorld servlet is functioning + */ +public class HelloWorldServletTest extends ServletTestCase { + + public void testHelloWorld() throws Exception { + HelloWorldServlet servlet = new HelloWorldServlet(); + servlet.doGet(request,response); + } + + public void endHelloWorld(WebResponse response) { + assertTrue(response.getText().startsWith("Hello world on")); + } +} diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/test-cactus/HttpUnitTest.java b/genapp/src/plugin-resources/web-velocity/template-resources/src/test-cactus/HttpUnitTest.java new file mode 100644 index 00000000..93f409af --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/test-cactus/HttpUnitTest.java @@ -0,0 +1,67 @@ +package @PACKAGE@; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import org.apache.cactus.ServletTestCase; + +import com.meterware.httpunit.WebConversation; + +/** + * This tests the system using the HttpUnit + */ +public class HttpUnitTest extends ServletTestCase { + + /** + * This tests if the Hello World servlet provides the correct output + * + * @throws Exception + * thrown when there is a problem with the test + */ + public void testHelloWorldServlet() throws Exception { + WebConversation wc = new WebConversation(); + wc.getResponse(requestUrl("/HelloWorld")); + assertTrue(wc.getCurrentPage().getText().startsWith("Hello world on")); + } + + /** + * This tests if the Hello World JSP provides the correct output + * + * @throws Exception + * thrown when there is a problem with the test + */ + public void testHelloWorldJsp() throws Exception { + WebConversation wc = new WebConversation(); + wc.getResponse(requestUrl("/sample.jsp")); + assertTrue(wc.getCurrentPage().getText().startsWith("Hello world JSP on")); + } + + /** + * This is a helper method to create the URL string for the initial web + * conversation request + * + * @param relativeUrl + * the relative URL including the leading"/" + * @return the context url with the relative URL appended to it + */ + private String requestUrl(String relativeUrl) { + StringBuffer url = request.getRequestURL(); + url.delete(url.lastIndexOf("/"), url.length()); + url.append(relativeUrl); + return url.toString(); + } +} diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/test/SanityTest.java b/genapp/src/plugin-resources/web-velocity/template-resources/src/test/SanityTest.java new file mode 100644 index 00000000..c0c5c31f --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/test/SanityTest.java @@ -0,0 +1,32 @@ +package @PACKAGE@; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import junit.framework.TestCase; + +/** + * This is a simple JUnit test case to ensure that the environment is okay. + * + * @author Archimedes Trajano + * @version $Id: SanityTest.java,v 1.1 2004/11/25 00:26:28 felipeal Exp $ + */ +public class SanityTest extends TestCase { + public void testSanity() { + assertEquals( "test", "test" ); + } +} diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/toolbox.xml b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/toolbox.xml new file mode 100644 index 00000000..f003566f --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/toolbox.xml @@ -0,0 +1,25 @@ + + + + + + helper + HelloWorld + + diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/velocity.properties b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/velocity.properties new file mode 100644 index 00000000..5a8fface --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/velocity.properties @@ -0,0 +1,127 @@ +# ------------------------------------------------------------------- +# Copyright 2004 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# These are the default properties for the +# Velocity Runtime. These values are used when +# Runtime.init() is called, and when Runtime.init(properties) +# fails to find the specificed properties file. +#---------------------------------------------------------------------------- + + +#---------------------------------------------------------------------------- +# R U N T I M E L O G +#---------------------------------------------------------------------------- +# Velocity uses the Servlet APIs logging facilites. + +#---------------------------------------------------------------------------- +# This controls if Runtime.error(), info() and warn() messages include the +# whole stack trace. The last property controls whether invalid references +# are logged. +#---------------------------------------------------------------------------- + +runtime.log.error.stacktrace = true +runtime.log.warn.stacktrace = true +runtime.log.info.stacktrace = true +runtime.log.invalid.reference = true + + +#---------------------------------------------------------------------------- +# T E M P L A T E E N C O D I N G +#---------------------------------------------------------------------------- + +input.encoding=ISO-8859-1 +output.encoding=ISO-8859-1 + + +#---------------------------------------------------------------------------- +# F O R E A C H P R O P E R T I E S +#---------------------------------------------------------------------------- +# These properties control how the counter is accessed in the #foreach +# directive. By default the reference $velocityCount will be available +# in the body of the #foreach directive. The default starting value +# for this reference is 1. +#---------------------------------------------------------------------------- + +directive.foreach.counter.name = velocityCount +directive.foreach.counter.initial.value = 1 + + +#---------------------------------------------------------------------------- +# I N C L U D E P R O P E R T I E S +#---------------------------------------------------------------------------- +# These are the properties that governed the way #include'd content +# is governed. +#---------------------------------------------------------------------------- + +directive.include.output.errormsg.start = + + +#---------------------------------------------------------------------------- +# P A R S E P R O P E R T I E S +#---------------------------------------------------------------------------- + +directive.parse.max.depth = 10 + + +#---------------------------------------------------------------------------- +# VELOCIMACRO PROPERTIES +#---------------------------------------------------------------------------- +# global : name of default global library. It is expected to be in the regular +# template path. You may remove it (either the file or this property) if +# you wish with no harm. +#---------------------------------------------------------------------------- +#velocimacro.library = /WEB-INF/VM_global_library.vm + +velocimacro.permissions.allow.inline = true +velocimacro.permissions.allow.inline.to.replace.global = false +velocimacro.permissions.allow.inline.local.scope = false + +velocimacro.context.localscope = false + + +#---------------------------------------------------------------------------- +# INTERPOLATION +#---------------------------------------------------------------------------- +# turn off and on interpolation of references and directives in string +# literals. ON by default :) +#---------------------------------------------------------------------------- +runtime.interpolate.string.literals = true + + +#---------------------------------------------------------------------------- +# RESOURCE MANAGEMENT +#---------------------------------------------------------------------------- +# Allows alternative ResourceManager and ResourceCache implementations +# to be plugged in. +#---------------------------------------------------------------------------- +resource.manager.class = org.apache.velocity.runtime.resource.ResourceManagerImpl +resource.manager.cache.class = org.apache.velocity.runtime.resource.ResourceCacheImpl + + + +# Filepath for error template, relative to web application root directory +tools.view.servlet.error.template = Error.vm + +# Directory for layout templates, relative to web application root directory +tools.view.servlet.layout.directory = layout/ + +# Filepath of the default layout template +# relative to the layout directory +# NOT relative to the root directory of the webapp! +tools.view.servlet.layout.default.template = TableBased.vm + diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/web.xml b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..ffb80b96 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + Velocity web application + + + velocity + org.apache.velocity.tools.view.servlet.VelocityViewServlet + + org.apache.velocity.toolbox + /WEB-INF/toolbox.xml + + + org.apache.velocity.properties + /WEB-INF/velocity.properties + + 10 + + + velocity + *.vm + + diff --git a/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/sample.vm b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/sample.vm new file mode 100644 index 00000000..8495b3ae --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template-resources/src/webapp/sample.vm @@ -0,0 +1,24 @@ +## ------------------------------------------------------------------- +## Copyright 2004 The Apache Software Foundation. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## ------------------------------------------------------------------- + +Request class: $request.class.name
+Request content length: $request.contentLength
+Request protocol: $request.protocol
+Request locale: $request.locale
+Request real path: $request.getRealPath("/")
+Request server name: $request.serverName
+Request remote addr: $request.remoteAddr
+Request remote port (Servlets 2.4 only): $request.remotePort
diff --git a/genapp/src/plugin-resources/web-velocity/template.properties b/genapp/src/plugin-resources/web-velocity/template.properties new file mode 100644 index 00000000..4be67c04 --- /dev/null +++ b/genapp/src/plugin-resources/web-velocity/template.properties @@ -0,0 +1,20 @@ +# ------------------------------------------------------------------- +# Copyright 2001-2004 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------- + +maven.genapp.repackage=java,test,test-cactus +maven.genapp.filter=project.xml,src/conf/cactus-web.xml + +maven.genapp.default.package=example.web diff --git a/genapp/xdocs/changes.xml b/genapp/xdocs/changes.xml index 875b306d..3f9d5f08 100644 --- a/genapp/xdocs/changes.xml +++ b/genapp/xdocs/changes.xml @@ -24,6 +24,9 @@ dIon Gillard + + Added Velocity-based webapp template (named web-velocity). + Remove Struts deprecated apis. Fix StrutsTestCase dependency in struts templates.