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

remm pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/tomcat-maven-plugin.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 301055b  Add back missing code to initialize resources
301055b is described below

commit 301055b89437fbed6d4f43dedc437f0b3d27d91b
Author: remm <[email protected]>
AuthorDate: Thu Apr 9 14:19:38 2026 +0200

    Add back missing code to initialize resources
---
 .../tomcat/maven/plugin/tomcat/run/RunMojo.java    | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git 
a/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/run/RunMojo.java
 
b/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/run/RunMojo.java
index 628df5a..57de531 100644
--- 
a/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/run/RunMojo.java
+++ 
b/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/run/RunMojo.java
@@ -28,12 +28,15 @@ import org.apache.catalina.webresources.FileResource;
 import org.apache.catalina.webresources.FileResourceSet;
 import org.apache.catalina.webresources.JarResource;
 import org.apache.catalina.webresources.JarResourceSet;
+import org.apache.catalina.webresources.StandardRoot;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Execute;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -297,6 +300,74 @@ public class RunMojo
         return loader;
     }
 
+    protected static class MyDirContext extends StandardRoot {
+        String buildOutputDirectory;
+
+        String webAppPath;
+
+        WebResourceSet webResourceSet;
+
+        Log log;
+
+        MyDirContext(String buildOutputDirectory, String webAppPath, Log log) {
+
+            this.buildOutputDirectory = buildOutputDirectory;
+            this.webAppPath = webAppPath;
+            this.log = log;
+        }
+
+        @Override
+        public WebResource getResource(String path) {
+
+            log.debug("MyDirContext#getResource: " + path);
+            if ("/WEB-INF/classes".equals(path)) {
+                return new FileResource(this, this.webAppPath, new 
File(this.buildOutputDirectory), true, null);
+            }
+
+            File file = new File(path);
+            if (file.exists()) {
+                return new FileResource(this, this.webAppPath, file, true, 
null);
+            }
+            WebResource webResource = super.getResource(path);
+            return webResource;
+        }
+
+
+        @Override
+        public WebResource getClassLoaderResource(String path) {
+            log.debug("MyDirContext#getClassLoaderResource: " + path);
+            // here get resources from various paths
+            return super.getClassLoaderResource(path);
+        }
+
+
+        @Override
+        public WebResource[] listResources(String path) {
+            log.debug("MyDirContext#listResources: " + path);
+            return super.listResources(path);
+        }
+
+        @Override
+        public WebResource[] getClassLoaderResources(String path) {
+            log.debug("MyDirContext#getClassLoaderResources: " + path);
+            return super.getClassLoaderResources(path);
+        }
+
+        @Override
+        public WebResource[] getResources(String path) {
+            log.debug("MyDirContext#getResources: " + path);
+            return super.getResources(path);
+        }
+
+        @Override
+        protected WebResource[] getResourcesInternal(String path, boolean 
useClassLoaderResources) {
+            log.debug("MyDirContext#getResourcesInternal: " + path);
+            return super.getResourcesInternal(path, useClassLoaderResources);
+        }
+
+
+    }
+
     @Override
     protected void enhanceContext( final Context context )
         throws MojoExecutionException
@@ -316,6 +387,9 @@ public class RunMojo
             final List<String> classLoaderEntries = 
classLoaderEntriesCalculatorResult.getClassPathEntries();
             final List<File> tmpDirectories = 
classLoaderEntriesCalculatorResult.getTmpDirectories();
 
+            context.setResources(new MyDirContext(new 
File(project.getBuild().getOutputDirectory()).getAbsolutePath(),
+                    getPath(), getLog()));
+
             /* Add jars */
             final List<String> jarPaths = extractJars( classLoaderEntries );
             for (String jarPath : jarPaths) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to