Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Draft: Add support for mounting additional resources #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sebkur
Copy link

@sebkur sebkur commented Feb 10, 2022

I added the plugin to a web app I work on. Works nicely, I just found I couldn't configure something that I usually configure for development in Eclipse and deployment as WAR files: additional resources that are mounted at a specific location of the web app.

I usually use this to make client side JavaScript/CSS libraries available at a specific location and also serve static files generated by other Gradle plugins.

path = new File(projectDir, "src/assets/vendor")
mountpoint = "/client"
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example on how to configure this in the target application

@Override
void addResource(Resource resource) {
context.resources.createWebResourceSet(getResourceSetType('PRE'), resource.mountpoint, resource.path.toURI().toURL(), '/')
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's straight-forward to mount the resources on Tomcat 8+

@@ -40,6 +40,11 @@ abstract class BaseTomcatServerImpl implements TomcatServer {
context.loader.addRepository(resource.toURI().toURL().toString())
}

@Override
void addResource(Resource resource) {
// TODO: how to implement this here for Tomcat 7x?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However I haven't found out how to do it on Tomcat7.

I'm not sure if it's worth finding a solution for Tomcat7; maybe Tomcat7 should be removed anyway and instead support for Tomcat 10 be implemented as a replacement? #204

@sebkur
Copy link
Author

sebkur commented Feb 10, 2022

Here's an example web app using the feature: https://github.com/sebkur/example-web-app

Note that it depends on classpath 'com.bmuschko:gradle-tomcat-plugin:2.7.0-local' which needs to be published locally using the changes in this PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant