This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts-archetypes.git
The following commit(s) were added to refs/heads/master by this push: new bafbca6 Fixes Portlet archetypes bafbca6 is described below commit bafbca6ff6cfa621cd96be5f7cbf5684f39b3c25 Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Sun May 10 09:25:52 2020 +0200 Fixes Portlet archetypes --- pom.xml | 2 - .../META-INF/maven/archetype-metadata.xml | 4 +- .../src/main/resources/archetype-resources/pom.xml | 73 +++++++++++++--------- .../src/main/java/view/IndexAction.java | 6 +- .../src/main/resources/struts.xml | 2 +- .../src/main/webapp/WEB-INF/web.xml | 50 +++++++-------- .../META-INF/maven/archetype-metadata.xml | 26 +------- .../src/main/resources/archetype-resources/pom.xml | 10 +-- .../src/main/resources/archetype-resources/pom.xml | 26 ++++---- .../src/main/webapp/WEB-INF/web.xml | 32 +++++----- 10 files changed, 112 insertions(+), 119 deletions(-) diff --git a/pom.xml b/pom.xml index c8bcfae..ccd0060 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- /* - * $Id: pom.xml 820737 2009-10-01 18:03:21Z musachy $ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information diff --git a/struts2-archetype-dbportlet/src/main/resources/META-INF/maven/archetype-metadata.xml b/struts2-archetype-dbportlet/src/main/resources/META-INF/maven/archetype-metadata.xml index 492ccb1..28576e6 100644 --- a/struts2-archetype-dbportlet/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/struts2-archetype-dbportlet/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<archetype-descriptor name="struts2-archetype-dbportlet"> +<archetype-descriptor name="struts2-archetype-portlet"> <fileSets> <fileSet filtered="true" packaged="true"> @@ -16,7 +16,7 @@ </includes> </fileSet> - <fileSet filtered="false" packaged="false"> + <fileSet filtered="true" packaged="false"> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> diff --git a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/pom.xml b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/pom.xml index 8b01057..3acb03d 100644 --- a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/pom.xml +++ b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/pom.xml @@ -1,18 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> - -<project> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>\${groupId}</groupId> <artifactId>\${artifactId}</artifactId> <version>\${version}</version> <packaging>war</packaging> <name>\${artifactId}</name> - <url>http://www.myComp.com</url> - <description>Struts 2 Database Portlet</description> <properties> <struts2.version>${supported.struts2.version}</struts2.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <spring.version>4.3.26.RELEASE</spring.version> + <portlet.api.version>2.0</portlet.api.version> + <!-- plugins --> + <plugin.compiler.version>3.6.1</plugin.compiler.version> + <plugin.war.version>2.3</plugin.war.version> + <plugin.pluto.version>2.0.3</plugin.pluto.version> </properties> <dependencies> @@ -60,7 +65,7 @@ <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> - <version>3.0.5.RELEASE</version> + <version>\${spring.version}</version> </dependency> <!-- Database driver (change for your specific database) --> @@ -88,43 +93,55 @@ <dependency> <groupId>javax.portlet</groupId> <artifactId>portlet-api</artifactId> - <version>2.0</version> + <version>\${portlet.api.version}</version> <scope>provided</scope> </dependency> </dependencies> <build> - <finalName>${artifactId}</finalName> + <finalName>\${artifactId}</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> - <version>3.6.1</version> + <version>3.6.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> - <plugin> - <groupId>org.mortbay.jetty</groupId> - <artifactId>maven-jetty-plugin</artifactId> - <version>6.1.21</version> - <configuration> - <scanIntervalSeconds>10</scanIntervalSeconds> - <scanTargets> - <scanTarget>src/main/webapp/WEB-INF</scanTarget> - <scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget> - <scanTarget>src/main/resources/struts.xml</scanTarget> - </scanTargets> - </configuration> - <dependencies> - <dependency> - <groupId>javax.portlet</groupId> - <artifactId>portlet-api</artifactId> - <version>2.0</version> - </dependency> - </dependencies> - </plugin> </plugins> </build> + + <profiles> + <profile> + <id>pluto-embedded</id> + <build> + <plugins> + <!-- configure maven-war-plugin to use updated web.xml --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>\${plugin.war.version}</version> + <configuration> + <webXml>\${project.build.directory}/pluto-resources/web.xml</webXml> + </configuration> + </plugin> + <!-- bind 'pluto2:assemble' goal to 'generate-resources' lifecycle --> + <plugin> + <groupId>org.apache.portals.pluto</groupId> + <artifactId>maven-pluto-plugin</artifactId> + <version>\${plugin.pluto.version}</version> + <executions> + <execution> + <goals> + <goal>assemble</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> diff --git a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/java/view/IndexAction.java b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/java/view/IndexAction.java index 4ab7b32..e8f43d1 100644 --- a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/java/view/IndexAction.java +++ b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/java/view/IndexAction.java @@ -1,7 +1,7 @@ package ${package}.view; import org.apache.struts2.dispatcher.DefaultActionSupport; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import javax.sql.DataSource; import java.util.Map; @@ -22,7 +22,7 @@ public class IndexAction extends DefaultActionSupport { // Initializes the in-memory database (not necessary in production) if (!initialized) { - SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds); + JdbcTemplate jt = new JdbcTemplate(ds); jt.update("CREATE TABLE sample_table ( id INTEGER IDENTITY, str_col VARCHAR(256), num_col INTEGER)"); jt.update("INSERT INTO sample_table(str_col,num_col) VALUES('Ford', 100)"); jt.update("INSERT INTO sample_table(str_col,num_col) VALUES('Toyota', 200)"); @@ -37,7 +37,7 @@ public class IndexAction extends DefaultActionSupport { // Only refresh the data every minute as needed long now = System.currentTimeMillis(); if (lastLoaded + CACHE_TIME < now) { - SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds); + JdbcTemplate jt = new JdbcTemplate(ds); data = jt.queryForList("SELECT * FROM sample_table"); lastLoaded = now; } diff --git a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/resources/struts.xml b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/resources/struts.xml index 62bd35d..7c75ac6 100644 --- a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/resources/struts.xml +++ b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/resources/struts.xml @@ -11,7 +11,7 @@ <include file="struts-portlet-default.xml" /> - <package name="${artifactId}-package" extends="struts-portlet-default" namespace="/"> + <package name="\${artifactId}-package" extends="struts-portlet-default" namespace="/"> <action name="*"> <result type="redirectAction"> <param name="actionName">index</param> diff --git a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml index d22380f..1725bee 100644 --- a/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml +++ b/struts2-archetype-dbportlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -1,37 +1,33 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> -<web-app> +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app id="\${artifactId}"> + <display-name>Struts2 DB Portlet</display-name> <context-param> - <param-name>contextConfigLocation</param-name> - <param-value>/WEB-INF/applicationContext*.xml</param-value> - </context-param> + <param-name>contextConfigLocation</param-name> + <param-value> + /WEB-INF/applicationContext*.xml + </param-value> + </context-param> + <listener> + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> + </listener> - <filter id="filterdispatcher"> - <filter-name>struts</filter-name> - <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> + <filter> + <filter-name>struts2</filter-name> + <filter-class> + org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter + </filter-class> </filter> - <filter-mapping> - <filter-name>struts</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <listener> - <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> - </listener> - - <listener> - <listener-class>org.apache.struts2.portlet.context.ServletContextHolderListener</listener-class> - </listener> - - <servlet id="preparator"> - <servlet-name>preparator</servlet-name> - <servlet-class>org.apache.struts2.portlet.context.PreparatorServlet</servlet-class> - </servlet> + <filter-mapping> + <filter-name>struts2</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> <welcome-file-list> - <welcome-file>index.jsp</welcome-file> + <welcome-file>index.html</welcome-file> </welcome-file-list> - + </web-app> diff --git a/struts2-archetype-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml b/struts2-archetype-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml index 8ccf712..230092f 100644 --- a/struts2-archetype-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/struts2-archetype-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<archetype-descriptor name="struts2-archetype-plugin"> +<archetype-descriptor name="struts2-archetype-convention"> <fileSets> <fileSet filtered="true" packaged="true"> @@ -9,32 +9,10 @@ </includes> </fileSet> - <fileSet filtered="true" packaged="true"> - <directory>src/test/java</directory> - <includes> - <include>**/*.java</include> - </includes> - </fileSet> - - <fileSet filtered="false" packaged="false"> - <directory>src/main/resources</directory> - <includes> - <include>**/*.xml</include> - </includes> - </fileSet> - - <fileSet filtered="false" packaged="false"> - <directory>src/main/webapp</directory> - <includes> - <include>**/*.jsp</include> - </includes> - </fileSet> - <fileSet filtered="true" packaged="false"> - <directory>src/main</directory> + <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> - <include>**/*.txt</include> </includes> </fileSet> </fileSets> diff --git a/struts2-archetype-plugin/src/main/resources/archetype-resources/pom.xml b/struts2-archetype-plugin/src/main/resources/archetype-resources/pom.xml index e8fef12..2fd6c5d 100644 --- a/struts2-archetype-plugin/src/main/resources/archetype-resources/pom.xml +++ b/struts2-archetype-plugin/src/main/resources/archetype-resources/pom.xml @@ -9,12 +9,17 @@ <packaging>jar</packaging> <name>\${artifactId}</name> + <properties> + <struts2.version>${supported.struts2.version}</struts2.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + <dependencies> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> - <version>${project.version}</version> + <version>\${struts2.version}</version> </dependency> <dependency> @@ -48,7 +53,4 @@ </plugins> </build> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> </project> diff --git a/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml b/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml index cad8021..e07c353 100644 --- a/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml +++ b/struts2-archetype-portlet/src/main/resources/archetype-resources/pom.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> - <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>${groupId}</groupId> - <artifactId>${artifactId}</artifactId> - <version>${version}</version> + + <groupId>\${groupId}</groupId> + <artifactId>\${artifactId}</artifactId> + <version>\${version}</version> <packaging>war</packaging> - <name>${artifactId}</name> + <name>\${artifactId}</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -25,19 +25,19 @@ <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> - <version>${struts2.version}</version> + <version>\${struts2.version}</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-portlet-plugin</artifactId> - <version>${struts2.version}</version> + <version>\${struts2.version}</version> </dependency> <dependency> <groupId>javax.portlet</groupId> <artifactId>portlet-api</artifactId> - <version>${portlet.api.version}</version> + <version>\${portlet.api.version}</version> <scope>provided</scope> </dependency> @@ -48,7 +48,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>${plugin.compiler.version}</version> + <version>\${plugin.compiler.version}</version> <configuration> <source>1.8</source> <target>1.8</target> @@ -66,16 +66,16 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> - <version>${plugin.war.version}</version> + <version>\${plugin.war.version}</version> <configuration> - <webXml>${project.build.directory}/pluto-resources/web.xml</webXml> + <webXml>\${project.build.directory}/pluto-resources/web.xml</webXml> </configuration> </plugin> <!-- bind 'pluto2:assemble' goal to 'generate-resources' lifecycle --> <plugin> <groupId>org.apache.portals.pluto</groupId> <artifactId>maven-pluto-plugin</artifactId> - <version>${plugin.pluto.version}</version> + <version>\${plugin.pluto.version}</version> <executions> <execution> <goals> diff --git a/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml index cd2cb9d..4dec584 100644 --- a/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml +++ b/struts2-archetype-portlet/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -1,21 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app id="\${artifactId}"> - <display-name>Struts2 Hello World Portlet</display-name> + <display-name>Struts2 Portlet</display-name> - <filter> - <filter-name>struts2</filter-name> - <filter-class> - org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter - </filter-class> - </filter> + <filter> + <filter-name>struts2</filter-name> + <filter-class> + org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter + </filter-class> + </filter> - <filter-mapping> - <filter-name>struts2</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> + <filter-mapping> + <filter-name>struts2</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list> + <welcome-file>index.html</welcome-file> + </welcome-file-list> - <welcome-file-list> - <welcome-file>index.html</welcome-file> - </welcome-file-list> </web-app>