diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a5ac5dc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +* +!/entrypoint.sh +!/target/extracted + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07827cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target/ +.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5414c67 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM docker.io/azul/zulu-openjdk:21.0.1-21.30.15 +WORKDIR /app +COPY target/extracted/dependencies/ ./ +COPY target/extracted/spring-boot-loader/ ./ +COPY target/extracted/snapshot-dependencies/ ./ +COPY target/extracted/application/ ./ +COPY entrypoint.sh ./ + +ENTRYPOINT ["./entrypoint.sh"] diff --git a/README.md b/README.md index 9aed515..3f6921d 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ How to run - Run the following command. ```bash -./scripts/deploy-local.sh +./scripts/start.sh ``` - Open the following URL with your browser. diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..d668ea8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +main() { + launch +} + +launch() { + java \ + ${DEBUG_PORT:+ -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:${DEBUG_PORT}} \ + "org.springframework.boot.loader.launch.WarLauncher" +} + +main \ No newline at end of file diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..1e69d92 --- /dev/null +++ b/mise.toml @@ -0,0 +1,3 @@ +[tools] +java = 'zulu-21.40.17' +maven = '3.9.9' diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d27b343 --- /dev/null +++ b/pom.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + org.apache.struts + struts-blank + war + Struts Apps - Blank + 1.0.0 + + 21 + 21 + + + + local-repo + file:../mvn-repo + + + + + io.github.iwauo.springing-struts + struts1-core + 0.0.4 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + springing.struts1.entrypoint.Main + WAR + 3.2.5 + + + + + \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..a31bb99 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -eu + +SCRIPT_DIR=$(realpath "$(dirname $BASH_SOURCE)") +PROJECT_BASE_DIR=$(realpath "$SCRIPT_DIR/..") + +APP_NAME=struts-blank +CONTAINER_NAME=springing-struts-$APP_NAME +DOCKER=$( (command -v podman &> /dev/null) && echo podman || echo docker ) + +main() { + build && start +} + +build() { + mvn \ + clean \ + dependency:purge-local-repository \ + -DreResolve=false \ + -DactTransitively=false \ + -DmanualInclude='io.github.iwauo.springing-struts' \ + package -U \ + spring-boot:repackage \ + && java \ + -Djarmode=layertools \ + -jar target/$APP_NAME-*.war \ + extract --destination target/extracted +} + +start() { + $DOCKER build -t $CONTAINER_NAME . \ + && ($DOCKER stop -t 0 $CONTAINER_NAME || true) \ + && $DOCKER rm -f $CONTAINER_NAME \ + && $DOCKER run -d \ + -p 8080:8080 \ + -p 5005:5005 \ + --name $CONTAINER_NAME \ + --env DEBUG_PORT=5005 \ + $CONTAINER_NAME \ + && $DOCKER logs -f $CONTAINER_NAME +} + +(cd "$PROJECT_BASE_DIR" \ + && eval "$(mise env)" \ + && main +) \ No newline at end of file diff --git a/src/main/resources/MessageResources.properties b/src/main/resources/MessageResources.properties new file mode 100644 index 0000000..a48defe --- /dev/null +++ b/src/main/resources/MessageResources.properties @@ -0,0 +1,44 @@ +# 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 regarding copyright ownership. +# The ASF licenses this file to You 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. + +# -- standard errors -- +errors.header= +# -- validator -- +errors.invalid={0} is invalid. +errors.maxlength={0} can not be greater than {1} characters. +errors.minlength={0} can not be less than {1} characters. +errors.range={0} is not in the range {1} through {2}. +errors.required={0} is required. +errors.byte={0} must be an byte. +errors.date={0} is not a date. +errors.double={0} must be an double. +errors.float={0} must be an float. +errors.integer={0} must be an integer. +errors.long={0} must be an long. +errors.short={0} must be an short. +errors.creditcard={0} is not a valid credit card number. +errors.email={0} is an invalid e-mail address. +# -- other -- +errors.cancel=Operation cancelled. +errors.detail={0} +errors.general=The process did not complete. Details should follow. +errors.token=Request could not be completed. Operation is not in sequence. +# -- welcome -- +welcome.title=Struts Blank Application +welcome.heading=Welcome! +welcome.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, restart your container, and you are on your way! (You can find the MessageResources.properties file with this message in the /WEB-INF/src folder.) diff --git a/src/main/webapp/WEB-INF/struts-config.xml b/src/main/webapp/WEB-INF/struts-config.xml new file mode 100644 index 0000000..513c0fa --- /dev/null +++ b/src/main/webapp/WEB-INF/struts-config.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/validation.xml b/src/main/webapp/WEB-INF/validation.xml new file mode 100644 index 0000000..ca6645f --- /dev/null +++ b/src/main/webapp/WEB-INF/validation.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + mask + ^[0-9a-zA-Z]*$ + + +
+ +
+ + + + + + postalCode + ^[0-9a-zA-Z]*$ + + + +
+ + + + + + + mask + ^[0-9a-zA-Z]*$ + + +
+ +
+ +
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..62c1df2 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,50 @@ + + + + + + + Struts Blank Application + + + + action + org.apache.struts.action.ActionServlet + + config + /WEB-INF/struts-config.xml + + 2 + + + + + + action + *.do + + + + + + index.jsp + + + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..07da6b5 --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,25 @@ +<%-- + 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 regarding copyright ownership. + The ASF licenses this file to You 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. +--%> +<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> + + +<%-- + +Redirect default requests to Welcome global ActionForward. +By using a redirect, the user-agent will change address to match the path of our Welcome ActionForward. + +--%> diff --git a/src/main/webapp/pages/Welcome.jsp b/src/main/webapp/pages/Welcome.jsp new file mode 100644 index 0000000..b83e322 --- /dev/null +++ b/src/main/webapp/pages/Welcome.jsp @@ -0,0 +1,39 @@ +<%-- + 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 regarding copyright ownership. + The ASF licenses this file to You 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. +--%> +<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> +<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> +<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> + + + +<bean:message key="welcome.title"/> + + + + + + + ERROR: Application resources not loaded -- check servlet container + logs for error messages. + + + +

+

+ + +