I'm using resource filtering on jsps, based on profiles. I'm also developing locally using mvn jetty:run
, but the filtering phase does not run.
How can I perform filtering using the jetty plugin?
Configuration snippets:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<includes>
<include>error.jsp</include>
</includes>
<filtering>true</filtering>
<targetPath>/</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<profile>
<id>jci</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>jci</name>
</property>
</activation>
<properties>
<error.title>Some value here</error.title>
</properties>
</profile>
You may want to use the jetty:run-exploded goal rather than jetty:run. From the documentation:
This goal first assembles your webapp into an exploded war file and then deploys it to Jetty.
This may ensure that the appropriate war lifecycle phases are executed before the server is started.
Also are you sure the jci profile is being activated? if another profile is specified for the build, the <activeByDefault> property won't enable the profile, see this bug for details.
From John Casey's response:
The above example is working as designed. The <activeByDefault/> element is meant to specify that this profile will be activated if no other profiles are active in the build. Therefore, specific activation of any profile will cause this one to be deactivated.
The filtered files usually end up in the build target-directory. If you run 'mvn jetty:run' it uses per default your unfiltered src/main/webapp directory. All you got to do is to add the build-target as additional resource directory. Done so, jetty will create an overlay and will also use the filtered files.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<webAppConfig>
<contextPath>/${project.build.finalName}</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<resourcesAsCSV>src/main/webapp,${project.build.directory}/${project.build.finalName}</resourcesAsCSV>
</baseResource>
</webAppConfig>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With