Search code examples
javamavenwicket

Acessing resource of a maven dependency in a wicket application


I have two maven projects.

components: Contains wicket components. All of these wicket components rely on a single stylesheet called component.css. The stylesheet is generated by the libsass-maven-plugin and output to the projet.build.directory. (Directly into the target folder) This project is packaged as a jar.

web-app: This is the project for the (wicket) web application packaged as a war.

My problem is, that I just can't find a way to include the componet.css as a external resource in my web-app project.

I tried to include it into the webapp folder using the maven-war-plugin and loading it as a <link> inside the html, but that didn't work, because components isn't a war project.

Then I tried to use new CssResourceReference(SomeClass.class, "/component.css") to let wicket generate the <link> element, but I get an error that the access to (static) package resource is denied.

My last possible solution was to create a class inside components and generate the component.css relative to that class. But somehow even this isn't working.


Solution

  • Then I tried to use new CssResourceReference(SomeClass.class, "/component.css") to let wicket generate the element, but I get an error that the access to (static) package resource is denied.

    This should work. Wicket's default settings allow .css static files to be served [1]. Do you use a custom IPackageResourceGuard that disables .css ?

    1. https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java