You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by wkbutler <ke...@gmail.com> on 2009/06/10 18:08:38 UTC

Property interpolation in war plugin

Hello - 
I believe this should be an easy thing but somehow is not working, using
Maven 2.1.0.

This is one of our resource files -- 
src/main/resources/applicationContext-resource.xml:

    <bean id="e3DataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
        <property name="driverClassName"
value="${e3.jdbc.driverClassName}"/>
        <property name="url" value="${e3.jdbc.url}"/>
        <property name="username" value="${e3.jdbc.username}"/>
        <property name="password" value="${e3.jdbc.password}"/>
        <property name="maxActive" value="100"/>
        <property name="maxWait" value="1000"/>
        <property name="poolPreparedStatements" value="true"/>
        <property name="defaultAutoCommit" value="true"/>
    </bean>


When I execute
    mvn clean compile war:exploded

I am expecting the ${property.values} to be interpolated with properties
defined in the pom.xml.

I think that the only thing required to make this work is to include this
section in my POM:

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
  </build>

as per this documentation  
  
http://maven.apache.org/guides/getting-started/index.html#How%20do%20I%20filter%20resource%20files
.

This is not working, however. The generated WAR still contains
un-interpolated values like ${e3.jdbc.url} in that file listed above, and
the rest of our src/main/resources files.

What is confusing to me is that 
#1  - the maven-jetty-plugin manages to do this without any special
configuration - jetty runs fine

#2 - the Maven Getting Started Guide referenced above suggests prefixing
property names with "pom", such as ${pom.e3.jdbc.url} - so I tried that of
course, with no luck.

Am I missing something? Should this be working as-is?

This is our maven-war-plugin configuration FWIW:

			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.0.2</version>
				<configuration>
					<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
				</configuration>
			</plugin>

and I did try the <filters> section, but that seems to be for using
external/supplemental configuration files.  I did not try using pom.xml as a
filter, but that seems redundant.

Help!  Thanks - 
Kent




-- 
View this message in context: http://www.nabble.com/Property-interpolation-in-war-plugin-tp23965676p23965676.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: Property interpolation in war plugin

Posted by Wayne Fay <wa...@gmail.com>.
> So here are some other things I learned along the way:

Great follow-up with lessons learned. I hope others benefit from this
thread via email archive searches etc.

Wayne

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


Re: Property interpolation in war plugin

Posted by wkbutler <ke...@gmail.com>.
Well this was a PBKAC - I did not have a profile activated that defined the
properties to be substituted. Shows what happens when you've been away from
a project.

So here are some other things I learned along the way:

* the property interpolation is done in the process-resources phase, so the
command is better stated

    mvn -DmyPropertyActivatedProfile clean compile process-resources
war:exploded

and then you can tack on your favorite deployer at the end, such as
tomcat-maven-plugin, jboss-maven-plugin, or cargo-maven2-plugin. Check out
the well-documented plugin pages.

* using mvn -X  will enable good debug so you can see what's happening





wkbutler wrote:
> 
> Hello - 
> I believe this should be an easy thing but somehow is not working, using
> Maven 2.1.0.
> 
> This is one of our resource files -- 
> src/main/resources/applicationContext-resource.xml:
> 
>     <bean id="e3DataSource"
> class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
>         <property name="driverClassName"
> value="${e3.jdbc.driverClassName}"/>
>         <property name="url" value="${e3.jdbc.url}"/>
>         <property name="username" value="${e3.jdbc.username}"/>
>         <property name="password" value="${e3.jdbc.password}"/>
>         <property name="maxActive" value="100"/>
>         <property name="maxWait" value="1000"/>
>         <property name="poolPreparedStatements" value="true"/>
>         <property name="defaultAutoCommit" value="true"/>
>     </bean>
> 
> 
> When I execute
>     mvn clean compile war:exploded
> 
> I am expecting the ${property.values} to be interpolated with properties
> defined in the pom.xml.
> 
> I think that the only thing required to make this work is to include this
> section in my POM:
> 
>   <build>
>     <resources>
>       <resource>
>         <directory>src/main/resources</directory>
>         <filtering>true</filtering>
>       </resource>
>     </resources>
>   </build>
> 
> as per this documentation  
>   
> http://maven.apache.org/guides/getting-started/index.html#How%20do%20I%20filter%20resource%20files
> .
> 
> This is not working, however. The generated WAR still contains
> un-interpolated values like ${e3.jdbc.url} in that file listed above, and
> the rest of our src/main/resources files.
> 
> What is confusing to me is that 
> #1  - the maven-jetty-plugin manages to do this without any special
> configuration - jetty runs fine
> 
> #2 - the Maven Getting Started Guide referenced above suggests prefixing
> property names with "pom", such as ${pom.e3.jdbc.url} - so I tried that of
> course, with no luck.
> 
> Am I missing something? Should this be working as-is?
> 
> This is our maven-war-plugin configuration FWIW:
> 
> 			<plugin>
> 				<artifactId>maven-war-plugin</artifactId>
> 				<version>2.0.2</version>
> 				<configuration>
> 					<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
> 				</configuration>
> 			</plugin>
> 
> and I did try the <filters> section, but that seems to be for using
> external/supplemental configuration files.  I did not try using pom.xml as
> a filter, but that seems redundant.
> 
> Help!  Thanks - 
> Kent
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Property-interpolation-in-war-plugin-tp23965676p23983461.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