Search code examples
mavenjsf-2font-face

filtering web.xml with maven causes font not loaded


I develop a web application with JSF2 and Maven 3. In my application, I use a custom font with the following code in my css:

@font-face {
font-family: 'another_shabby';
src: url("#{resource['fonts:anothershabby_trial-webfont.eot']}");
src: url("#{resource['fonts:anothershabby_trial-webfont.eot']}?#iefix")
    format('embedded-opentype'),
    url("#{resource['fonts:anothershabby_trial-webfont.woff']}")
    format('woff'),
    url("#{resource['fonts:anothershabby_trial-webfont.ttf']}")
    format('truetype'),
    url("#{resource['fonts:anothershabby_trial-webfont.svg']}#WebSymbolsRegular")
    format('svg');
font-weight: normal;
font-style: normal;}

the font files are in my resources folder, in the directory:webapp/resources/fonts

Now, I have a problem which seems to be caused by Maven...

I have added a filter in maven to parse the web.xml in order to dynamically switch the context-param javax.faces.PROJECT_STAGE between Development and Production, according to a Maven profile.

Here is my pom:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <webResources>
            <resource>
                <directory>src/main/webapp</directory>
                <filtering>true</filtering>
            </resource>
        </webResources>
    </configuration>
</plugin>

<profile>
    <id>dev</id>
    <properties>
        <jsfProjectStage>Development</jsfProjectStage>
    </properties>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
</profile>

The web.xml:

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>${jsfProjectStage}</param-value>
</context-param>

When I use this configuration, the font is not loaded properly, but if I remove the filter in the pom and the context-param is "hard-coded", everything works fine... I tested on Safari (Mac + iPhone) and Chrome.

Is there a problem in my configuration? Did I miss something? Is it a known problem?...


Solution

  • After doing some researches, I found an other solution to my problem. I post it, just in case:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
        </configuration>
    </plugin>