You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sebastien Brunot <sb...@ilog.fr> on 2006/11/10 14:24:38 UTC

XML representation of an Artifact in the section of the POM

Hi all,
 
i have a mojo that defines a parameter names sourcePom which type is
Artifact :
 
/**

* The POM where jar dependencies are declared.

* 

* @parameter expression="${merge-jar-dependencies.sourcePom}"
default-value="${project.artifact}"

*/

private Artifact sourcePom;

 

I don't know how to specify an artifact under <configuration>
<sourcePom> ...

Thanks for your help,

Sebastien

 


Re: XML representation of an Artifact in the section of the POM

Posted by Wendy Smoak <ws...@gmail.com>.
On 11/10/06, franz see <fr...@gmail.com> wrote:
>
> Good day to you, Sebastien,
>
> No problem ;-)
>
> Wow..thanks for the information. :-)

Would any of this be appropriate for the 'Mojo Developer Cookbook' on the wiki?

http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook

If it's something that took you time to figure out, it might help the
next person if you can summarize it on the wiki.

-- 
Wendy

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


RE: XML representation of an Artifact in the section of the POM

Posted by franz see <fr...@gmail.com>.
Good day to you, Sebastien,

No problem ;-)

Wow..thanks for the information. :-)

Thanks a bunch,
Franz


Sebastien Brunot wrote:
> 
> Thanks for your help franz, it's nice to have the kind of support you
> provides.
> 
> In fact, I've adopted the strategy I've seen in the
> maven-dependency-plugin :
> 
> 1) I've included in my plugin a java bean PomArtifact that declares
> three String attributes : groupId, artifactId and version. Public
> getters and setters are defined for those attributes, and the attributes
> javadoc uses the @parameter and @required annotations (note that
> defining default values such as ${project.groupId} fot those attributes
> doen not seems to work)
> 
> 2) In my mojo, sourcePom type is now PomArtifact
> 
> 3) Everything works fine using the following xml in the POM :
> 
> <project>
>   ...
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>...</groupId>
>         <artifactId>...</artifactId>
>         <version>...</version>
>         <executions>
>           <execution>
>             <configuration>
>               <sourcePom>
>                 <artifactId>...</artifactId>
>                 <groupId>...</groupId>
>                 <version>...</version>
>               </sourcePom>
>             <configuration>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
> </project>
> 
> 4) In my Mojo execute method, I will now create an Artifact object using
> the values retrieved from sourcePom.
> 
> Sebastien
> 
> -----Original Message-----
> From: franz see [mailto:franz.see@gmail.com] 
> Sent: Friday, November 10, 2006 2:54 PM
> To: users@maven.apache.org
> Subject: Re: XML representation of an Artifact in the <configuration>
> section of the POM
> 
> 
> Good day to you, Sebastien,
> 
> Note: I don't know everything about mojo parameters but i'll show what i
> know so far
> 
> Here's the break down of a mojo parameter:
> 
> /**
>  *  @parameter expression="${merge-jar-dependencies.sourcePom}"
> default-value="${project.artifact}"
>  */
> private Aritfact sourcePom;
> 
> expression (in your case, merge-jar-dependencies.sourcePom). 
> `--> Used to inject a Property value to that parameter (sourcePom).
> Properties may come from System / Environment Variables, POM properties,
> Commandline Properties, Filter properties, or other predefined
> properties (i.e project.artifact). 
> 
> default-value (in your case, project.artifact) `--> Injects a property
> to your parameter. 
> 
> you class's field (in your case, soucePom) `--> This is your paramater.
> If the first two discussed here is injected by properties, this one is
> injected from the <configuration> element in your pom. (Note: AFAIK, if
> you set your experssion as a predefined property such as
> project.artifact, the parameter can no longer be configured in your pom)
> 
> 
> 
> To answer your question, since you're using a class, you use the
> parameter.
> 
> <project>
>   ...
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>...</groupId>
>         <artifactId>...</artifactId>
>         <version>...</version>
>         <executions>
>           <execution>
>             <configuration>
>               <sourcePom>
>                 <artifactId>...</artifactId>
>                 <groupId>...</groupId>
>                 <version>...</version>
>                 ...
>               </sourcePom>
>             <configuration>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
> </project>
> 
> the <sourcePom> represents your sourcePom field in your class.
> the elements of <sourcePom> are the fields of the Artifact.
> 
> Things I am unsure of:
> 1. I am not sure if <sourcePom> will work as it is. But if not, you may
> want to try <sourcePom
> implementation="org.apache.maven.artifact.DefaultArtifact". 
> 2. I am not sure if "private Aritfact sourcePom" will work as well, you
> may want to try DefaultArtifact.
> 3. Most likely, #1 & #2 will work withouth those "workarounds" i
> mentioned, Im just not sure how.
> 4. I am not sure whether it is the fields of the Artifact that you
> access with the elements of <sourcePom> or the setters.
> 
> If you find the answers to those, or if somebody out there who knows,
> kindly share it with us :-)
> 
> Thanks,
> Franz
> 
> 
> Sebastien Brunot wrote:
>> 
>> Hi all,
>>  
>> i have a mojo that defines a parameter names sourcePom which type is 
>> Artifact :
>>  
>> /**
>> 
>> * The POM where jar dependencies are declared.
>> 
>> *
>> 
>> * @parameter expression="${merge-jar-dependencies.sourcePom}"
>> default-value="${project.artifact}"
>> 
>> */
>> 
>> private Artifact sourcePom;
>> 
>>  
>> 
>> I don't know how to specify an artifact under <configuration> 
>> <sourcePom> ...
>> 
>> Thanks for your help,
>> 
>> Sebastien
>> 
>>  
>> 
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/XML-representation-of-an-Artifact-in-the-%3Cconfig
> uration%3E-section-of-the-POM-tf2607681s177.html#a7277297
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/XML-representation-of-an-Artifact-in-the-%3Cconfiguration%3E-section-of-the-POM-tf2607681s177.html#a7288606
Sent from the Maven - Users mailing list archive at Nabble.com.


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


RE: XML representation of an Artifact in the section of the POM

Posted by Sebastien Brunot <sb...@ilog.fr>.
Thanks for your help franz, it's nice to have the kind of support you
provides.

In fact, I've adopted the strategy I've seen in the
maven-dependency-plugin :

1) I've included in my plugin a java bean PomArtifact that declares
three String attributes : groupId, artifactId and version. Public
getters and setters are defined for those attributes, and the attributes
javadoc uses the @parameter and @required annotations (note that
defining default values such as ${project.groupId} fot those attributes
doen not seems to work)

2) In my mojo, sourcePom type is now PomArtifact

3) Everything works fine using the following xml in the POM :

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>...</groupId>
        <artifactId>...</artifactId>
        <version>...</version>
        <executions>
          <execution>
            <configuration>
              <sourcePom>
                <artifactId>...</artifactId>
                <groupId>...</groupId>
                <version>...</version>
              </sourcePom>
            <configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

4) In my Mojo execute method, I will now create an Artifact object using
the values retrieved from sourcePom.

Sebastien

-----Original Message-----
From: franz see [mailto:franz.see@gmail.com] 
Sent: Friday, November 10, 2006 2:54 PM
To: users@maven.apache.org
Subject: Re: XML representation of an Artifact in the <configuration>
section of the POM


Good day to you, Sebastien,

Note: I don't know everything about mojo parameters but i'll show what i
know so far

Here's the break down of a mojo parameter:

/**
 *  @parameter expression="${merge-jar-dependencies.sourcePom}"
default-value="${project.artifact}"
 */
private Aritfact sourcePom;

expression (in your case, merge-jar-dependencies.sourcePom). 
`--> Used to inject a Property value to that parameter (sourcePom).
Properties may come from System / Environment Variables, POM properties,
Commandline Properties, Filter properties, or other predefined
properties (i.e project.artifact). 

default-value (in your case, project.artifact) `--> Injects a property
to your parameter. 

you class's field (in your case, soucePom) `--> This is your paramater.
If the first two discussed here is injected by properties, this one is
injected from the <configuration> element in your pom. (Note: AFAIK, if
you set your experssion as a predefined property such as
project.artifact, the parameter can no longer be configured in your pom)



To answer your question, since you're using a class, you use the
parameter.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>...</groupId>
        <artifactId>...</artifactId>
        <version>...</version>
        <executions>
          <execution>
            <configuration>
              <sourcePom>
                <artifactId>...</artifactId>
                <groupId>...</groupId>
                <version>...</version>
                ...
              </sourcePom>
            <configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

the <sourcePom> represents your sourcePom field in your class.
the elements of <sourcePom> are the fields of the Artifact.

Things I am unsure of:
1. I am not sure if <sourcePom> will work as it is. But if not, you may
want to try <sourcePom
implementation="org.apache.maven.artifact.DefaultArtifact". 
2. I am not sure if "private Aritfact sourcePom" will work as well, you
may want to try DefaultArtifact.
3. Most likely, #1 & #2 will work withouth those "workarounds" i
mentioned, Im just not sure how.
4. I am not sure whether it is the fields of the Artifact that you
access with the elements of <sourcePom> or the setters.

If you find the answers to those, or if somebody out there who knows,
kindly share it with us :-)

Thanks,
Franz


Sebastien Brunot wrote:
> 
> Hi all,
>  
> i have a mojo that defines a parameter names sourcePom which type is 
> Artifact :
>  
> /**
> 
> * The POM where jar dependencies are declared.
> 
> *
> 
> * @parameter expression="${merge-jar-dependencies.sourcePom}"
> default-value="${project.artifact}"
> 
> */
> 
> private Artifact sourcePom;
> 
>  
> 
> I don't know how to specify an artifact under <configuration> 
> <sourcePom> ...
> 
> Thanks for your help,
> 
> Sebastien
> 
>  
> 
> 
> 

--
View this message in context:
http://www.nabble.com/XML-representation-of-an-Artifact-in-the-%3Cconfig
uration%3E-section-of-the-POM-tf2607681s177.html#a7277297
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@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: XML representation of an Artifact in the section of the POM

Posted by franz see <fr...@gmail.com>.
Good day to you, Sebastien,

Note: I don't know everything about mojo parameters but i'll show what i
know so far

Here's the break down of a mojo parameter:

/**
 *  @parameter expression="${merge-jar-dependencies.sourcePom}"
default-value="${project.artifact}"
 */
private Aritfact sourcePom;

expression (in your case, merge-jar-dependencies.sourcePom). 
`--> Used to inject a Property value to that parameter (sourcePom).
Properties may come from System / Environment Variables, POM properties,
Commandline Properties, Filter properties, or other predefined properties
(i.e project.artifact). 

default-value (in your case, project.artifact)
`--> Injects a property to your parameter. 

you class's field (in your case, soucePom)
`--> This is your paramater. If the first two discussed here is injected by
properties, this one is injected from the <configuration> element in your
pom. (Note: AFAIK, if you set your experssion as a predefined property such
as project.artifact, the parameter can no longer be configured in your pom)



To answer your question, since you're using a class, you use the parameter.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>...</groupId>
        <artifactId>...</artifactId>
        <version>...</version>
        <executions>
          <execution>
            <configuration>
              <sourcePom>
                <artifactId>...</artifactId>
                <groupId>...</groupId>
                <version>...</version>
                ...
              </sourcePom>
            <configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

the <sourcePom> represents your sourcePom field in your class.
the elements of <sourcePom> are the fields of the Artifact.

Things I am unsure of:
1. I am not sure if <sourcePom> will work as it is. But if not, you may want
to try <sourcePom
implementation="org.apache.maven.artifact.DefaultArtifact". 
2. I am not sure if "private Aritfact sourcePom" will work as well, you may
want to try DefaultArtifact.
3. Most likely, #1 & #2 will work withouth those "workarounds" i mentioned,
Im just not sure how.
4. I am not sure whether it is the fields of the Artifact that you access
with the elements of <sourcePom> or the setters.

If you find the answers to those, or if somebody out there who knows, kindly
share it with us :-)

Thanks,
Franz


Sebastien Brunot wrote:
> 
> Hi all,
>  
> i have a mojo that defines a parameter names sourcePom which type is
> Artifact :
>  
> /**
> 
> * The POM where jar dependencies are declared.
> 
> * 
> 
> * @parameter expression="${merge-jar-dependencies.sourcePom}"
> default-value="${project.artifact}"
> 
> */
> 
> private Artifact sourcePom;
> 
>  
> 
> I don't know how to specify an artifact under <configuration>
> <sourcePom> ...
> 
> Thanks for your help,
> 
> Sebastien
> 
>  
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/XML-representation-of-an-Artifact-in-the-%3Cconfiguration%3E-section-of-the-POM-tf2607681s177.html#a7277297
Sent from the Maven - Users mailing list archive at Nabble.com.


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