You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alessandro Novarini <a....@sourcesense.com> on 2009/02/13 10:18:46 UTC

How to filter META-INF/context.xml

Hello list,

After some weeks of lurking, trying to catch all the hidden secrets of  
maven, I need your help.
I looked for some hints on the net also, but probably I'm a bad web  
surfer and I couldn't find anything useful.

So, here's the problem:

I have a maven web project imported into eclipse, and this is a piece  
of its directory structure:

src/
src/main/
src/main/webapps/
src/main/webapps/META-INF/
src/main/webapps/META-INF/context.xml

filters/
filters/integration.properties

------------
File contents
------------

context.xml

<Context>
<Resource name="${jdbc.name}" auth="Container"
             type="${datasource.type}" username="${database.username}"  
password="${database.password}"
             driverClassName="${database.driver}" url="${database.url}"
             maxActive="8" maxIdle="4"/>
</Context>

integration.properties

jdbc.name=jdbc/ds
datasource.type=javax.sql.DataSource
database.username=user
database.password=pass
database.driver=com.mysql.jdbc.Driver
database.url=jdbc:mysql://192.168.250.30:3306/aDatabase? 
autoreconnect=true


And this is the pom.xml (just the interesting sections)

<build>
     ...
                 <plugins>
                        ...
                        <plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<dependentWarExcludes>META-INF/context.xml</dependentWarExcludes>
				</configuration>
			</plugin>
                         ...
		</plugins>
                 ...
                 <resources>
			<resource>
				<targetPath>META-INF</targetPath>
				<directory>src/main/webapp/META-INF</directory>
				<includes>
					<include>**/context.xml</include>
				</includes>
				<filtering>true</filtering>
			</resource>
		</resources>
     ....
</build>


With this configuration, the META-INF directory is copied into target/ 
classes, and the context.xml is filtered, so it seems just a problem  
with the targetPath, but...
Let's add this tag in the build section:

<finalName>testApp</finalName>

So that at the end of mvn package I'll have a war file named testApp.war

We changed the configuration above in this way:
<targetPath>../testApp/META-INF</targetPath>

But the context.xml in the testApp/META-INF in unfiltered :(

Where's the mistake? Is there anything I don't get? Of course there  
is, but what?

Sorry for the long mail, I hope I've explained my problem properly.

Thank you in advance
Ale


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to filter META-INF/context.xml

Posted by mateamargo <ma...@gmail.com>.
I was trying to acomplish the same thing. But it seems the war plugin ensures
that the context.xml file is overwritten.
I even added an antrun task to copy the filtered context to the META-INF
folder, but the war:war goal writes on it before building the war.

I know this because I've added an ant task to change the context.xml
permission to avoid writting and this is what I got:

[INFO] Could not copy webapp
sources[/home/user/projects/prueba/target/mywebapp]

Embedded error: Unable to open file
/home/user/projects/prueba/target/mywebapp/META-INF/context.xml for writing.

Did you find out a way to do this?
-- 
View this message in context: http://www.nabble.com/How-to-filter-META-INF-context.xml-tp21992805p25242310.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to filter META-INF/context.xml

Posted by user454322 <ja...@yahoo.com.mx>.
I gor it with the war-plugin
<build>
...
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
				
<containerConfigXML>src/main/resources/META-INF/context.xml</containerConfigXML>
					<archive>
						<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
						<manifest>
						
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
						</manifest>
					</archive>
					*<webResources>
						<resource>
							<directory>src/main/resources/META-INF</directory>
							<filtering>true</filtering>
							<targetPath>META-INF</targetPath>
						</resource>
					</webResources>*
				</configuration>
			</plugin>
		</plugins>
...
</build>

--
View this message in context: http://maven.40175.n5.nabble.com/How-to-filter-META-INF-context-xml-tp120983p5449829.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org