You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jeff Trent <ca...@gmail.com> on 2012/01/18 04:24:16 UTC

maven plugin configuration and binding execution to a phase/goal

I am stuck on two things while writing a plugin: (1) configuration,
and (2) binding to the right goal/phase automatically.  I am using
Maven 3.0.3, and trying to use the plugin for APK (android) packaged
modules.

(1) configuration.

/**
 * @phase compile
 * @goal myGoal
 * @requiresDependencyResolution runtime
 */
public class MyMojo extends AbstractMojo {

  /**
   * @parameter expression="${myGoal.aVal}" default-value="defaultVal"
   */
  String aVal;

…
}


And in my pom using the plugin:

<build>
		<plugins>
			<plugin>
				<groupId>my.package</groupId>
				<artifactId>my-plugin-test</artifactId>
				<version>1.0-SNAPSHOT</version>
				<configuration>
					<aVal>myConfiguredValue</aVal>
				</configuration>
				<executions>
					<execution>
						<phase>generate-resources</phase>
						<goals>
							<goal>myGoal</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

...

The problem is that I always get the default value instead of the
configured value.  What am I missing?

Am I required to provide the plugin.xml file, even for this simple case?

(2) Binding to the right goal/phase.

Ideally in the above example I don't want to specify <executions> for
my plugin.  But I can't figure out how to vary my annotations to get
it to work.

Can someone point out the problem, or a simple concrete example that
demonstrates this case please?

Thanks,
CP

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


Re: maven plugin configuration and binding execution to a phase/goal

Posted by Stephen Connolly <st...@gmail.com>.
On 18 January 2012 13:32, C Potter <ca...@gmail.com> wrote:
> Hi Manfred,
>
> I've already posted my Android related questions on the Android Dev forum
> yesterday that motivated the need for this.
>
> These question here remain outstanding and all pertain solely to Maven...
>  can someone please answer these...
>
> (1) Configuration parameters - just using aVal did not work!  There is some
> other problem below that I cannot spot.  Do I need a maven plugin xml to
> make this happen?
>
> (2) How do I bind to the right phase/goal without needing <executions>?

You don't... unless you implement a custom packaging type

>
> Thanks!
>
> On Wed, Jan 18, 2012 at 12:03 AM, Manfred Moser <ma...@mosabuam.com>wrote:
>
>> On 12-01-17 07:24 PM, Jeff Trent wrote:
>>
>>> I am stuck on two things while writing a plugin: (1) configuration,
>>> and (2) binding to the right goal/phase automatically.  I am using
>>> Maven 3.0.3, and trying to use the plugin for APK (android) packaged
>>> modules.
>>>
>>> (1) configuration.
>>>
>>> /**
>>>  * @phase compile
>>>  * @goal myGoal
>>>  * @requiresDependencyResolution runtime
>>>  */
>>> public class MyMojo extends AbstractMojo {
>>>
>>>   /**
>>>    * @parameter expression="${myGoal.aVal}" default-value="defaultVal"
>>>    */
>>>   String aVal;
>>>
>>> …
>>> }
>>>
>>>
>>> And in my pom using the plugin:
>>>
>>> <build>
>>>                <plugins>
>>>                        <plugin>
>>>                                <groupId>my.package</groupId>
>>>                                <artifactId>my-plugin-test</**artifactId>
>>>                                <version>1.0-SNAPSHOT</**version>
>>>                                <configuration>
>>>                                        <aVal>myConfiguredValue</aVal>
>>>                                </configuration>
>>>                                <executions>
>>>                                        <execution>
>>>                                                <phase>generate-resources</
>>> **phase>
>>>                                                <goals>
>>>                                                        <goal>myGoal</goal>
>>>                                                </goals>
>>>                                        </execution>
>>>                                </executions>
>>>                        </plugin>
>>>
>>> ...
>>>
>>> The problem is that I always get the default value instead of the
>>> configured value.  What am I missing?
>>>
>>> Am I required to provide the plugin.xml file, even for this simple case?
>>>
>>> (2) Binding to the right goal/phase.
>>>
>>> Ideally in the above example I don't want to specify<executions>  for
>>> my plugin.  But I can't figure out how to vary my annotations to get
>>> it to work.
>>>
>>> Can someone point out the problem, or a simple concrete example that
>>> demonstrates this case please?
>>>
>>> Thanks,
>>> CP
>>>
>>
>> The expression should just be aVal... btw. what are you trying to do that
>> the Android Maven Plugin does not do? You could implement the feature as a
>> mojo there become part of that strong community..
>>
>> manfred
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<us...@maven.apache.org>
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>

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


Re: maven plugin configuration and binding execution to a phase/goal

Posted by C Potter <ca...@gmail.com>.
Hi Manfred,

I've already posted my Android related questions on the Android Dev forum
yesterday that motivated the need for this.

These question here remain outstanding and all pertain solely to Maven...
 can someone please answer these...

(1) Configuration parameters - just using aVal did not work!  There is some
other problem below that I cannot spot.  Do I need a maven plugin xml to
make this happen?

(2) How do I bind to the right phase/goal without needing <executions>?

Thanks!

On Wed, Jan 18, 2012 at 12:03 AM, Manfred Moser <ma...@mosabuam.com>wrote:

> On 12-01-17 07:24 PM, Jeff Trent wrote:
>
>> I am stuck on two things while writing a plugin: (1) configuration,
>> and (2) binding to the right goal/phase automatically.  I am using
>> Maven 3.0.3, and trying to use the plugin for APK (android) packaged
>> modules.
>>
>> (1) configuration.
>>
>> /**
>>  * @phase compile
>>  * @goal myGoal
>>  * @requiresDependencyResolution runtime
>>  */
>> public class MyMojo extends AbstractMojo {
>>
>>   /**
>>    * @parameter expression="${myGoal.aVal}" default-value="defaultVal"
>>    */
>>   String aVal;
>>
>> …
>> }
>>
>>
>> And in my pom using the plugin:
>>
>> <build>
>>                <plugins>
>>                        <plugin>
>>                                <groupId>my.package</groupId>
>>                                <artifactId>my-plugin-test</**artifactId>
>>                                <version>1.0-SNAPSHOT</**version>
>>                                <configuration>
>>                                        <aVal>myConfiguredValue</aVal>
>>                                </configuration>
>>                                <executions>
>>                                        <execution>
>>                                                <phase>generate-resources</
>> **phase>
>>                                                <goals>
>>                                                        <goal>myGoal</goal>
>>                                                </goals>
>>                                        </execution>
>>                                </executions>
>>                        </plugin>
>>
>> ...
>>
>> The problem is that I always get the default value instead of the
>> configured value.  What am I missing?
>>
>> Am I required to provide the plugin.xml file, even for this simple case?
>>
>> (2) Binding to the right goal/phase.
>>
>> Ideally in the above example I don't want to specify<executions>  for
>> my plugin.  But I can't figure out how to vary my annotations to get
>> it to work.
>>
>> Can someone point out the problem, or a simple concrete example that
>> demonstrates this case please?
>>
>> Thanks,
>> CP
>>
>
> The expression should just be aVal... btw. what are you trying to do that
> the Android Maven Plugin does not do? You could implement the feature as a
> mojo there become part of that strong community..
>
> manfred
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<us...@maven.apache.org>
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: maven plugin configuration and binding execution to a phase/goal

Posted by Manfred Moser <ma...@mosabuam.com>.
On 12-01-17 07:24 PM, Jeff Trent wrote:
> I am stuck on two things while writing a plugin: (1) configuration,
> and (2) binding to the right goal/phase automatically.  I am using
> Maven 3.0.3, and trying to use the plugin for APK (android) packaged
> modules.
>
> (1) configuration.
>
> /**
>   * @phase compile
>   * @goal myGoal
>   * @requiresDependencyResolution runtime
>   */
> public class MyMojo extends AbstractMojo {
>
>    /**
>     * @parameter expression="${myGoal.aVal}" default-value="defaultVal"
>     */
>    String aVal;
>
> …
> }
>
>
> And in my pom using the plugin:
>
> <build>
> 		<plugins>
> 			<plugin>
> 				<groupId>my.package</groupId>
> 				<artifactId>my-plugin-test</artifactId>
> 				<version>1.0-SNAPSHOT</version>
> 				<configuration>
> 					<aVal>myConfiguredValue</aVal>
> 				</configuration>
> 				<executions>
> 					<execution>
> 						<phase>generate-resources</phase>
> 						<goals>
> 							<goal>myGoal</goal>
> 						</goals>
> 					</execution>
> 				</executions>
> 			</plugin>
>
> ...
>
> The problem is that I always get the default value instead of the
> configured value.  What am I missing?
>
> Am I required to provide the plugin.xml file, even for this simple case?
>
> (2) Binding to the right goal/phase.
>
> Ideally in the above example I don't want to specify<executions>  for
> my plugin.  But I can't figure out how to vary my annotations to get
> it to work.
>
> Can someone point out the problem, or a simple concrete example that
> demonstrates this case please?
>
> Thanks,
> CP

The expression should just be aVal... btw. what are you trying to do 
that the Android Maven Plugin does not do? You could implement the 
feature as a mojo there become part of that strong community..

manfred

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