You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lester Ward <lw...@tagaudit.com> on 2003/10/29 15:42:04 UTC

Replacing properties in files

Is there any way to have Maven take a file copy it such that any properties
it contains (e.g. ${pom.currentVersion}) are realized? For example, say I
have a script in src/scripts that has a header like this:

# uploaded.py
# Requires: Python 2.2.x
# Author:   Lester Ward
# Version: 	${pom.currentVersion}

I want to have a maven.xml script that results in a copy of this file in
target/build/ with a header like this:

# uploaded.py
# Requires: Python 2.2.x
# Author:   Lester Ward
# Version: 	1.7.2

Is there a good way to do this to resolve any properties in the file, or do
I have to manually call Ant's Replace tag for specific values?

Thanks,
Wordman

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


Re: Replacing properties in files

Posted by Jason van Zyl <jv...@maven.org>.
On Wed, 2003-10-29 at 09:42, Lester Ward wrote:
> Is there any way to have Maven take a file copy it such that any properties
> it contains (e.g. ${pom.currentVersion}) are realized? For example, say I
> have a script in src/scripts that has a header like this:
> 
> # uploaded.py
> # Requires: Python 2.2.x
> # Author:   Lester Ward
> # Version: 	${pom.currentVersion}
> 
> I want to have a maven.xml script that results in a copy of this file in
> target/build/ with a header like this:
> 
> # uploaded.py
> # Requires: Python 2.2.x
> # Author:   Lester Ward
> # Version: 	1.7.2
> 
> Is there a good way to do this to resolve any properties in the file, or do
> I have to manually call Ant's Replace tag for specific values?

Make the properties file a template and use the Jelly Velocity Tag
Library.


<project
  xmlns:velocity="jelly:org.apache.commons.jelly.tags.velocity.VelocityTagLibrary">

  <velocity:merge
    name="${basedir}/target/upload.py"
    basedir="${templateBaseDirectory}"
    template="upload.py.vm"
  />

</project>

So, that will take ${templateBaseDirectory}/upload.py.vm and spit out
${basedir}/target/upload.py with your values from the context.

The the velocity:merge tag uses values in the Jelly context to make a
Velocity context for the template merge so above is all you need to do.
If you want to add some addition values to the context before merging
just use the standard <j:set var="foo" value="bar"/> type goop and $foo
will be replaced with "bar" in this case.

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

Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
  
  -- Jacques Ellul, The Technological Society


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