Hi,

On Fri, Feb 8, 2013 at 10:00 PM, kamaci <[email protected]> wrote:

> I am developing a Maven plugin. It will search for given token and inject
> values at given files.


That sound exactly like something the maven-resource-plugin can do.

Everything is OK but there is only one thing that I
> am struggling with. I have some tokens and variables and I want to read
> them
> from a properties file. For example:
>
> project.version = ${project.version}
> svn.revision.number = ${svn.revision.number}
> bamboo.build.number = ${bamboo.build.number}
> foo=bar
>
> If I write them into my pom.xml file Maven will understand that variables
> and when I get the value of them within my Mojo Maven will automatically
> give me the value of variable. However if I write them into a properties
> file it doesn't.
>
>
Have you looked  at
http://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html#filters
and maybe
http://maven.apache.org/plugins/maven-resources-plugin/examples/custom-resource-filters.html
?


I have realized resource tag and tried:
>
>     <resources>
>         <resource>
>             <directory>src/main/resources/</directory>
>             <filtering>true</filtering>
>         </resource>
>      </resources>
>
> but it is not what I want. I have tried to that at my Mojo:
>
>         MavenResourcesExecution mavenResourcesExecution = new
> MavenResourcesExecution(resources, outputFileDirectory, project, encoding,
> buildFilters, Collections.<String>emptyList(), session);
>
>         try {
>
> mavenResourcesFiltering.filterResources(mavenResourcesExecution);
>         } catch (MavenFilteringException e) {
>                 e.printStackTrace();
>         }
>
> but because of I pass outputFileDirectory it creates a new properties file
> into that directory. I don't want to get a new filtered properties file I
> just want to retrieve a properties variable that includes replaced with
> real
> values of Maven variables from my original properties file.
>
> If I don't create a outputdirectory and just I can do something like that:
>
>     Properties filteredProperties =
> mavenResourcesFiltering.filterResources(mavenResourcesExecution);
>
> everything will be OK for me. How can I do that?
>
> PS: Something like ${project.version} I call them as Maven variables.
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Reading-Variables-From-a-Properties-File-Without-Creating-An-Ouptut-File-tp5746409.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Adrien Rivard
06 63 08 79 74

Reply via email to