I see a couple of reasons why it will not work:

1. Maven interpolates expressions when the model is read. Mojo
configuration is reinterpolated before mojo is executed with exception of
PlexusConfiguration fields (which may be a bug). But if loaded property is
used outside a configuration, let's say in <resource>/<directory> it will
not be reinterpolated.
2. Complete execution plan is calculated before any plugin is executed, so
you cannot change execution phase later. This can be overcome by an
extension, which is executed before execution plan is calculated.

Check build-congurator-maven-plugin and build-configurator-maven-extension
[1]. build-congurator-maven-plugin overcomes the first problem - it
reinterpolates the model and mojo executions, so loaded properties are
visible everywhere. build-configurator-maven-extension overcomes the second
problem. Besides, it has some nice features like EL support in property
files. It's currently under development with snapshots published to [2],
but unit-test coverage is over 90% so it's very stable.

There is also an m2e-connector for build-congurator-maven-plugin, which
currently correctly loads properties and reinterpolates mojo executions [3].

[1] http://htfv.github.com/build-configurator/
[2] https://oss.sonatype.org/content/repositories/snapshots/
[3] http://htfv.github.com/m2e-connectors/updates/1.0.0-SNAPSHOT/


Regards,
htfv (Aliaksei Lahachou)


On Wed, Jun 20, 2012 at 5:30 PM, sureshrk19 <[email protected]> wrote:

> Hi,
>
> Following is the pom.xml snippet...
>
> <plugin>
>        <groupId>org.codehaus.mojo</groupId>
>        <artifactId>properties-maven-plugin</artifactId>
>        <version>1.0-alpha-2</version>
>        <executions>
>                <execution>
>                <phase>initialize</phase>
>                <goals>
>                        <goal>read-project-properties</goal>
>                </goals>
>                <configuration>
>                        <files>
>                           <file>my.properties</file>
>                        </files>
>                        </configuration>
>                 </execution>
>        </executions>
> </plugin>
>
> then, I'm trying to read "exec.type" value from properties file.
>
> <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-javadoc-plugin</artifactId>
>        <executions>
>                <execution>
>                        <phase>${exec.type}</phase>
>                          .......
>                          ......
> </plugin>
>
>
> seems ${exec.type} value is not being read from properties file. where as,
> I
> have another property defined in same properties is working fine..
>
> <plugin>
>        <artifactId>maven-war-plugin</artifactId>
>        <version>2.2</version>
>        <configuration>
>                <webappDirectory>${deploy.dir}</webappDirectory>
>                ....
> </plugin>
>
> Not sure, how these 2 are different.
>
> PS: I tried following and able to read ${exec.type}
> 1) If I define exec.type in pom.xml
> <properties>
>        <exec.type>package</exec.type>
> </properties>
> or
> 2) If I define exec.type=package as windows environment variable then, also
> it is fine.
>
> Only problem is I'm not able to read from properties file.
>
> Any pointers would be highly appreciated.
>
> Thanks,
> SR
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Can-t-read-phase-value-from-properties-file-tp5711621.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]
>
>

Reply via email to