You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by franz see <fr...@gmail.com> on 2007/02/13 11:49:51 UTC
Re: [m2] profiles / text substitution
Good day to you, los,
Do something like this
<project>
...
<build>
<resources>
<resource>
<directory>src/main/config</directory>
<includes>
<include>hibernate.cfg.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>dev</id>
<activation>
<property>
<name>env</name>
<value>dev</value>
</property>
</activation>
<build>
<filters>
<filter>src/main/filters/connection-dev.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>prod</id>
<activation>
<property>
<name>env</name>
<value>prod</value>
</property>
</activation>
<build>
<filters>
<filter>src/main/filters/connection-prod.properties</filter>
</filters>
</build>
</profile>
</profiles>
</project>
The filtering is done using filter files ( see [1] ), while the filter file
to be used depends on which profile is activated. You can user property
activation to specify which profile to use ( see [2] ).
This is assuming that your directory structure is something like this...
.
`-- src
`-- main
|-- filters
| |-- connection-dev.properties
| `-- connection-prod.properties
`-- config
`-- hibernate.cfg.xml
Cheers,
Franz
[1]
http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
[2] http://docs.codehaus.org/display/MAVENUSER/Profiles
moraleslos wrote:
>
> I would like to use maven profiles in the pom but would like someway to
> combine this with text substitution. Basically I would like to have one
> generic hibernate configuration file that has a ${connection} ready for
> runtime text substitution. Then I would have 2 external files that
> contains the appropriate connection properties, e.g.
> connection-dev.properties and connection-prod.properties. I would like to
> profile these directly in the pom, and then invoke maven in the command
> line specifying the appropriate profile. So, for example, when I do
> this-- mvn -Denv=dev package-- I would like maven to package my hibernate
> config file, substituting the ${connection} with that found in
> connection-dev.properties. Is there a way to do this with maven profiles?
> Thanks in advance!
>
> -los
>
--
View this message in context: http://www.nabble.com/profiles---text-substitution-tf3217012s177.html#a8942185
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