This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 681eb77dd3 Add warnings and details about webapp classes
681eb77dd3 is described below

commit 681eb77dd39dd4df0d48c53ebd352d04f6ce1d59
Author: remm <r...@apache.org>
AuthorDate: Thu Dec 21 11:45:10 2023 +0100

    Add warnings and details about webapp classes
    
    They need to be packaged as well, and they also might be needed during
    compilation.
---
 modules/stuffed/webapp-jspc.ant.xml | 20 +++++++++++++++++---
 webapps/docs/graal.xml              | 12 ++++++++++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/modules/stuffed/webapp-jspc.ant.xml 
b/modules/stuffed/webapp-jspc.ant.xml
index 07a51841be..cffafcf7d8 100644
--- a/modules/stuffed/webapp-jspc.ant.xml
+++ b/modules/stuffed/webapp-jspc.ant.xml
@@ -15,7 +15,7 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project name="Webapp JSP precompilation and packaging for Maven shade plugin" 
default="package" basedir=".">
+<project name="Webapp JSP precompilation and packaging for Maven shade plugin" 
default="package" basedir="." xmlns:if="ant:if">
 
   <property name="webapp.name" value="examples" />
 
@@ -31,13 +31,27 @@
     <!-- Will contain the webapp classes -->
     <mkdir dir="${basedir}/src/main/java" />
     <mkdir dir="${basedir}/src/main/resources" />
+    <mkdir dir="${basedir}/target/classes" />
 
-    <!-- JSP precompilation -->
+    <!-- Copy all webapp classes to the mvn target location -->
+    <copy todir="${basedir}/target/classes">
+        <fileset id="webappclasses" 
dir="${basedir}/webapps/${webapp.name}/WEB-INF/classes" includes="**/*.class" 
erroronmissingdir="false" />
+    </copy>
+
+       <!-- Warn about any JARs in /WEB-INF/lib -->
+    <fileset id="webappjars" 
dir="${basedir}/webapps/${webapp.name}/WEB-INF/lib" includes="**/*.jar" 
erroronmissingdir="false" />
+    <pathconvert refid="webappjars" property="webinflib" setonempty="false"/>
+    <pathconvert refid="webappclasses" property="webinfclasses" 
setonempty="false"/>
+    <echo if:set="webinflib">JARs from /WEB-INF/lib need to be made available 
to Maven as dependencies.</echo>
+    <echo if:set="webinfclasses">Classes from /WEB-INF/classes will be 
packaged to the shaded JAR, but they will not be available during compilation. 
If needed during that step, they need to be packaged as JARs and made available 
to Maven as dependencies.</echo>
+
+       <!-- JSP precompilation -->
     <jasper validateXml="false" package="${webapp.name}.org.apache.jsp"
             uriroot="${basedir}/webapps/${webapp.name}"
             webXml="${basedir}/webapps/${webapp.name}/WEB-INF/tomcat-web.xml"
             outputDir="${basedir}/src/main/java" />
-    <!-- Copy all webapp classes to the mvn compile location -->
+
+       <!-- Copy all webapp sources to the mvn compile location -->
     <copy todir="${basedir}/src/main/java">
         <fileset dir="${basedir}/webapps/${webapp.name}/WEB-INF/classes" 
includes="**/*.java" erroronmissingdir="false" />
     </copy>
diff --git a/webapps/docs/graal.xml b/webapps/docs/graal.xml
index 3701078150..d86b48a1b2 100644
--- a/webapps/docs/graal.xml
+++ b/webapps/docs/graal.xml
@@ -78,6 +78,18 @@
     folder.
   </p>
 
+  <p>
+    All the webapp classes need to be made available to the Maven shade plugin
+    as well as the compiler during the JSP precompilation step.
+    Any JARs that are present in <code>/WEB-INF/lib</code>
+    need to be made available as Maven dependencies.
+    The <code>webapp-jspc.ant.xml</code> script will copy classes from the
+    <code>/WEB-INF/classes</code> folder of the webapp
+    to the <code>target/classes</code> path that Maven uses as the compilation
+    target, but if any of the JSP sources use them, then they need to be
+    packaged as JARs instead. 
+  </p>
+
   <p>
     The first step is to build the shaded Tomcat JAR with all dependencies.
     Any JSP in the webapp must all be precompiled and packaged (assuming


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to