Bug 394976 - m2e-wtp not filtering overlay
Summary: m2e-wtp not filtering overlay
Status: NEW
Alias: None
Product: M2E-WTP
Classification: Technology
Component: overlay (show other bugs)
Version: 0.16.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-23 09:43 EST by Vinicius CLA
Modified: 2012-11-23 13:41 EST (History)
3 users (show)

See Also:


Attachments
Example project (1.24 KB, application/octet-stream)
2012-11-23 09:43 EST, Vinicius CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vinicius CLA 2012-11-23 09:43:56 EST
Created attachment 223915 [details]
Example project

I am having this problem using Eclipse Indigo with m2e 1.2.0.20120903-1050 and m2e-wtp 0.16.0.20120914-0945. 

My project has 1 overlay war and 9 other wars that use this overlay. Each final war defines some properties that have to be reflected on some of the overlay files. So on the final wars pom.xml I have something this:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.2</version>
  <configuration>
[...]
    <overlays>
      <overlay>
        <groupId>org.test</groupId>
        <artifactId>overlay</artifactId>
        <filtered>true</filtered>
      </overlay>
    </overlays>
[...]
  </configuration>
</plugin>

<dependencies>
  <dependency>
    <groupId>org.test</groupId>
    <artifactId>overlay</artifactId>
    <version>xxx</version>
    <type>war</type>
  </dependency>
</dependencies>

  It works fine if I package from maven3 command line but deploying on tomcat7 using m2e-wtp I got the unfiltered properties on the files.

  Attached are example projects that shows the problem.
Comment 1 Fred Bricon CLA 2012-11-23 12:00:00 EST
filtering war overlays in m2e-wtp is not supported, and given the current overlay implementation, I doubt it can be fixed without rewriting the everything. It'll definitely be non trivial to implement.

The main problem is the incremental nature of the overlay support in WTP (changes in overlays are deployed incrementally on the server), which makes it difficult to cope with on the fly filtering, and the fact it's not coupled to maven.

There's a workaround though, it's not pretty, but should work. Add the following m2e-wtp profile to your (final war) pom.xmls : 

<profiles>
	<profile>
		<id>m2e-wtp</id>
		<!-- 
		workaround for lack of overlay filtering support in m2e-wtp
		You need to distinguish whether the overlay is a workspace project or an archive
		
		The filtered files will be copied to target/m2e-wtp/web-resources.

		Be aware that, in case of duplicates, filtered resources will supercede your project resources. 
		
		 -->
		<build>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-war-plugin</artifactId>
					<version>2.2</version>
					<configuration>
						<failOnMissingWebXml>false</failOnMissingWebXml>
						<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> 
						<webResources>
							<!-- workaround for lack of overlay support filtering 
							case when the overlay is also a workspace project
							
							If you modify a file in the overlay project, you'll need to *touch* this pom.xml
							to trigger an filtering request. 								
							-->
							<resource>
								<directory>../overlay/src/main/webapp</directory>
								<includes>
								    <!-- filtering must be limited to the relevant files only
								    or else you might experience some performance penalty -->
									<include>*.html</include>
								</includes>
								<filtering>true</filtering>
							</resource>
							<!-- workaround for lack of overlay support filtering 
							case when the overlay is an archive 
							<resource>
								<directory>target/m2e-wtp/overlays/overlay-0.0.1/-SNAPSHOT</directory>
								<includes>
									<include>*.html</include>
								</includes>
								<filtering>true</filtering>
							</resource>
							-->
							<resource>
								<filtering>true</filtering>
								<directory>src/main/webapp</directory>
								<includes>
									<include>**/*.html</include>
								</includes>
							</resource>
						</webResources>
						<overlays>
							<overlay>
								<groupId>org.test</groupId>
								<artifactId>overlay</artifactId>
								<filtered>true</filtered>
							</overlay>
						</overlays>
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>
</profiles>
Comment 2 Fred Bricon CLA 2012-11-23 12:00:54 EST
Bugzilla form
Comment 3 Fred Bricon CLA 2012-11-23 12:01:18 EST
...atting sucks!
Comment 4 Fred Bricon CLA 2012-11-23 12:07:59 EST
I recommend using JBoss Tools' Maven Profiles Management feature (http://docs.jboss.org/tools/whatsnew/maven/maven-news-3.3.0.M3.html#itemname1) 
installable from http://download.jboss.org/jbosstools/updates/development/juno/ to switch between maven profiles
Comment 5 Vinicius CLA 2012-11-23 13:41:41 EST
I can see why it will be difficult to implement this...

Anyway, thanx for you suggestion. It is not pretty but is better than replicating the files in all the modules. I'll try it.