On Sat, Jan 17, 2009 at 11:24 PM, Stephen Connolly
<[email protected]> wrote:
> I think you replied to the wrong address.
>
> 2009/1/18 <[email protected]>
>
>> Carlo
>>
>> Thanks a lot!
>>
>> I have tried this method. But I have another problem:
>>
>> I declare the mojo in root pom.xml and the property added in mojo can be
>> reference with ${propertyName}. But in the pom.xml of sub module, the
>> property can't be referenced like this. It seems no such property added in
>> mojo.
>>
>> What's the reason? Is there any solution?
>>

Use maven-2.1-M1, it has fixed the bug you encounter.  See
build-helper-maven-plugin source and example to see some discussions
about this

>
> I suspect that the reason is the child pom's properties are inferred when
> building the model, which is before your plugin's mojo runs
>
>
>>
>> I'm a new to maven, so really appreciate your help -:)
>>
>> Stephen Connolly-2 wrote:
>> >
>> > 2009/1/16 Carlo Sciolla <[email protected]>
>> >
>> >> Something like this:
>> >>
>> >> <code>
>> >> // MyMojo.java
>> >>
>> >>    /**
>> >>    * The Maven project
>> >>    * @parameter expression="${project}"
>> >>    * @required
>> >>    */
>> >>    private MavenProject project;
>> >>
>> >> [...]
>> >>
>> >>    public void execute()
>> >>        throws MojoExecutionException
>> >>    {
>> >> [...]
>> >>        project.getProperties().put("propertyAvailableHereafter",
>> >> actualValue);
>> >> [...]
>> >>    }
>> >> }
>> >> </code>
>> >>
>> >
>> > But note that this property will only be available to phases after your
>> > mojo
>> > has executed....
>> >
>> > This can cause fun if you want to use the property value in the pom in an
>> > expression that is used when the initial model is being constructed (i.e.
>> > you cannot use the property in /project/artifactId, etc)
>> >
>> >
>> >>
>> >>
>> >> Hope this helps,
>> >> c.
>> >>
>> >> --
>> >> Carlo Sciolla - http://www.skuro.tk
>> >> Software Engineer at Sourcesense - Making sense of open Source
>> >> (http://www.sourcesense.com)
>> >> Linux User #372086
>> >>
>> >>  \|/
>> >>  -(o< -- I'm a punk, dude!
>> >>  //\
>> >>  V_/_
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>> >
>> >
>> Quoted from:
>>
>> http://www.nabble.com/How-to-update-property-value-of-POM.xml-in-a-maven-plugin--tp21492944p21500409.html
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to