You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Maxime Carpentier <ca...@gmail.com> on 2012/01/13 11:53:53 UTC
maven-plugin-tools-ant custom parameter
Hi,
I'm developping a new plugin using ant, guided by
http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html.
In this tutorial you can see how to map parameter for your plugin,
declaring in your pom.xml :
<plugin>
<groupId>org.myproject.plugins</groupId>
<artifactId>hello-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<name>John</name>
</configuration>
</plugin>
and in your xml mojo :
<parameter>
<name>name</name>
<property>name</property>
<required>true</required>
<type>java.lang.String</type>
...
</parameter>
but what i actually want to do is using complex objects, as described here
:
http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
<configuration>
<person>
<firstName>Jason</firstName>
<lastName>van Zyl</lastName>
</person>
</configuration>
I've tried several possible configurations but no success...any idea
on how to do it ?
Thanxs,
Max
Re: maven-plugin-tools-ant custom parameter
Posted by "Mark H. Wood" <mw...@IUPUI.Edu>.
On Tue, Jan 17, 2012 at 10:43:10PM +0100, Robert Scholte wrote:
> Hi Max,
>
> Don't confuse a mojo with a pojo.
> The Mojo reflects the actual goal, supports injection, etc, etc.
> A pojo is just that plain old java object: private fields with their
> getters and setters
> Only for mojo's the @parameters can be used.
> Such field can be of a lot of types: String, primitive, pojo, array or
> List of one of these types (as long as Plexus can transform it)
> The @parameter on the name of the person won't work.
It would be nice if the rules were documented somewhere.
> I strongly advice you to first read the 5 minutes[1] and 30 minutes[2]
> tutorials.
I wish him luck. They leave a lot out. At least, I *think* they do,
because I had a lot of questions that don't seem to be answered
anywhere. I went digging in the code, wound up deep inside Plexus,
submitted a documentation patch for the bits I managed to understand,
but still felt no certainty.
So what *are* we supposed to do if we want structured parameters? And
where should I have read that?
--
Mark H. Wood, Lead System Programmer mwood@IUPUI.Edu
Asking whether markets are efficient is like asking whether people are smart.
Re: maven-plugin-tools-ant custom parameter
Posted by Robert Scholte <ap...@sourcegrounds.com>.
Hi Max,
Don't confuse a mojo with a pojo.
The Mojo reflects the actual goal, supports injection, etc, etc.
A pojo is just that plain old java object: private fields with their
getters and setters
Only for mojo's the @parameters can be used.
Such field can be of a lot of types: String, primitive, pojo, array or
List of one of these types (as long as Plexus can transform it)
The @parameter on the name of the person won't work.
I've never developed Ant Plugins for Maven 2.x, this is the first time I
see this page.
My impression is that this was written in the early days of Maven 2.
I don't think there are a lot of people who are still developing
Maven-plugins like this.
I strongly advice you to first read the 5 minutes[1] and 30 minutes[2]
tutorials.
Next check if there is already a plugin which already solves your problem,
you're probably not the first one [3] (at the bottom are some other
maven-plugin communities)
Unlike Ant it's much easier to reuse "build-scripts"/plugins.
-Robert
[1]
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
[2] http://maven.apache.org/guides/getting-started/index.html
[3] http://maven.apache.org/plugins/index.html
On Tue, 17 Jan 2012 15:22:05 +0100, Maxime Carpentier
<ca...@gmail.com> wrote:
> Thanxs Robert, but i still don't get it
>
> i'm just replacing my String object (which works fine) by a Person object
> so instead of having in my project's pom :
>
> <configuration><person>John </person></configuration>
> i have :
> <configuration><person><name>Jason</name></person></configuration>
>
> Doesn't it work this way ? :
> plugin mojo.xml : declaring properties used in build.xml
> plugin build.xml : executed part, using properties declared in mojo.xml
> and
> valued in project's pom
> project pom : defining properties value
>
> In a more simple exemple, how to use a List instead of a String
> parameter ?
>
> i'm using maven-plugin-tools-ant because i'd like use an already existing
> build.xml file...
>
> Thanxs for your help,
> Max
>
> On Mon, Jan 16, 2012 at 6:29 PM, Robert Scholte
> <ap...@sourcegrounds.com>wrote:
>
>> Yes you're missing something.
>> If we keep it very simple: you can use properties to set the
>> configuration, but you can't use configuration to set a property.
>> I'm wondering why you're using Ant and not just making an Mojo.
>>
>> Please check http://www.sonatype.com/books/**
>> mvnref-book/reference/writing-**plugins-sect-mojo-params.html<http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-mojo-params.html>
>>
>> -Robert
>>
>>
>> On Mon, 16 Jan 2012 10:16:22 +0100, Maxime Carpentier <
>> carpentier.max@gmail.com> wrote:
>>
>> yes, but i'm not sure about my hello.mojos.xml :
>>>
>>> *Person.java :*
>>>
>>> package my.test.maven;
>>>
>>> public class Person {
>>> /**
>>> * @parameter expression="${cvs.name}"
>>> */
>>> private String name;
>>> public String getName() {
>>> return name;
>>> }
>>> public void setName(String name) {
>>> this.name= name;
>>> }
>>> }
>>>
>>> *hello.mojos.xml :*
>>>
>>>
>>> <pluginMetadata>
>>> <mojos>
>>> <mojo>
>>> <goal>sayhi</goal>
>>> <requiresProject>true</**requiresProject>
>>> <call>sayhi-ant</call>
>>> <parameters>
>>> <parameter>
>>> <name>person</name>
>>> <property>person</property>
>>> <required>true</required>
>>> <expression>${person}</**expression>
>>> <type>my.test.maven.Person</**type>
>>> </parameter>
>>> <parameters>
>>> <mojos>
>>> <mojo>
>>> <pluginMetadata>
>>>
>>> and in my hello.build.xml : <echo message="Hello ${person} - ${
>>> person.name}
>>> " /> outputs : Hello ${person} - ${person.name}
>>> did i miss something ?
>>>
>>> On Fri, Jan 13, 2012 at 9:21 PM, Robert Scholte
>>> <apache@sourcegrounds.com
>>> >**wrote:
>>>
>>> have you tried to create a pojo called Person (with getters + setters
>>> for
>>>> firstName and lastName) in the same package as the mojo?
>>>> did you add something like this to the mojo
>>>>
>>>> /**
>>>> * @parameter
>>>> */
>>>> private Person person;
>>>>
>>>>
>>>> -Robert
>>>>
>>>>
>>>>
>>>> On Fri, 13 Jan 2012 11:53:53 +0100, Maxime Carpentier <
>>>> carpentier.max@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>>> I'm developping a new plugin using ant, guided by
>>>>> http://maven.apache.org/****guides/plugin/guide-ant-**<http://maven.apache.org/**guides/plugin/guide-ant-**>
>>>>> plugin-development.html<http:/**/maven.apache.org/guides/**
>>>>> plugin/guide-ant-plugin-**development.html<http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html>
>>>>> >
>>>>>
>>>>> .
>>>>> In this tutorial you can see how to map parameter for your plugin,
>>>>> declaring in your pom.xml :
>>>>>
>>>>> <plugin>
>>>>> <groupId>org.myproject.****plugins</groupId>
>>>>> <artifactId>hello-plugin</****artifactId>
>>>>> <version>1.0-SNAPSHOT</****version>
>>>>>
>>>>>
>>>>> <configuration>
>>>>> <name>John</name>
>>>>> </configuration>
>>>>> </plugin>
>>>>>
>>>>> and in your xml mojo :
>>>>>
>>>>> <parameter>
>>>>> <name>name</name>
>>>>> <property>name</property>
>>>>> <required>true</required>
>>>>> <type>java.lang.String</type>
>>>>> ...
>>>>> </parameter>
>>>>>
>>>>> but what i actually want to do is using complex objects, as described
>>>>> here
>>>>> :
>>>>> http://maven.apache.org/****guides/mini/guide-configuring-****<http://maven.apache.org/**guides/mini/guide-configuring-**>
>>>>> plugins.html#Mapping_Complex_****Objects<http://maven.apache.**
>>>>> org/guides/mini/guide-**configuring-plugins.html#**
>>>>> Mapping_Complex_Objects<http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects>
>>>>> >
>>>>>
>>>>>
>>>>> <configuration>
>>>>> <person>
>>>>> <firstName>Jason</firstName>
>>>>> <lastName>van Zyl</lastName>
>>>>> </person>
>>>>> </configuration>
>>>>>
>>>>> I've tried several possible configurations but no success...any idea
>>>>> on how to do it ?
>>>>> Thanxs,
>>>>>
>>>>> Max
>>>>>
>>>>>
>>>> ------------------------------****----------------------------**
>>>> --**---------
>>>> To unsubscribe, e-mail:
>>>> users-unsubscribe@maven.**apac**he.org<http://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<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-tools-ant custom parameter
Posted by Maxime Carpentier <ca...@gmail.com>.
Thanxs Robert, but i still don't get it
i'm just replacing my String object (which works fine) by a Person object
so instead of having in my project's pom :
<configuration><person>John </person></configuration>
i have :
<configuration><person><name>Jason</name></person></configuration>
Doesn't it work this way ? :
plugin mojo.xml : declaring properties used in build.xml
plugin build.xml : executed part, using properties declared in mojo.xml and
valued in project's pom
project pom : defining properties value
In a more simple exemple, how to use a List instead of a String parameter ?
i'm using maven-plugin-tools-ant because i'd like use an already existing
build.xml file...
Thanxs for your help,
Max
On Mon, Jan 16, 2012 at 6:29 PM, Robert Scholte <ap...@sourcegrounds.com>wrote:
> Yes you're missing something.
> If we keep it very simple: you can use properties to set the
> configuration, but you can't use configuration to set a property.
> I'm wondering why you're using Ant and not just making an Mojo.
>
> Please check http://www.sonatype.com/books/**
> mvnref-book/reference/writing-**plugins-sect-mojo-params.html<http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-mojo-params.html>
>
> -Robert
>
>
> On Mon, 16 Jan 2012 10:16:22 +0100, Maxime Carpentier <
> carpentier.max@gmail.com> wrote:
>
> yes, but i'm not sure about my hello.mojos.xml :
>>
>> *Person.java :*
>>
>> package my.test.maven;
>>
>> public class Person {
>> /**
>> * @parameter expression="${cvs.name}"
>> */
>> private String name;
>> public String getName() {
>> return name;
>> }
>> public void setName(String name) {
>> this.name= name;
>> }
>> }
>>
>> *hello.mojos.xml :*
>>
>>
>> <pluginMetadata>
>> <mojos>
>> <mojo>
>> <goal>sayhi</goal>
>> <requiresProject>true</**requiresProject>
>> <call>sayhi-ant</call>
>> <parameters>
>> <parameter>
>> <name>person</name>
>> <property>person</property>
>> <required>true</required>
>> <expression>${person}</**expression>
>> <type>my.test.maven.Person</**type>
>> </parameter>
>> <parameters>
>> <mojos>
>> <mojo>
>> <pluginMetadata>
>>
>> and in my hello.build.xml : <echo message="Hello ${person} - ${
>> person.name}
>> " /> outputs : Hello ${person} - ${person.name}
>> did i miss something ?
>>
>> On Fri, Jan 13, 2012 at 9:21 PM, Robert Scholte <apache@sourcegrounds.com
>> >**wrote:
>>
>> have you tried to create a pojo called Person (with getters + setters for
>>> firstName and lastName) in the same package as the mojo?
>>> did you add something like this to the mojo
>>>
>>> /**
>>> * @parameter
>>> */
>>> private Person person;
>>>
>>>
>>> -Robert
>>>
>>>
>>>
>>> On Fri, 13 Jan 2012 11:53:53 +0100, Maxime Carpentier <
>>> carpentier.max@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>>> I'm developping a new plugin using ant, guided by
>>>> http://maven.apache.org/****guides/plugin/guide-ant-**<http://maven.apache.org/**guides/plugin/guide-ant-**>
>>>> plugin-development.html<http:/**/maven.apache.org/guides/**
>>>> plugin/guide-ant-plugin-**development.html<http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html>
>>>> >
>>>>
>>>> .
>>>> In this tutorial you can see how to map parameter for your plugin,
>>>> declaring in your pom.xml :
>>>>
>>>> <plugin>
>>>> <groupId>org.myproject.****plugins</groupId>
>>>> <artifactId>hello-plugin</****artifactId>
>>>> <version>1.0-SNAPSHOT</****version>
>>>>
>>>>
>>>> <configuration>
>>>> <name>John</name>
>>>> </configuration>
>>>> </plugin>
>>>>
>>>> and in your xml mojo :
>>>>
>>>> <parameter>
>>>> <name>name</name>
>>>> <property>name</property>
>>>> <required>true</required>
>>>> <type>java.lang.String</type>
>>>> ...
>>>> </parameter>
>>>>
>>>> but what i actually want to do is using complex objects, as described
>>>> here
>>>> :
>>>> http://maven.apache.org/****guides/mini/guide-configuring-****<http://maven.apache.org/**guides/mini/guide-configuring-**>
>>>> plugins.html#Mapping_Complex_****Objects<http://maven.apache.**
>>>> org/guides/mini/guide-**configuring-plugins.html#**
>>>> Mapping_Complex_Objects<http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects>
>>>> >
>>>>
>>>>
>>>> <configuration>
>>>> <person>
>>>> <firstName>Jason</firstName>
>>>> <lastName>van Zyl</lastName>
>>>> </person>
>>>> </configuration>
>>>>
>>>> I've tried several possible configurations but no success...any idea
>>>> on how to do it ?
>>>> Thanxs,
>>>>
>>>> Max
>>>>
>>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.**apac**he.org<http://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<us...@maven.apache.org>
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: maven-plugin-tools-ant custom parameter
Posted by Robert Scholte <ap...@sourcegrounds.com>.
Yes you're missing something.
If we keep it very simple: you can use properties to set the
configuration, but you can't use configuration to set a property.
I'm wondering why you're using Ant and not just making an Mojo.
Please check
http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-mojo-params.html
-Robert
On Mon, 16 Jan 2012 10:16:22 +0100, Maxime Carpentier
<ca...@gmail.com> wrote:
> yes, but i'm not sure about my hello.mojos.xml :
>
> *Person.java :*
> package my.test.maven;
>
> public class Person {
> /**
> * @parameter expression="${cvs.name}"
> */
> private String name;
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name= name;
> }
> }
>
> *hello.mojos.xml :*
>
> <pluginMetadata>
> <mojos>
> <mojo>
> <goal>sayhi</goal>
> <requiresProject>true</requiresProject>
> <call>sayhi-ant</call>
> <parameters>
> <parameter>
> <name>person</name>
> <property>person</property>
> <required>true</required>
> <expression>${person}</expression>
> <type>my.test.maven.Person</type>
> </parameter>
> <parameters>
> <mojos>
> <mojo>
> <pluginMetadata>
>
> and in my hello.build.xml : <echo message="Hello ${person} -
> ${person.name}
> " /> outputs : Hello ${person} - ${person.name}
> did i miss something ?
>
> On Fri, Jan 13, 2012 at 9:21 PM, Robert Scholte
> <ap...@sourcegrounds.com>wrote:
>
>> have you tried to create a pojo called Person (with getters + setters
>> for
>> firstName and lastName) in the same package as the mojo?
>> did you add something like this to the mojo
>>
>> /**
>> * @parameter
>> */
>> private Person person;
>>
>>
>> -Robert
>>
>>
>>
>> On Fri, 13 Jan 2012 11:53:53 +0100, Maxime Carpentier <
>> carpentier.max@gmail.com> wrote:
>>
>> Hi,
>>> I'm developping a new plugin using ant, guided by
>>> http://maven.apache.org/**guides/plugin/guide-ant-**
>>> plugin-development.html<http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html>
>>> .
>>> In this tutorial you can see how to map parameter for your plugin,
>>> declaring in your pom.xml :
>>>
>>> <plugin>
>>> <groupId>org.myproject.**plugins</groupId>
>>> <artifactId>hello-plugin</**artifactId>
>>> <version>1.0-SNAPSHOT</**version>
>>>
>>> <configuration>
>>> <name>John</name>
>>> </configuration>
>>> </plugin>
>>>
>>> and in your xml mojo :
>>>
>>> <parameter>
>>> <name>name</name>
>>> <property>name</property>
>>> <required>true</required>
>>> <type>java.lang.String</type>
>>> ...
>>> </parameter>
>>>
>>> but what i actually want to do is using complex objects, as described
>>> here
>>> :
>>> http://maven.apache.org/**guides/mini/guide-configuring-**
>>> plugins.html#Mapping_Complex_**Objects<http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects>
>>>
>>> <configuration>
>>> <person>
>>> <firstName>Jason</firstName>
>>> <lastName>van Zyl</lastName>
>>> </person>
>>> </configuration>
>>>
>>> I've tried several possible configurations but no success...any idea
>>> on how to do it ?
>>> Thanxs,
>>>
>>> Max
>>>
>>
>> ------------------------------**------------------------------**---------
>> 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-tools-ant custom parameter
Posted by Maxime Carpentier <ca...@gmail.com>.
yes, but i'm not sure about my hello.mojos.xml :
*Person.java :*
package my.test.maven;
public class Person {
/**
* @parameter expression="${cvs.name}"
*/
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name= name;
}
}
*hello.mojos.xml :*
<pluginMetadata>
<mojos>
<mojo>
<goal>sayhi</goal>
<requiresProject>true</requiresProject>
<call>sayhi-ant</call>
<parameters>
<parameter>
<name>person</name>
<property>person</property>
<required>true</required>
<expression>${person}</expression>
<type>my.test.maven.Person</type>
</parameter>
<parameters>
<mojos>
<mojo>
<pluginMetadata>
and in my hello.build.xml : <echo message="Hello ${person} - ${person.name}
" /> outputs : Hello ${person} - ${person.name}
did i miss something ?
On Fri, Jan 13, 2012 at 9:21 PM, Robert Scholte <ap...@sourcegrounds.com>wrote:
> have you tried to create a pojo called Person (with getters + setters for
> firstName and lastName) in the same package as the mojo?
> did you add something like this to the mojo
>
> /**
> * @parameter
> */
> private Person person;
>
>
> -Robert
>
>
>
> On Fri, 13 Jan 2012 11:53:53 +0100, Maxime Carpentier <
> carpentier.max@gmail.com> wrote:
>
> Hi,
>> I'm developping a new plugin using ant, guided by
>> http://maven.apache.org/**guides/plugin/guide-ant-**
>> plugin-development.html<http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html>
>> .
>> In this tutorial you can see how to map parameter for your plugin,
>> declaring in your pom.xml :
>>
>> <plugin>
>> <groupId>org.myproject.**plugins</groupId>
>> <artifactId>hello-plugin</**artifactId>
>> <version>1.0-SNAPSHOT</**version>
>>
>> <configuration>
>> <name>John</name>
>> </configuration>
>> </plugin>
>>
>> and in your xml mojo :
>>
>> <parameter>
>> <name>name</name>
>> <property>name</property>
>> <required>true</required>
>> <type>java.lang.String</type>
>> ...
>> </parameter>
>>
>> but what i actually want to do is using complex objects, as described here
>> :
>> http://maven.apache.org/**guides/mini/guide-configuring-**
>> plugins.html#Mapping_Complex_**Objects<http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects>
>>
>> <configuration>
>> <person>
>> <firstName>Jason</firstName>
>> <lastName>van Zyl</lastName>
>> </person>
>> </configuration>
>>
>> I've tried several possible configurations but no success...any idea
>> on how to do it ?
>> Thanxs,
>>
>> Max
>>
>
> ------------------------------**------------------------------**---------
> 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-tools-ant custom parameter
Posted by Robert Scholte <ap...@sourcegrounds.com>.
have you tried to create a pojo called Person (with getters + setters for
firstName and lastName) in the same package as the mojo?
did you add something like this to the mojo
/**
* @parameter
*/
private Person person;
-Robert
On Fri, 13 Jan 2012 11:53:53 +0100, Maxime Carpentier
<ca...@gmail.com> wrote:
> Hi,
> I'm developping a new plugin using ant, guided by
> http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html.
> In this tutorial you can see how to map parameter for your plugin,
> declaring in your pom.xml :
>
> <plugin>
> <groupId>org.myproject.plugins</groupId>
> <artifactId>hello-plugin</artifactId>
> <version>1.0-SNAPSHOT</version>
>
> <configuration>
> <name>John</name>
> </configuration>
> </plugin>
>
> and in your xml mojo :
>
> <parameter>
> <name>name</name>
> <property>name</property>
> <required>true</required>
> <type>java.lang.String</type>
> ...
> </parameter>
>
> but what i actually want to do is using complex objects, as described
> here
> :
> http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
>
> <configuration>
> <person>
> <firstName>Jason</firstName>
> <lastName>van Zyl</lastName>
> </person>
> </configuration>
>
> I've tried several possible configurations but no success...any idea
> on how to do it ?
> Thanxs,
>
> Max
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org