Mojo + JUnit4 = MavenProject NPE

2016-12-20 Thread Guillaume Ch
Hi all,

I've a issue with one of my mojo UT with JUnit4 (MojoRule )[1].
When my UT run, the MavenProject attribute is not initialized. But
bypassing this test and running my Mojo as a real plugin in a project work
fine.

Did someone have experimented a similar issue ?

Best regards

[1]
https://github.com/gchauvet/daemonize-maven-plugin/blob/master/src/test/java/io/zatarox/maven/daemonize/StartDaemonMojoTest.java#L34


Re: Generate A Maven artifact's dependencies and licenses ( how to instantiate a MavenProject using a giving artifact coordinate)

2014-07-12 Thread Dan Tran
I found a solution for this is to start up with my existing MavenProject
which is very much empty since it is run under standalone command line,
push the interested artifact into the MavenProject as a dependency
artifact, after that I can use it with MavenDependencyGraphBuilder

-Dan


On Fri, Jul 11, 2014 at 9:55 PM, Dan Tran  wrote:

>
> Hello,
>
> I have a need to create an spreadsheet ( for legal purpose) containing a
> Maven artifact, base on a given coordinate,  and all of its transitive
> dependencies and associated license info
>
> There are 2 plugins having this kind of requirements:
> maven-project-info-report-plugin and license-maven-plugin, both of these
> projects  have a maven project to work with. ( ie MavenProject )
>
> For my case,  I need to  instantiate MavenProject from the provided
> artifact using ProjectBuilder component, but this gives all kind of problem
> from stack overflow to NPE
>
> here is code
>
> private MavenProject getMavenProjectFromArtifact( Artifact artifact )
> throws ProjectBuildingException
> {
> ProjectBuildingRequest request = new
> DefaultProjectBuildingRequest();
> request.setLocalRepository( localRepository );
> request.setPluginArtifactRepositories( pluginArtifactRepositories
> );
> request.setRemoteRepositories( remoteRepositories );
> request.setResolveDependencies( true );
> request.setResolveVersionRanges( true );
>
>
> ProjectBuildingResult result = projectBuilder.build( artifact,
> request );
>
> return result.getProject();
> }
>
>
> Am I using the right builder?
>
>
> Any advice to get this working is very much appreciated.
>
>
> Thanks
>
> -Dan
>
>
>
>
>
>


Generate A Maven artifact's dependencies and licenses ( how to instantiate a MavenProject using a giving artifact coordinate)

2014-07-11 Thread Dan Tran
Hello,

I have a need to create an spreadsheet ( for legal purpose) containing a
Maven artifact, base on a given coordinate,  and all of its transitive
dependencies and associated license info

There are 2 plugins having this kind of requirements:
maven-project-info-report-plugin and license-maven-plugin, both of these
projects  have a maven project to work with. ( ie MavenProject )

For my case,  I need to  instantiate MavenProject from the provided
artifact using ProjectBuilder component, but this gives all kind of problem
from stack overflow to NPE

here is code

private MavenProject getMavenProjectFromArtifact( Artifact artifact )
throws ProjectBuildingException
{
ProjectBuildingRequest request = new
DefaultProjectBuildingRequest();
request.setLocalRepository( localRepository );
request.setPluginArtifactRepositories( pluginArtifactRepositories );
request.setRemoteRepositories( remoteRepositories );
request.setResolveDependencies( true );
request.setResolveVersionRanges( true );


ProjectBuildingResult result = projectBuilder.build( artifact,
request );

return result.getProject();
}


Am I using the right builder?


Any advice to get this working is very much appreciated.


Thanks

-Dan


RE: Reload MavenProject MavenSession and BuildPluginManager

2014-02-15 Thread DK
I tried the following but the project version didn't work


Artifact artifact = project.getArtifact();
try {
artifactResolver.resolve(artifact,
remoteArtifactRepositories, localRepository);

System.out.println("project = " + project.getVersion());
System.out.println("artifact = " + artifact.getVersion());
} catch (ArtifactResolutionException ex) {
getLog().error(null, ex);
} catch (ArtifactNotFoundException ex) {
getLog().error(null, ex);
}





--
View this message in context: 
http://maven.40175.n5.nabble.com/Reload-MavenProject-MavenSession-and-BuildPluginManager-tp5783698p5785012.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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



RE: Reload MavenProject MavenSession and BuildPluginManager

2014-02-09 Thread Martin Gainty
you will need to trigger ArtifactResolver.resolveAlways with the artifact, 
localRepository properly populated for each of the requested artifacts..Here is 
an example from maven-netbeans-plugin

 

private void resolve(Artifact artifact, boolean failOnError, boolean remote) 
throws MojoExecutionException { 

129.if (!artifact.isResolved() || artifact.isSnapshot()) { 
130.try { 
131.artifactResolver.resolveAlways(artifact, remote ? 
remoteArtifactRepositories : Collections.EMPTY_LIST, localRepository); 
132.} catch (AbstractArtifactResolutionException ex) { 
133.if (failOnError) { 
134.throw new MojoExecutionException("can not resolve " + 
artifact, ex); 
135.} 
136.} 
137.} 
138.}

https://kenai.com/projects/mvn-nb-plugin/sources/subversion/content/src/main/java/com/kenai/maven/netbeans/plugin/NetBeansMojo.java?rev=4

Martin 
__ 

  


> Date: Sat, 8 Feb 2014 09:59:27 -0800
> From: desmond.kirr...@gmail.com
> To: users@maven.apache.org
> Subject: Reload MavenProject MavenSession and BuildPluginManager
> 
> How can my Moo reload/refresh MavenProject MavenSession and
> BuildPluginManager components.
> 
> I need to do this after my Mojo switches the a different Git branch.
> 
> 
> 
> --
> View this message in context: 
> http://maven.40175.n5.nabble.com/Reload-MavenProject-MavenSession-and-BuildPluginManager-tp5783698.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
  

RE: Reload MavenProject MavenSession and BuildPluginManager

2014-02-09 Thread DK
Not really an option as this may only run locally and my Mojo may be
configured to only create a local Git branch
On 9 Feb 2014 01:51, "mgainty [via Maven]" <
ml-node+s40175n5783730...@n5.nabble.com> wrote:

> > Date: Sat, 8 Feb 2014 09:59:27 -0800
> > From: [hidden email]<http://user/SendEmail.jtp?type=node&node=5783730&i=0>
> > To: [hidden email]<http://user/SendEmail.jtp?type=node&node=5783730&i=1>
> > Subject: Reload MavenProject MavenSession and BuildPluginManager
> >
> > How can my Moo reload/refresh MavenProject MavenSession and
> > BuildPluginManager components.
> >
> > I need to do this after my Mojo switches the a different Git branch.
> MG>so you have a "new feature branch"
> MG>git hf feature start ##feature name##
>
> MG>I would set this as a post-create task on a Hudson job  e.g.
> MG>and implement 'git hf feature #feature name#' on post-create of Hudson
> Job
> >
> > --
> > View this message in context:
> http://maven.40175.n5.nabble.com/Reload-MavenProject-MavenSession-and-BuildPluginManager-tp5783698.html
> > Sent from the Maven - Users mailing list archive at Nabble.com.
> >
> > -
> > To unsubscribe, e-mail: [hidden 
> > email]<http://user/SendEmail.jtp?type=node&node=5783730&i=2>
> > For additional commands, e-mail: [hidden 
> > email]<http://user/SendEmail.jtp?type=node&node=5783730&i=3>
> >
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://maven.40175.n5.nabble.com/Reload-MavenProject-MavenSession-and-BuildPluginManager-tp5783698p5783730.html
>  To unsubscribe from Reload MavenProject MavenSession and
> BuildPluginManager, click 
> here<http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5783698&code=ZGVzbW9uZC5raXJyYW5lQGdtYWlsLmNvbXw1NzgzNjk4fDk2MTMwOTQ5Mw==>
> .
> NAML<http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://maven.40175.n5.nabble.com/Reload-MavenProject-MavenSession-and-BuildPluginManager-tp5783698p5783778.html
Sent from the Maven - Users mailing list archive at Nabble.com.

RE: Reload MavenProject MavenSession and BuildPluginManager

2014-02-08 Thread Martin Gainty
> Date: Sat, 8 Feb 2014 09:59:27 -0800
> From: desmond.kirr...@gmail.com
> To: users@maven.apache.org
> Subject: Reload MavenProject MavenSession and BuildPluginManager
> 
> How can my Moo reload/refresh MavenProject MavenSession and
> BuildPluginManager components.
> 
> I need to do this after my Mojo switches the a different Git branch.
MG>so you have a "new feature branch"
MG>git hf feature start ##feature name## 

MG>I would set this as a post-create task on a Hudson job  e.g.
MG>and implement 'git hf feature #feature name#' on post-create of Hudson Job
> 
> --
> View this message in context: 
> http://maven.40175.n5.nabble.com/Reload-MavenProject-MavenSession-and-BuildPluginManager-tp5783698.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
  

Reload MavenProject MavenSession and BuildPluginManager

2014-02-08 Thread DK
How can my Moo reload/refresh MavenProject MavenSession and
BuildPluginManager components.

I need to do this after my Mojo switches the a different Git branch.



--
View this message in context: 
http://maven.40175.n5.nabble.com/Reload-MavenProject-MavenSession-and-BuildPluginManager-tp5783698.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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



Re: Maven Plugin Issue - MavenProject Not Bound

2013-01-20 Thread Robert Scholte

When using doclet-tags, you should use:
@parameter default-value="${project}"

Robert

Op Sun, 20 Jan 2013 22:34:31 +0100 schreef Jeremy Long  
:


I am trying to create a simple plugin to inspect project dependencies  
using
the MavenProject - but I'm getting an error because the MavenProject is  
not

bound (see below for details).

Here is the code for the plugin:

/**
 * Goal that checks project dependencies
 * @goal package
 * @phase package
 * @requiresProject false
 * @requiresDependencyResolution runtime
 * @requiresOnline true
 * @execute phase="package"
 */
public class DependencyCheckMojo extends AbstractMojo {

/**
 * POM
 *
 * @component
 */
    protected MavenProject project;

public void execute() throws MojoExecutionException {
if (project != null) {
Set artifacts = project.getArtifacts();
for (Artifact a : artifacts) {
getLog().error(a.getFile().toString());
}
} else {
getLog().error("Dependency Check - Maven project is null");
}
}
}

The POM for the plugin is:


org.codesecure
DependencyCheck-Plugin
1.0-SNAPSHOT
maven-plugin




maven-plugin-plugin
2.3

dependencycheck



mojo-descriptor

descriptor








org.apache.maven
maven-plugin-api
3.0


org.apache.maven
maven-core
3.0




However, when I use this plugin in another project:


org.codesecure
DependencyCheck-Plugin
1.0-SNAPSHOT

  
package

  package

  



And I run 'mvn package' I get the following error:

[ERROR] Failed to execute goal
org.codesecure:DependencyCheck-Plugin:1.0-SNAPSHO
T:package (default) on project sample: Execution default of goal
org.codesecure:
DependencyCheck-Plugin:1.0-SNAPSHOT:package failed: Unable to load the  
mojo

'pac
kage' (or one of its required components) from the plugin
'org.codesecure:Depend
encyCheck-Plugin:1.0-SNAPSHOT': com.google.inject.ProvisionException:  
Guice

prov
ision errors:
[ERROR]
[ERROR] 1) No implementation for org.apache.maven.project.MavenProject  
was

bound
.
[ERROR] while locating org.codesecure.DependencyCheckMojo


Any idea what I'm doing wrong?

Thanks in advance,

Jeremy


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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Hervé BOUTEMY
I wish we had this good discussion in may, when we wroked on plugin-tools ease 
of use enhancements

I understand your point
And in fact, when I write that the feature was added partly because parameter 
default-value="${project}" read-only="true", I see I didn't document it 
either, now that I'm able to do it because it is absolutely clear in my head 
(and wasn't before the work in may)

let's go ahead:
- now that the expressions will be well documented in future Maven versions 
(see [1] instead of [2])
- given that I'll add a documentation on the default-value pattern to get 
Maven objects, whatever we decide here
I'm ok to deprecate the @component trick in favour of the documentation 
written, because the trick can be confusing

tell me if you open a Jira issue, I'll be glad to work on it

Regards,

Hervé


[1] http://maven.apache.org/ref/3.1-SNAPSHOT/maven-
core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html

[2] http://maven.apache.org/ref/3.1-SNAPSHOT/maven-
core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html

Le mercredi 28 novembre 2012 20:19:44 Jason van Zyl a écrit :
> How does it help by telling them something factually incorrect? A component
> has a specific definition of being an instance created by the container.
> On Nov 28, 2012, at 7:23 PM, Hervé BOUTEMY  wrote:
> > no, we choose to do that for ease of use for the average plugin developer
> > 
> > we had a long discussion on how to ease plugin development, find a better
> > name than "expression", understand that such Maven object injection case
> > is best written as default-value than expression, and so on...
> > 
> > and actual plugins using @Component for injecting classical MavenProject
> > is
> > easier than @Parameter( defaultValue="${project}" ) even if the former is
> > a
> > trick
> > 
> > Le mercredi 28 novembre 2012 19:05:10 Jason van Zyl a écrit :
> >> I would remove that from the doco. I assume the @Parameter method still
> >> works and just keep that method.
> >> 
> >> jvz
> >> 
> >> On 2012-11-28, at 6:57 PM, Hervé BOUTEMY  wrote:
> >>> magic has been done:
> >>> see http://maven.apache.org/plugin-tools/apidocs/src-
> >>> html/org/apache/maven/tools/plugin/util/PluginUtils.html#line.40
> >>> 
> >>> Le mercredi 28 novembre 2012 18:54:11 Jason van Zyl a écrit :
> >>>> Internally the way @component works is to take the role of component
> >>>> supplied or figure it out. With that role a lookup against the
> >>>> container
> >>>> is
> >>>> executed. The MavenProject is not something that is available from the
> >>>> container because it is not a component. So I doubt it works, unless
> >>>> some
> >>>> magic was done to just make the @Component act on MavenProject's which
> >>>> itself doesn't make sense. It is meant to be a parameter, and that's
> >>>> what
> >>>> it has always been.
> >>>> 
> >>>> On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:
> >>>>> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
> >>>>>> The MavenProject is not a component that is injected by the
> >>>>>> container.
> >>>>>> It's handled by the PluginParameterExpressionEvaluator[1] which looks
> >>>>>> at
> >>>>>> all the non-@component things and sets their values once the Mojo
> >>>>>> instance is constructed.
> >>>>>> 
> >>>>>> [1]:
> >>>>>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java
> >>>>>> /o
> >>>>>> r
> >>>>>> g/apache/maven/plugin/PluginParameterExpressionEvaluator.java>
> >>>>> 
> >>>>> Does that mean our docs are wrong?
> >>>>> Do you have an example?
> >>>>> 
> >>>>> I've not used annotations before and I was trying to help someone
> >>>>> else's user list question.
> >>>>> And unfortunately google returns javadoc matches as well so wading
> >>>>> through examples was time consuming and not very enlightening.
> >>>>> 
> >>>>> And the link Olivier sent is using
> >>>>> 
> >>>>>  /**
> >>>>>  
> >>>>>   * The Maven project.
> >>>>>   

Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Jason van Zyl
How does it help by telling them something factually incorrect? A component has 
a specific definition of being an instance created by the container. 

On Nov 28, 2012, at 7:23 PM, Hervé BOUTEMY  wrote:

> no, we choose to do that for ease of use for the average plugin developer
> 
> we had a long discussion on how to ease plugin development, find a better 
> name 
> than "expression", understand that such Maven object injection case is best 
> written as default-value than expression, and so on...
> 
> and actual plugins using @Component for injecting classical MavenProject is 
> easier than @Parameter( defaultValue="${project}" ) even if the former is a 
> trick
> 
> Le mercredi 28 novembre 2012 19:05:10 Jason van Zyl a écrit :
>> I would remove that from the doco. I assume the @Parameter method still
>> works and just keep that method.
>> 
>> jvz
>> 
>> On 2012-11-28, at 6:57 PM, Hervé BOUTEMY  wrote:
>>> magic has been done:
>>> see http://maven.apache.org/plugin-tools/apidocs/src-
>>> html/org/apache/maven/tools/plugin/util/PluginUtils.html#line.40
>>> 
>>> Le mercredi 28 novembre 2012 18:54:11 Jason van Zyl a écrit :
>>>> Internally the way @component works is to take the role of component
>>>> supplied or figure it out. With that role a lookup against the container
>>>> is
>>>> executed. The MavenProject is not something that is available from the
>>>> container because it is not a component. So I doubt it works, unless some
>>>> magic was done to just make the @Component act on MavenProject's which
>>>> itself doesn't make sense. It is meant to be a parameter, and that's what
>>>> it has always been.
>>>> 
>>>> On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:
>>>>> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
>>>>>> The MavenProject is not a component that is injected by the container.
>>>>>> It's handled by the PluginParameterExpressionEvaluator[1] which looks
>>>>>> at
>>>>>> all the non-@component things and sets their values once the Mojo
>>>>>> instance is constructed.
>>>>>> 
>>>>>> [1]:
>>>>>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/o
>>>>>> r
>>>>>> g/apache/maven/plugin/PluginParameterExpressionEvaluator.java>
>>>>> 
>>>>> Does that mean our docs are wrong?
>>>>> Do you have an example?
>>>>> 
>>>>> I've not used annotations before and I was trying to help someone
>>>>> else's user list question.
>>>>> And unfortunately google returns javadoc matches as well so wading
>>>>> through examples was time consuming and not very enlightening.
>>>>> 
>>>>> And the link Olivier sent is using
>>>>> 
>>>>>  /**
>>>>> 
>>>>>   * The Maven project.
>>>>>   */
>>>>> 
>>>>>  @Component
>>>>>  private MavenProject project;
>>>>> 
>>>>> and is working, but when I tried that it didn't.
>>>>> 
>>>>> I'm going to try looking at the pom to see if there are some incorrect
>>>>> versions of dependencies might be causing an issue.
>>>>> 
>>>>> -
>>>>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
>>>>> For additional commands, e-mail: users-h...@maven.apache.org
>>>> 
>>>> Thanks,
>>>> 
>>>> Jason
>>>> 
>>>> --
>>>> Jason van Zyl
>>>> Founder & CTO, Sonatype
>>>> Founder,  Apache Maven
>>>> http://twitter.com/jvanzyl
>>>> -
>>>> 
>>>> To do two things at once is to do neither.
>>>> 
>>>> -- Publilius Syrus, Roman slave, first century B.C.
>>> 
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
>>> For additional commands, e-mail: users-h...@maven.apache.org
>> 
>> -
>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
>> For additional commands, e-mail: users-h...@maven.apache.org
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 

Thanks,

Jason

--
Jason van Zyl
Founder & CTO, Sonatype
Founder,  Apache Maven
http://twitter.com/jvanzyl
-

To do two things at once is to do neither.
 
 -- Publilius Syrus, Roman slave, first century B.C.







Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Hervé BOUTEMY
no, we choose to do that for ease of use for the average plugin developer

we had a long discussion on how to ease plugin development, find a better name 
than "expression", understand that such Maven object injection case is best 
written as default-value than expression, and so on...

and actual plugins using @Component for injecting classical MavenProject is 
easier than @Parameter( defaultValue="${project}" ) even if the former is a 
trick

Le mercredi 28 novembre 2012 19:05:10 Jason van Zyl a écrit :
> I would remove that from the doco. I assume the @Parameter method still
> works and just keep that method.
> 
> jvz
> 
> On 2012-11-28, at 6:57 PM, Hervé BOUTEMY  wrote:
> > magic has been done:
> > see http://maven.apache.org/plugin-tools/apidocs/src-
> > html/org/apache/maven/tools/plugin/util/PluginUtils.html#line.40
> > 
> > Le mercredi 28 novembre 2012 18:54:11 Jason van Zyl a écrit :
> >> Internally the way @component works is to take the role of component
> >> supplied or figure it out. With that role a lookup against the container
> >> is
> >> executed. The MavenProject is not something that is available from the
> >> container because it is not a component. So I doubt it works, unless some
> >> magic was done to just make the @Component act on MavenProject's which
> >> itself doesn't make sense. It is meant to be a parameter, and that's what
> >> it has always been.
> >> 
> >> On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:
> >>> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
> >>>> The MavenProject is not a component that is injected by the container.
> >>>> It's handled by the PluginParameterExpressionEvaluator[1] which looks
> >>>> at
> >>>> all the non-@component things and sets their values once the Mojo
> >>>> instance is constructed.
> >>>> 
> >>>> [1]:
> >>>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/o
> >>>> r
> >>>> g/apache/maven/plugin/PluginParameterExpressionEvaluator.java>
> >>> 
> >>> Does that mean our docs are wrong?
> >>> Do you have an example?
> >>> 
> >>> I've not used annotations before and I was trying to help someone
> >>> else's user list question.
> >>> And unfortunately google returns javadoc matches as well so wading
> >>> through examples was time consuming and not very enlightening.
> >>> 
> >>> And the link Olivier sent is using
> >>> 
> >>>   /**
> >>>   
> >>>* The Maven project.
> >>>*/
> >>>   
> >>>   @Component
> >>>   private MavenProject project;
> >>> 
> >>> and is working, but when I tried that it didn't.
> >>> 
> >>> I'm going to try looking at the pom to see if there are some incorrect
> >>> versions of dependencies might be causing an issue.
> >>> 
> >>> -
> >>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> >>> For additional commands, e-mail: users-h...@maven.apache.org
> >> 
> >> Thanks,
> >> 
> >> Jason
> >> 
> >> --
> >> Jason van Zyl
> >> Founder & CTO, Sonatype
> >> Founder,  Apache Maven
> >> http://twitter.com/jvanzyl
> >> -
> >> 
> >> To do two things at once is to do neither.
> >> 
> >> -- Publilius Syrus, Roman slave, first century B.C.
> > 
> > -
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Hervé BOUTEMY
it's confusing for people mastering a lot of things

for normal people, it was really not easy to understand, and not really 
documented, neither PluginParameterExpressionEvaluator (which I documented 
after I uderstood) nor the '@parameter default-value="${project}" 
readonly=true' pattern (lots of plugins had expression="${project}")

we had a long discussion on the dev list and found that, even if a little 
magic, it would be really easier to use: 
http://jira.codehaus.org/browse/MPLUGIN-204

the doc of the annotations show these special cases

Regards,

Hervé

Le mercredi 28 novembre 2012 19:00:03 Jason van Zyl a écrit :
> That's not right, and confusing. It's not a component.
> 
> jvz
> 
> On 2012-11-28, at 6:57 PM, Hervé BOUTEMY  wrote:
> > magic has been done:
> > see http://maven.apache.org/plugin-tools/apidocs/src-
> > html/org/apache/maven/tools/plugin/util/PluginUtils.html#line.40
> > 
> > Le mercredi 28 novembre 2012 18:54:11 Jason van Zyl a écrit :
> >> Internally the way @component works is to take the role of component
> >> supplied or figure it out. With that role a lookup against the container
> >> is
> >> executed. The MavenProject is not something that is available from the
> >> container because it is not a component. So I doubt it works, unless some
> >> magic was done to just make the @Component act on MavenProject's which
> >> itself doesn't make sense. It is meant to be a parameter, and that's what
> >> it has always been.
> >> 
> >> On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:
> >>> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
> >>>> The MavenProject is not a component that is injected by the container.
> >>>> It's handled by the PluginParameterExpressionEvaluator[1] which looks
> >>>> at
> >>>> all the non-@component things and sets their values once the Mojo
> >>>> instance is constructed.
> >>>> 
> >>>> [1]:
> >>>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/o
> >>>> r
> >>>> g/apache/maven/plugin/PluginParameterExpressionEvaluator.java>
> >>> 
> >>> Does that mean our docs are wrong?
> >>> Do you have an example?
> >>> 
> >>> I've not used annotations before and I was trying to help someone
> >>> else's user list question.
> >>> And unfortunately google returns javadoc matches as well so wading
> >>> through examples was time consuming and not very enlightening.
> >>> 
> >>> And the link Olivier sent is using
> >>> 
> >>>   /**
> >>>   
> >>>* The Maven project.
> >>>*/
> >>>   
> >>>   @Component
> >>>   private MavenProject project;
> >>> 
> >>> and is working, but when I tried that it didn't.
> >>> 
> >>> I'm going to try looking at the pom to see if there are some incorrect
> >>> versions of dependencies might be causing an issue.
> >>> 
> >>> -
> >>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> >>> For additional commands, e-mail: users-h...@maven.apache.org
> >> 
> >> Thanks,
> >> 
> >> Jason
> >> 
> >> --
> >> Jason van Zyl
> >> Founder & CTO, Sonatype
> >> Founder,  Apache Maven
> >> http://twitter.com/jvanzyl
> >> -
> >> 
> >> To do two things at once is to do neither.
> >> 
> >> -- Publilius Syrus, Roman slave, first century B.C.
> > 
> > -
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Jason van Zyl
I would remove that from the doco. I assume the @Parameter method still works 
and just keep that method.

jvz

On 2012-11-28, at 6:57 PM, Hervé BOUTEMY  wrote:

> magic has been done:
> see http://maven.apache.org/plugin-tools/apidocs/src-
> html/org/apache/maven/tools/plugin/util/PluginUtils.html#line.40
> 
> Le mercredi 28 novembre 2012 18:54:11 Jason van Zyl a écrit :
>> Internally the way @component works is to take the role of component
>> supplied or figure it out. With that role a lookup against the container is
>> executed. The MavenProject is not something that is available from the
>> container because it is not a component. So I doubt it works, unless some
>> magic was done to just make the @Component act on MavenProject's which
>> itself doesn't make sense. It is meant to be a parameter, and that's what
>> it has always been.
>> On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:
>>> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
>>>> The MavenProject is not a component that is injected by the container.
>>>> It's handled by the PluginParameterExpressionEvaluator[1] which looks at
>>>> all the non-@component things and sets their values once the Mojo
>>>> instance is constructed.
>>>> 
>>>> [1]:
>>>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/or
>>>> g/apache/maven/plugin/PluginParameterExpressionEvaluator.java> 
>>> Does that mean our docs are wrong?
>>> Do you have an example?
>>> 
>>> I've not used annotations before and I was trying to help someone
>>> else's user list question.
>>> And unfortunately google returns javadoc matches as well so wading
>>> through examples was time consuming and not very enlightening.
>>> 
>>> And the link Olivier sent is using
>>> 
>>>   /**
>>> 
>>>* The Maven project.
>>>*/
>>> 
>>>   @Component
>>>   private MavenProject project;
>>> 
>>> and is working, but when I tried that it didn't.
>>> 
>>> I'm going to try looking at the pom to see if there are some incorrect
>>> versions of dependencies might be causing an issue.
>>> 
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
>>> For additional commands, e-mail: users-h...@maven.apache.org
>> 
>> Thanks,
>> 
>> Jason
>> 
>> --
>> Jason van Zyl
>> Founder & CTO, Sonatype
>> Founder,  Apache Maven
>> http://twitter.com/jvanzyl
>> -
>> 
>> To do two things at once is to do neither.
>> 
>> -- Publilius Syrus, Roman slave, first century B.C.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Jason van Zyl
That's not right, and confusing. It's not a component.

jvz

On 2012-11-28, at 6:57 PM, Hervé BOUTEMY  wrote:

> magic has been done:
> see http://maven.apache.org/plugin-tools/apidocs/src-
> html/org/apache/maven/tools/plugin/util/PluginUtils.html#line.40
> 
> Le mercredi 28 novembre 2012 18:54:11 Jason van Zyl a écrit :
>> Internally the way @component works is to take the role of component
>> supplied or figure it out. With that role a lookup against the container is
>> executed. The MavenProject is not something that is available from the
>> container because it is not a component. So I doubt it works, unless some
>> magic was done to just make the @Component act on MavenProject's which
>> itself doesn't make sense. It is meant to be a parameter, and that's what
>> it has always been.
>> On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:
>>> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
>>>> The MavenProject is not a component that is injected by the container.
>>>> It's handled by the PluginParameterExpressionEvaluator[1] which looks at
>>>> all the non-@component things and sets their values once the Mojo
>>>> instance is constructed.
>>>> 
>>>> [1]:
>>>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/or
>>>> g/apache/maven/plugin/PluginParameterExpressionEvaluator.java> 
>>> Does that mean our docs are wrong?
>>> Do you have an example?
>>> 
>>> I've not used annotations before and I was trying to help someone
>>> else's user list question.
>>> And unfortunately google returns javadoc matches as well so wading
>>> through examples was time consuming and not very enlightening.
>>> 
>>> And the link Olivier sent is using
>>> 
>>>   /**
>>> 
>>>* The Maven project.
>>>*/
>>> 
>>>   @Component
>>>   private MavenProject project;
>>> 
>>> and is working, but when I tried that it didn't.
>>> 
>>> I'm going to try looking at the pom to see if there are some incorrect
>>> versions of dependencies might be causing an issue.
>>> 
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
>>> For additional commands, e-mail: users-h...@maven.apache.org
>> 
>> Thanks,
>> 
>> Jason
>> 
>> --
>> Jason van Zyl
>> Founder & CTO, Sonatype
>> Founder,  Apache Maven
>> http://twitter.com/jvanzyl
>> -
>> 
>> To do two things at once is to do neither.
>> 
>> -- Publilius Syrus, Roman slave, first century B.C.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Hervé BOUTEMY
magic has been done:
see http://maven.apache.org/plugin-tools/apidocs/src-
html/org/apache/maven/tools/plugin/util/PluginUtils.html#line.40

Le mercredi 28 novembre 2012 18:54:11 Jason van Zyl a écrit :
> Internally the way @component works is to take the role of component
> supplied or figure it out. With that role a lookup against the container is
> executed. The MavenProject is not something that is available from the
> container because it is not a component. So I doubt it works, unless some
> magic was done to just make the @Component act on MavenProject's which
> itself doesn't make sense. It is meant to be a parameter, and that's what
> it has always been.
> On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:
> > On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
> >> The MavenProject is not a component that is injected by the container.
> >> It's handled by the PluginParameterExpressionEvaluator[1] which looks at
> >> all the non-@component things and sets their values once the Mojo
> >> instance is constructed.
> >> 
> >> [1]:
> >> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/or
> >> g/apache/maven/plugin/PluginParameterExpressionEvaluator.java> 
> > Does that mean our docs are wrong?
> > Do you have an example?
> > 
> > I've not used annotations before and I was trying to help someone
> > else's user list question.
> > And unfortunately google returns javadoc matches as well so wading
> > through examples was time consuming and not very enlightening.
> > 
> > And the link Olivier sent is using
> > 
> >/**
> >
> > * The Maven project.
> > */
> >
> >@Component
> >private MavenProject project;
> > 
> > and is working, but when I tried that it didn't.
> > 
> > I'm going to try looking at the pom to see if there are some incorrect
> > versions of dependencies might be causing an issue.
> > 
> > -
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> 
> Thanks,
> 
> Jason
> 
> --
> Jason van Zyl
> Founder & CTO, Sonatype
> Founder,  Apache Maven
> http://twitter.com/jvanzyl
> -
> 
> To do two things at once is to do neither.
> 
>  -- Publilius Syrus, Roman slave, first century B.C.

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Jason van Zyl
Internally the way @component works is to take the role of component supplied 
or figure it out. With that role a lookup against the container is executed. 
The MavenProject is not something that is available from the container because 
it is not a component. So I doubt it works, unless some magic was done to just 
make the @Component act on MavenProject's which itself doesn't make sense. It 
is meant to be a parameter, and that's what it has always been.

On Nov 28, 2012, at 6:03 PM, Barrie Treloar  wrote:

> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
>> The MavenProject is not a component that is injected by the container. It's 
>> handled by the PluginParameterExpressionEvaluator[1] which looks at all the 
>> non-@component things and sets their values once the Mojo instance is 
>> constructed.
>> 
>> [1]: 
>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
> 
> Does that mean our docs are wrong?
> Do you have an example?
> 
> I've not used annotations before and I was trying to help someone
> else's user list question.
> And unfortunately google returns javadoc matches as well so wading
> through examples was time consuming and not very enlightening.
> 
> And the link Olivier sent is using
>/**
> * The Maven project.
> */
>@Component
>private MavenProject project;
> and is working, but when I tried that it didn't.
> 
> I'm going to try looking at the pom to see if there are some incorrect
> versions of dependencies might be causing an issue.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 

Thanks,

Jason

--
Jason van Zyl
Founder & CTO, Sonatype
Founder,  Apache Maven
http://twitter.com/jvanzyl
-

To do two things at once is to do neither.
 
 -- Publilius Syrus, Roman slave, first century B.C.







Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Barrie Treloar
On Thu, Nov 29, 2012 at 10:14 AM, Olivier Lamy  wrote:
> then don't miss
>
>   
> org.apache.maven.plugins
> maven-plugin-plugin
> 3.2
> 
>   
>   true
> 
[del]

Which is clearly documented at
http://maven.apache.org/plugin-tools/maven-plugin-plugin/examples/using-annotations.html
:)

As I said, I've not used it before and didn't look too closely at the
configuration to compare it with the docs - my bad.

Thanks.

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Olivier Lamy
2012/11/29 Barrie Treloar :
> On Thu, Nov 29, 2012 at 9:37 AM, Olivier Lamy  wrote:
>> see 
>> http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
>> and 
>> http://maven.apache.org/plugin-tools/maven-plugin-plugin/examples/using-annotations.html
>
> I tried those with his example project I forked at
> https://bitbucket.org/baerrach/randoop-maven-plugin
> (Its a mercurial repo)
>
> You can see in my comments that @Component doesn't work, but javadoc does.
>
> I can't explain why...
maybe avoid to mix doclet and annotations

then don't miss

  
org.apache.maven.plugins
maven-plugin-plugin
3.2

  
  true


  
mojo-descriptor

  descriptor

  
  
  
help-goal

  helpmojo

  

  

and add an it test to ease help :-)
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>



--
Olivier Lamy
Talend: http://coders.talend.com
http://twitter.com/olamy | http://linkedin.com/in/olamy

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Barrie Treloar
On Thu, Nov 29, 2012 at 9:37 AM, Olivier Lamy  wrote:
> see 
> http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
> and 
> http://maven.apache.org/plugin-tools/maven-plugin-plugin/examples/using-annotations.html

I tried those with his example project I forked at
https://bitbucket.org/baerrach/randoop-maven-plugin
(Its a mercurial repo)

You can see in my comments that @Component doesn't work, but javadoc does.

I can't explain why...

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Olivier Lamy
see 
http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
and 
http://maven.apache.org/plugin-tools/maven-plugin-plugin/examples/using-annotations.html


2012/11/29 Barrie Treloar :
> On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
>> The MavenProject is not a component that is injected by the container. It's 
>> handled by the PluginParameterExpressionEvaluator[1] which looks at all the 
>> non-@component things and sets their values once the Mojo instance is 
>> constructed.
>>
>> [1]: 
>> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
>
> Does that mean our docs are wrong?
> Do you have an example?
>
> I've not used annotations before and I was trying to help someone
> else's user list question.
> And unfortunately google returns javadoc matches as well so wading
> through examples was time consuming and not very enlightening.
>
> And the link Olivier sent is using
> /**
>  * The Maven project.
>  */
> @Component
> private MavenProject project;
> and is working, but when I tried that it didn't.
>
> I'm going to try looking at the pom to see if there are some incorrect
> versions of dependencies might be causing an issue.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>



-- 
Olivier Lamy
Talend: http://coders.talend.com
http://twitter.com/olamy | http://linkedin.com/in/olamy

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Barrie Treloar
On Thu, Nov 29, 2012 at 8:49 AM, Jason van Zyl  wrote:
> The MavenProject is not a component that is injected by the container. It's 
> handled by the PluginParameterExpressionEvaluator[1] which looks at all the 
> non-@component things and sets their values once the Mojo instance is 
> constructed.
>
> [1]: 
> https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java

Does that mean our docs are wrong?
Do you have an example?

I've not used annotations before and I was trying to help someone
else's user list question.
And unfortunately google returns javadoc matches as well so wading
through examples was time consuming and not very enlightening.

And the link Olivier sent is using
/**
 * The Maven project.
 */
    @Component
private MavenProject project;
and is working, but when I tried that it didn't.

I'm going to try looking at the pom to see if there are some incorrect
versions of dependencies might be causing an issue.

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Jason van Zyl
The MavenProject is not a component that is injected by the container. It's 
handled by the PluginParameterExpressionEvaluator[1] which looks at all the 
non-@component things and sets their values once the Mojo instance is 
constructed.

[1]: 
https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java

On Nov 27, 2012, at 10:26 PM, Barrie Treloar  wrote:

> While trying to sort out
> http://maven.40175.n5.nabble.com/Retrieving-the-project-source-directories-from-MavenProject-td5733602.html
> 
> I was hacking his code and found that
> Java 1.5 @Component MavenProject returns null
> 
> But when I changed it to use JavaDoc @parameter
> expression="${project}" it works fine.
> 
> http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
> gives an example
>@Component
>private MavenProject project;
> 
> http://maven.apache.org/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Component.html
> says MavenProject can be accessed via @Component
> 
> I've not used the Java 1.5 annotations before.
> Does anyone know why this might be?
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 

Thanks,

Jason

--
Jason van Zyl
Founder & CTO, Sonatype
Founder,  Apache Maven
http://twitter.com/jvanzyl
-

happiness is like a butterfly: the more you chase it, the more it will
elude you, but if you turn your attention to other things, it will come
and sit softly on your shoulder ...

-- Thoreau 







Re: Retrieving the project source directories from MavenProject

2012-11-28 Thread Barrie Treloar
On Thu, Nov 29, 2012 at 3:32 AM, Javier Ortiz  wrote:
> It worked! Thanks a lot. Now trying to figure out how to make the unit test
> work...

Its more like an integration test than a unit test, as your mojo will
need a lot of structure that it just painful to Mock.

Have a look at the maven-it project to see how it is done.
There are about 3 different frameworks when I started this stuff and
one (I dont remember which) became the leader.

You may also want to look at using a mock repository so that it loads
things off disk (and writes your test version into this repo too)
instead of downloading things form the internet or polluting your
local cache.  I'm not sure how well this is documented.

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Olivier Lamy
2012/11/28 Barrie Treloar :
>>> I've not used the Java 1.5 annotations before.
>>> Does anyone know why this might be?
>> weird as it works for all our plugins :-)
>> How do you build that ? any sample ?
>
> Got one I can take a look at?

http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java

>
> Google isn't helpful because it picks up the javadoc ones too.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>



--
Olivier Lamy
Talend: http://coders.talend.com
http://twitter.com/olamy | http://linkedin.com/in/olamy

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



Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Barrie Treloar
>> I've not used the Java 1.5 annotations before.
>> Does anyone know why this might be?
> weird as it works for all our plugins :-)
> How do you build that ? any sample ?

Got one I can take a look at?

Google isn't helpful because it picks up the javadoc ones too.

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



Re: Retrieving the project source directories from MavenProject

2012-11-28 Thread Javier Ortiz
It worked! Thanks a lot. Now trying to figure out how to make the unit test
work...


On Tue, Nov 27, 2012 at 9:23 PM, Barrie Treloar  wrote:

> On Wed, Nov 28, 2012 at 9:08 AM, Javier Ortiz 
> wrote:
> > Added the link to the sources:
> > https://bitbucket.org/javydreamercsw/randoop-maven-plugin
> >
> > The link was added in Stackoverflow as well.
>
> Ok. I got it running.
>
> Updated Stackoverflow.
>
> Summary:
> Java 1.5 annotations @Parameter and @Component are not working.
> JavaDoc annotations are working fine.
>
> Will start another thread to ask why Java 1.5 annotations aren't
> working as they should.
>
> Example output below
>
> [INFO] --- randoop-maven-plugin:1.0-SNAPSHOT:generate-all-tests
> (default-cli) @ randoop-maven-plugin ---
> [INFO] Running Randoop Mojo on project: Randoop-Maven-Plugin Maven Mojo
> [INFO] Sources:
> [INFO] XXX\randoop-maven-plugin\src\main\java
> [INFO] Artifacts:
> [INFO] org.apache.maven:maven-plugin-api:jar:2.2.1:compile
> [INFO] org.apache.maven:maven-project:jar:2.2.1:compile
> [INFO] org.apache.maven:maven-settings:jar:2.2.1:compile
> [INFO] org.apache.maven:maven-profile:jar:2.2.1:compile
> [INFO] org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
> [INFO] org.apache.maven:maven-repository-metadata:jar:2.2.1:compile
> [INFO] org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile
> [INFO] backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
> [INFO] org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
> [INFO] org.codehaus.plexus:plexus-interpolation:jar:1.11:compile
> [INFO] org.codehaus.plexus:plexus-utils:jar:1.5.15:compile
> [INFO] org.apache.maven:maven-artifact:jar:2.2.1:compile
> [INFO]
> org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
> [INFO] classworlds:classworlds:jar:1.1-alpha-2:compile
> [INFO]
> org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.2:compile
> [INFO] org.apache.maven:maven-model:jar:2.2.1:compile
> [INFO] org.fuin:utils4j:jar:0.6.8:compile
> [INFO] Dependencies:
> [INFO] Dependency {groupId=org.apache.maven,
> artifactId=maven-plugin-api, version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.apache.maven, artifactId=maven-project,
> version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.apache.maven,
> artifactId=maven-settings, version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.apache.maven, artifactId=maven-profile,
> version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.apache.maven,
> artifactId=maven-artifact-manager, version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.apache.maven,
> artifactId=maven-repository-metadata, version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.apache.maven.wagon,
> artifactId=wagon-provider-api, version=1.0-beta-6, type=jar}
> [INFO] Dependency {groupId=backport-util-concurrent,
> artifactId=backport-util-concurrent, version=3.1, type=jar}
> [INFO] Dependency {groupId=org.apache.maven,
> artifactId=maven-plugin-registry, version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.codehaus.plexus,
> artifactId=plexus-interpolation, version=1.11, type=jar}
> [INFO] Dependency {groupId=org.codehaus.plexus,
> artifactId=plexus-utils, version=1.5.15, type=jar}
> [INFO] Dependency {groupId=org.apache.maven,
> artifactId=maven-artifact, version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.codehaus.plexus,
> artifactId=plexus-container-default, version=1.0-alpha-9-stable-1,
> type=jar}
> [INFO] Dependency {groupId=classworlds, artifactId=classworlds,
> version=1.1-alpha-2, type=jar}
> [INFO] Dependency {groupId=org.apache.maven.plugin-tools,
> artifactId=maven-plugin-annotations, version=3.2, type=jar}
> [INFO] Dependency {groupId=org.apache.maven, artifactId=maven-model,
> version=2.2.1, type=jar}
> [INFO] Dependency {groupId=org.fuin, artifactId=utils4j,
> version=0.6.8, type=jar}
> [INFO] Classpath:
> [INFO] XXX\randoop-maven-plugin\target\classes
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\maven-plugin-api\2.2.1\maven-plugin-api-2.2.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\maven-project\2.2.1\maven-project-2.2.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\maven-settings\2.2.1\maven-settings-2.2.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\maven-profile\2.2.1\maven-profile-2.2.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\maven-artifact-manager\2.2.1\maven-artifact-manager-2.2.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\maven-repository-metadata\2.2.1\maven-repository-metadata-2.2.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\wagon\wagon-provider-api\1.0-beta-6\wagon-provider-api-1.0-beta-6.jar
> [INFO]
> C:\Users\XXX\.m2\repository\backport-util-concurrent\backport-util-concurrent\3.1\backport-util-concurrent-3.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\apache\maven\maven-plugin-registry\2.2.1\maven-plugin-registry-2.2.1.jar
> [INFO]
> C:\Users\XXX\.m2\repository\org\codehaus\plexu

Re: Mojo Java 1.5 @Component MavenProject (returns null) vs JavaDoc @parameter expression="${project}" works

2012-11-28 Thread Olivier Lamy
2012/11/28 Barrie Treloar :
> While trying to sort out
> http://maven.40175.n5.nabble.com/Retrieving-the-project-source-directories-from-MavenProject-td5733602.html
>
> I was hacking his code and found that
> Java 1.5 @Component MavenProject returns null
>
> But when I changed it to use JavaDoc @parameter
> expression="${project}" it works fine.
>
> http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
> gives an example
> @Component
> private MavenProject project;
>
> http://maven.apache.org/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Component.html
> says MavenProject can be accessed via @Component
>
> I've not used the Java 1.5 annotations before.
> Does anyone know why this might be?
weird as it works for all our plugins :-)
How do you build that ? any sample ?
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>



--
Olivier Lamy
Talend: http://coders.talend.com
http://twitter.com/olamy | http://linkedin.com/in/olamy

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



Re: Retrieving the project source directories from MavenProject

2012-11-27 Thread Barrie Treloar
On Wed, Nov 28, 2012 at 9:08 AM, Javier Ortiz  wrote:
> Added the link to the sources:
> https://bitbucket.org/javydreamercsw/randoop-maven-plugin
>
> The link was added in Stackoverflow as well.

Ok. I got it running.

Updated Stackoverflow.

Summary:
Java 1.5 annotations @Parameter and @Component are not working.
JavaDoc annotations are working fine.

Will start another thread to ask why Java 1.5 annotations aren't
working as they should.

Example output below

[INFO] --- randoop-maven-plugin:1.0-SNAPSHOT:generate-all-tests
(default-cli) @ randoop-maven-plugin ---
[INFO] Running Randoop Mojo on project: Randoop-Maven-Plugin Maven Mojo
[INFO] Sources:
[INFO] XXX\randoop-maven-plugin\src\main\java
[INFO] Artifacts:
[INFO] org.apache.maven:maven-plugin-api:jar:2.2.1:compile
[INFO] org.apache.maven:maven-project:jar:2.2.1:compile
[INFO] org.apache.maven:maven-settings:jar:2.2.1:compile
[INFO] org.apache.maven:maven-profile:jar:2.2.1:compile
[INFO] org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
[INFO] org.apache.maven:maven-repository-metadata:jar:2.2.1:compile
[INFO] org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile
[INFO] backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[INFO] org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
[INFO] org.codehaus.plexus:plexus-interpolation:jar:1.11:compile
[INFO] org.codehaus.plexus:plexus-utils:jar:1.5.15:compile
[INFO] org.apache.maven:maven-artifact:jar:2.2.1:compile
[INFO] 
org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[INFO] classworlds:classworlds:jar:1.1-alpha-2:compile
[INFO] org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.2:compile
[INFO] org.apache.maven:maven-model:jar:2.2.1:compile
[INFO] org.fuin:utils4j:jar:0.6.8:compile
[INFO] Dependencies:
[INFO] Dependency {groupId=org.apache.maven,
artifactId=maven-plugin-api, version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.apache.maven, artifactId=maven-project,
version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.apache.maven,
artifactId=maven-settings, version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.apache.maven, artifactId=maven-profile,
version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.apache.maven,
artifactId=maven-artifact-manager, version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.apache.maven,
artifactId=maven-repository-metadata, version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.apache.maven.wagon,
artifactId=wagon-provider-api, version=1.0-beta-6, type=jar}
[INFO] Dependency {groupId=backport-util-concurrent,
artifactId=backport-util-concurrent, version=3.1, type=jar}
[INFO] Dependency {groupId=org.apache.maven,
artifactId=maven-plugin-registry, version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.codehaus.plexus,
artifactId=plexus-interpolation, version=1.11, type=jar}
[INFO] Dependency {groupId=org.codehaus.plexus,
artifactId=plexus-utils, version=1.5.15, type=jar}
[INFO] Dependency {groupId=org.apache.maven,
artifactId=maven-artifact, version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.codehaus.plexus,
artifactId=plexus-container-default, version=1.0-alpha-9-stable-1,
type=jar}
[INFO] Dependency {groupId=classworlds, artifactId=classworlds,
version=1.1-alpha-2, type=jar}
[INFO] Dependency {groupId=org.apache.maven.plugin-tools,
artifactId=maven-plugin-annotations, version=3.2, type=jar}
[INFO] Dependency {groupId=org.apache.maven, artifactId=maven-model,
version=2.2.1, type=jar}
[INFO] Dependency {groupId=org.fuin, artifactId=utils4j,
version=0.6.8, type=jar}
[INFO] Classpath:
[INFO] XXX\randoop-maven-plugin\target\classes
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-plugin-api\2.2.1\maven-plugin-api-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-project\2.2.1\maven-project-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-settings\2.2.1\maven-settings-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-profile\2.2.1\maven-profile-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-artifact-manager\2.2.1\maven-artifact-manager-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-repository-metadata\2.2.1\maven-repository-metadata-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\wagon\wagon-provider-api\1.0-beta-6\wagon-provider-api-1.0-beta-6.jar
[INFO] 
C:\Users\XXX\.m2\repository\backport-util-concurrent\backport-util-concurrent\3.1\backport-util-concurrent-3.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-plugin-registry\2.2.1\maven-plugin-registry-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\codehaus\plexus\plexus-interpolation\1.11\plexus-interpolation-1.11.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\codehaus\plexus\plexus-utils\1.5.15\plexus-utils-1.5.15.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\apache\maven\maven-artifact\2.2.1\maven-artifact-2.2.1.jar
[INFO] 
C:\Users\XXX\.m2\repository\org\codehaus\plexus\plexus-container-de

Re: Retrieving the project source directories from MavenProject

2012-11-27 Thread Javier Ortiz
Added the link to the sources:
https://bitbucket.org/javydreamercsw/randoop-maven-plugin

The link was added in Stackoverflow as well.


On Tue, Nov 27, 2012 at 4:14 PM, Barrie Treloar  wrote:

> On Wed, Nov 28, 2012 at 1:25 AM, Javier Ortiz 
> wrote:
> > I'll give it a try.
>
> If your plugin code is available somewhere posting a link to it might
> be helpful.
> Others may have to the time to look at it and who knows a tagged
> before/after might also help others who follow this email thread from
> a google search later.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


Re: Retrieving the project source directories from MavenProject

2012-11-27 Thread Barrie Treloar
On Wed, Nov 28, 2012 at 1:25 AM, Javier Ortiz  wrote:
> I'll give it a try.

If your plugin code is available somewhere posting a link to it might
be helpful.
Others may have to the time to look at it and who knows a tagged
before/after might also help others who follow this email thread from
a google search later.

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



Re: Retrieving the project source directories from MavenProject

2012-11-27 Thread Javier Ortiz
On Mon, Nov 26, 2012 at 5:53 PM, Barrie Treloar  wrote:

> On Tue, Nov 27, 2012 at 9:44 AM, Javier Ortiz 
> wrote:
> > I did go through all that documentation previous to posting the question
> > but in Stackoverflow and in the list. I replied to your answer and will
> do
> > here as well:
> >
> > I did read it and tried that as well, but the getCompileSourceRoots()
> > returns empty list. I was expecting the src/main/java at leaset but no
> > luck. I already took a look at the maven-compiler-plugin and the way they
> > do it but is equivalent to getting the MavenProject and calling
> > getCompileSourceRoots() but also gives an empty list. The project I'm
> > trying has one source file in the default src/main/java path.
>
> Is your mojo bound to a phase correctly?
>
Yes, it was bounded to process-sources and I tried to change it to
generate-resources as the eclipse plugin without any changes.

> Its been a while since I've gone hacking in this space.
>
> Have a look at
>
> https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
> in the buildDirectoryList():
> extractSourceDirs( mainDirectories,
> project.getCompileSourceRoots(), basedir, projectBaseDir, false, null
> );
>
> Why dont you check out the maven-eclipse-plugin project and
> * attach some debug output at the spots that are similar to where it
> doesn't work in your code and see if you can figure out what is not
> working.
> * morph it to a skeleton of what you are trying to do.
>
> That should give you enough to work out how to build your own mojo.
>

I'll give it a try.

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


Re: Retrieving the project source directories from MavenProject

2012-11-26 Thread Barrie Treloar
On Tue, Nov 27, 2012 at 9:44 AM, Javier Ortiz  wrote:
> I did go through all that documentation previous to posting the question
> but in Stackoverflow and in the list. I replied to your answer and will do
> here as well:
>
> I did read it and tried that as well, but the getCompileSourceRoots()
> returns empty list. I was expecting the src/main/java at leaset but no
> luck. I already took a look at the maven-compiler-plugin and the way they
> do it but is equivalent to getting the MavenProject and calling
> getCompileSourceRoots() but also gives an empty list. The project I'm
> trying has one source file in the default src/main/java path.

Is your mojo bound to a phase correctly?
Its been a while since I've gone hacking in this space.

Have a look at
https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
in the buildDirectoryList():
extractSourceDirs( mainDirectories,
project.getCompileSourceRoots(), basedir, projectBaseDir, false, null
);

Why dont you check out the maven-eclipse-plugin project and
* attach some debug output at the spots that are similar to where it
doesn't work in your code and see if you can figure out what is not
working.
* morph it to a skeleton of what you are trying to do.

That should give you enough to work out how to build your own mojo.

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



Re: Retrieving the project source directories from MavenProject

2012-11-26 Thread Javier Ortiz
I did go through all that documentation previous to posting the question
but in Stackoverflow and in the list. I replied to your answer and will do
here as well:

I did read it and tried that as well, but the getCompileSourceRoots()
returns empty list. I was expecting the src/main/java at leaset but no
luck. I already took a look at the maven-compiler-plugin and the way they
do it but is equivalent to getting the MavenProject and calling
getCompileSourceRoots() but also gives an empty list. The project I'm
trying has one source file in the default src/main/java path.


On Mon, Nov 26, 2012 at 4:54 PM, Barrie Treloar  wrote:

> On Tue, Nov 27, 2012 at 8:39 AM, Javier Ortiz 
> wrote:
> > I'm loading a Maven project as described
> > here<
> http://stackoverflow.com/questions/4381460/get-mavenproject-from-just-the-pom-xml-pom-parser
> >.
> > I'm trying to figure out how I can retrieve the source roots so I can
> > figure out the Java classes I have so my Mojo can use them.
> >
> > I tried a couple of the methods in there, like getResources or
> > getScriptSources without luck. Any idea?
> >
> > See the Stackoverflow question
> > here<
> http://stackoverflow.com/questions/13462107/mavenproject-get-the-available-classes-for-use-on-my-plugin
> >
>
> I've answered over at Stackoverflow and pasting it here also
>
> I recommend reading more docs and looking at plugins that do similar
> things for ideas on how to get things done.
>
> 
> Have you read the [plugin developers documentation][1]?
>
> That page will link to [Plugins Cookbook][2] which links to [Mojo
> Developer Cookbook][3] which has [The maven project, or the effective
> pom.][4] and gives you access to
> *org.apache.maven.project.MavenProject* object via
>
> /** @parameter default-value="${project}" */
> private org.apache.maven.project.MavenProject mavenProject;
>
> You can call *[getCompileSourceRoots()][5]* to get a list of the
> directories that will be used for compilation.
>
> You will also need to do more reading about how to setup
> inclusion/exclusions.  You can use other plugins as examples of how to
> do this, e.g. [maven-compiler-plugin][6]
>
>
>   [1]: http://maven.apache.org/plugin-developers/index.html
>   [2]: http://maven.apache.org/plugin-developers/cookbook/index.html
>   [3]: http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook
>   [4]:
> http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook#MojoDeveloperCookbook-Themavenprojectortheeffectivepom
>   [5]:
> http://maven.apache.org/ref/3.0.3/maven-core/apidocs/org/apache/maven/project/MavenProject.html
>   [6]:
> http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


Re: Retrieving the project source directories from MavenProject

2012-11-26 Thread Barrie Treloar
On Tue, Nov 27, 2012 at 8:39 AM, Javier Ortiz  wrote:
> I'm loading a Maven project as described
> here<http://stackoverflow.com/questions/4381460/get-mavenproject-from-just-the-pom-xml-pom-parser>.
> I'm trying to figure out how I can retrieve the source roots so I can
> figure out the Java classes I have so my Mojo can use them.
>
> I tried a couple of the methods in there, like getResources or
> getScriptSources without luck. Any idea?
>
> See the Stackoverflow question
> here<http://stackoverflow.com/questions/13462107/mavenproject-get-the-available-classes-for-use-on-my-plugin>

I've answered over at Stackoverflow and pasting it here also

I recommend reading more docs and looking at plugins that do similar
things for ideas on how to get things done.


Have you read the [plugin developers documentation][1]?

That page will link to [Plugins Cookbook][2] which links to [Mojo
Developer Cookbook][3] which has [The maven project, or the effective
pom.][4] and gives you access to
*org.apache.maven.project.MavenProject* object via

/** @parameter default-value="${project}" */
private org.apache.maven.project.MavenProject mavenProject;

You can call *[getCompileSourceRoots()][5]* to get a list of the
directories that will be used for compilation.

You will also need to do more reading about how to setup
inclusion/exclusions.  You can use other plugins as examples of how to
do this, e.g. [maven-compiler-plugin][6]


  [1]: http://maven.apache.org/plugin-developers/index.html
  [2]: http://maven.apache.org/plugin-developers/cookbook/index.html
  [3]: http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook
  [4]: 
http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook#MojoDeveloperCookbook-Themavenprojectortheeffectivepom
  [5]: 
http://maven.apache.org/ref/3.0.3/maven-core/apidocs/org/apache/maven/project/MavenProject.html
  [6]: http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html

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



Re: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-16 Thread Martin Eisengardt
>
>
>
> As I understood from Martin Eisengardt this has to with the fact that the
> PlexusContainer does not have maven related information since Maven 3.
>
> Right now I'm looking into the source code of Maven to see how plugins are
> executed.
>
>
>

Actually some plugins are aware of this. For example maven-site-plugin
generates other mojos to execute the reportings. And thus it should use
some other method to receive mojo objects. Something that is not the plexus
container.


RE: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-16 Thread Kinai User
Thank you all for your replies.

@mgainty
I tried to show you how things were set up on my part and send you only some
snippets of my configuration. Maybe this led to some confusion. Therefore I
will try to give some additional info to show how things are setup:

In the build-plugin part of our pom.xml we've specified a plugin that we
developed ourselves which is able to execute other plugins. We call it the
pluginutils-plugin and in the example is referred to as Plugin A. 
This is a normal maven plugin with one goal named executePlugin. Also the
plugin.xml is generated as supposed to.

This plugin has some executions attached to it and one of them is the
aspectJ-weaving-execution
This execution also has some other parameters like pomProperties and
pomPackagings. But the most important parameter is the list of executionId's
as defined like this:


   aspectJ-weaving


The executionId's that are defined here must match with executionId's as
defined in the build-pluginManagement-Part of our pom. In this part we've
specified several plugins (existing plugins like the aspectj-maven-plugin
but also plugins that we've developed ourselves).

Once the pluginutils-plugin is triggered it will use it's configuration and
verifies if the project/module that is build satisfies one of the properties
specified. So it will check whether the property doAspectJWeaving is set to
true for this project or whether this project is of type war/ejb or jar. If
this is the case it will then check the list with all plugins that are
configured and will try to find the executionId (in this case
aspectJ-weaving). If there's a match it will start the executeMojo on that
plugin.

In Maven2 all other plugins (in the example referred to as plugin B or
C/D/E/F etc) executed normally and all Maven related information (like
MavenProject and MavenSession) was injected correctly. However after
switching to Maven 3 builds failed because of missing required parameters
(or nullpointerexceptions if required annotation was not specified).

As I understood from Martin Eisengardt this has to with the fact that the
PlexusContainer does not have maven related information since Maven 3. 

Right now I'm looking into the source code of Maven to see how plugins are
executed.

Regards,
Richard




--
View this message in context: 
http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570p5717245.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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



Re: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-15 Thread Martin Eisengardt
I noticed this too. The main reason is the plexus container does not know
anything about the maven sessions. Maven sessions and other things are no
valid plexus components (in the meaning they do not prefer to be a
singleton).
However the current solution for me was to have some little wrapper that is
able to inject maven session on request. The magic happens in
org.apache.maven.plugin.PluginParameterExpressionEvaluator.

Whenever receiving an object from plexus that requires maven session and
others you should not try to receive it via @required/@Requirement
directly. Instead access the plexus container and use this expression
evaluator. It does everything that is normally injected to mojos  and their
requirements only.

See
https://github.com/php-maven/maven-php-plugin/blob/master/branches/2.0-SNAPSHOT/maven-php-core/src/main/java/org/phpmaven/core/ComponentFactory.java#L175
for an example.


Whatever you are doing there may be other solutions. Maven itself has some
utilities to receive a plugin in the correct way. The above scenario is
only related with scenarios you mix up with "the maven way" and "the plexus
way". And maybe I was totally wrong to write this utility :)


However if there is need it is possible to merge my configurationfactory
utility class to a more common maven project and push it to central.

On Wed, Aug 15, 2012 at 7:31 AM, Kinai User  wrote:

> Hi Martin,
>
> Plugin A has several executions defined with different configurations.
> Here's an example of such a configuration (from the -part):
>
>   
> aspectJ-weaving-execution
> compile
> 
>   executePlugin
> 
> 
>   
> aspectJ-weaving
>   
>   
> jar
> war
> ejb
>   
>   
> 
>   doAspectJWeaving
>   true
> 
>   
> 
>   
>
> Plugin A will check the current project to see whether it is of
> pomPackaging
> type jar/war or ejb or if the project contains the property
> doAspectJWeaving
> with the value true. If one of these conditions is met plugin A decides to
> execute the aspectJ-weaving.
>
> Here's the configuration for the pluginExecution = aspectJ-weaving from the
> -part:
> 
>
>   org.codehaus.mojo
>   aspectj-maven-plugin
>   1.4
>   
> 1.5
> true
> true
> false
> 
>   
> org.springframework
> spring-aspects
>   
> 
>   
>   
> 
>   *aspectJ-weaving*
>   
> compile
>   
> 
>   
> 
>
> However plugin B needs access to the MavenProject or MavenSession instance
> to retrieve some maven info but since these dependencies are not injected a
> NullPointerException (or if @required was defined a missing parameter) will
> be thrown.
>
> Beware that I used an example for Plugin B which is an existing plugin
> where
> we do not have the sources of. But this also holds for plugin that we
> created ourselves.
>
> Any help appreciated.
>
> Regards,
> Richard
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570p5717095.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


RE: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-14 Thread Kinai User
Hi Martin,

Plugin A has several executions defined with different configurations.
Here's an example of such a configuration (from the -part):

  
aspectJ-weaving-execution
compile

  executePlugin


  
aspectJ-weaving
  
  
jar
war
ejb
  
  

  doAspectJWeaving
  true

  

  

Plugin A will check the current project to see whether it is of pomPackaging
type jar/war or ejb or if the project contains the property doAspectJWeaving
with the value true. If one of these conditions is met plugin A decides to
execute the aspectJ-weaving.

Here's the configuration for the pluginExecution = aspectJ-weaving from the
-part:

  
  org.codehaus.mojo
  aspectj-maven-plugin
  1.4
  
1.5
true
true
false

  
org.springframework
spring-aspects
  
  
  
  

  *aspectJ-weaving*
  
compile
  

  


However plugin B needs access to the MavenProject or MavenSession instance
to retrieve some maven info but since these dependencies are not injected a
NullPointerException (or if @required was defined a missing parameter) will
be thrown.

Beware that I used an example for Plugin B which is an existing plugin where
we do not have the sources of. But this also holds for plugin that we
created ourselves.

Any help appreciated.

Regards,
Richard



--
View this message in context: 
http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570p5717095.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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



RE: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-14 Thread Martin Gainty

Richard

"I want plugin A to be executed always and plugin A to decide whether plugin B 
(defined in
pluginManagement) should be executed"what criteria are you using to trigger the 
execution of plugin B by plugin A?

Martin 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.


> Date: Tue, 14 Aug 2012 06:46:03 -0700
> From: ki...@live.nl
> To: users@maven.apache.org
> Subject: RE: MavenProject/MavenSession not injected when executing plugin 
> from a plugin
> 
> Some additional info on the last thread :
> 
> Plugin A is defined in the  part, plugin B is defined in the
> -part.
> 
> It appears that injection as specified in the configuration is not properly
> executed when the plugin is defined in the pluginManagement part (while this
> worked fine in Maven 2).
> 
> If I add plugin B to the -part dependency injection is
> executed fine however this way plugin B will be executed for every project
> by default. This is not the behaviour I want because I want plugin A to be
> executed always and plugin A to decide whether plugin B (defined in
> pluginManagement) should be executed.
> 
> Hope this additional info helps.
> 
> Regards,
> Richard
> 
> 
> 
> --
> View this message in context: 
> http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570p5717052.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
  

RE: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-14 Thread Kinai User
Some additional info on the last thread :

Plugin A is defined in the  part, plugin B is defined in the
-part.

It appears that injection as specified in the configuration is not properly
executed when the plugin is defined in the pluginManagement part (while this
worked fine in Maven 2).

If I add plugin B to the -part dependency injection is
executed fine however this way plugin B will be executed for every project
by default. This is not the behaviour I want because I want plugin A to be
executed always and plugin A to decide whether plugin B (defined in
pluginManagement) should be executed.

Hope this additional info helps.

Regards,
Richard



--
View this message in context: 
http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570p5717052.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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



RE: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-14 Thread Kinai User
Hi All,

Thank you for your response.

I think I need a little bit more help. Maybe you guys can be somewhat more
specific as to which classes I can use as an example.
I have downloaded the sources for both the maven-site-plugin and the
maven-executor-plugin but so far have not found an example of what I am
trying to do.

I am using the BuildPluginManager's executeMojo method for executing my own
plugin but I don't see a reference in the downloaded sources to this class.
Does this mean I should not use this way (=class) of executing my own plugin
and is there an other way to start other plugins ?
And if so can you point me to this class and/or method ?

As stated before the first plugin (plugin A) is called correctly by Maven
and both the MavenProject and MavenSession are injected correctly. However
when I execute plugin B using the BuildPluginManager.executeMojo method
injection for MavenProject and MavenSession fails in plugin B.

Thank you all in advance.

Richard



--
View this message in context: 
http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570p5717045.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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



RE: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-09 Thread Martin Gainty

to extend non-local plugins where the source is not available...Take a look at 
implementing maven-inherit-plugin 

http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin

HTH
Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.


> Date: Thu, 9 Aug 2012 12:29:44 +0200
> Subject: Re: MavenProject/MavenSession not injected when executing plugin 
> from a plugin
> From: ol...@apache.org
> To: users@maven.apache.org
> 
> Hi
> Have a look at how we solve that in the site plugin sources
> That will probably help you.
> 
> --
> Olivier
> Le 9 août 2012 09:29, "Kinai User"  a écrit :
> 
> > Hi there,
> >
> > I have developed a plugin which can execute other Maven plugins depending
> > on
> > certain properties available in a project.
> >
> > The process is like this:
> > 1. Maven build starts
> > 2. Plugin A is triggered which has several executions defined. Depending on
> > properties in the project on hand a execution is triggered
> > 3. Plugin B (or C, D etc) will be triggered.
> >
> > The problem is I do not have access to the MavenProject and MavenSession in
> > Plugin B (or C, D) because these are not injected resulting in
> > NullPointerExceptions. The BuildPluginManager however is correctly injected
> > (however not needed in this plugin but added it to test the mechanism).
> >
> > I'm using the same syntax in Plugin A and there both MavenProject and
> > MavenSession are injected.
> >
> > Some code examples:
> >
> > Plugin A executing other plugins:
> > 
> >   private void executePlugin ( Plugin plugin, String executionId, String
> > goal ) throws MojoExecutionException
> >{
> >  try
> >  {
> >List repositories =
> > session.getCurrentProject().getRemoteProjectRepositories();
> >
> >MojoDescriptor mojoDescriptor =
> > pluginManager.getMojoDescriptor(plugin, goal,  repositories,
> > session.getRepositorySession());
> >MojoExecution mojoExecution = new MojoExecution( mojoDescriptor,
> > executionId );
> >getLog().info( "Executing goal " + goal + " within execution " +
> > executionId + " for plugin " + plugin );
> >pluginManager.executeMojo(session , mojoExecution);
> >  }
> >  catch ( Exception e )
> > {
> > throw new MojoExecutionException( "Error executing plugin " +
> > plugin + " with execution id " +
> >executionId, e );
> > }
> > }
> >
> >
> > Plugin B
> > 
> > /**
> >  * Goal which updates the VersionIF.java with the current version.
> >  * @goal updateVersion
> >  * @phase process-sources
> >  *
> >  */
> >
> > public class VersionIFMojo extends AbstractMojo {
> >
> > /**
> >  * The Maven project.
> >  *
> >  * @parameter expression="${project}"
> >  */
> > private MavenProject project;
> >
> > /**
> >  * The Maven Session Object
> >  *
> >  * @parameter expression="${session}"
> >  * @readonly
> >  */
> > protected MavenSession session;
> >
> > /**
> >  * Plugin manager used to invoke plugin executions.
> >  *
> >  * @required
> >  * @component
> > */
> >  private BuildPluginManager pManager;
>

Re: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-09 Thread Hervé BOUTEMY
the most interesting code is probably in maven-reporting-executor 
http://maven.apache.org/shared/maven-reporting-exec/, which is used by m-site-
p

Regards,

Hervé

Le jeudi 9 août 2012 12:29:44 Olivier Lamy a écrit :
> Hi
> Have a look at how we solve that in the site plugin sources
> That will probably help you.
> 
> --
> Olivier
> 
> Le 9 août 2012 09:29, "Kinai User"  a écrit :
> > Hi there,
> > 
> > I have developed a plugin which can execute other Maven plugins depending
> > on
> > certain properties available in a project.
> > 
> > The process is like this:
> > 1. Maven build starts
> > 2. Plugin A is triggered which has several executions defined. Depending
> > on
> > properties in the project on hand a execution is triggered
> > 3. Plugin B (or C, D etc) will be triggered.
> > 
> > The problem is I do not have access to the MavenProject and MavenSession
> > in
> > Plugin B (or C, D) because these are not injected resulting in
> > NullPointerExceptions. The BuildPluginManager however is correctly
> > injected
> > (however not needed in this plugin but added it to test the mechanism).
> > 
> > I'm using the same syntax in Plugin A and there both MavenProject and
> > MavenSession are injected.
> > 
> > Some code examples:
> > 
> > Plugin A executing other plugins:
> > 
> > 
> >   private void executePlugin ( Plugin plugin, String executionId, String
> > 
> > goal ) throws MojoExecutionException
> > 
> >{
> >
> >  try
> >  {
> >  
> >List repositories =
> > 
> > session.getCurrentProject().getRemoteProjectRepositories();
> > 
> >MojoDescriptor mojoDescriptor =
> > 
> > pluginManager.getMojoDescriptor(plugin, goal,  repositories,
> > 
> > session.getRepositorySession());
> >
> >MojoExecution mojoExecution = new MojoExecution( mojoDescriptor,
> > 
> > executionId );
> > 
> >getLog().info( "Executing goal " + goal + " within execution " +
> > 
> > executionId + " for plugin " + plugin );
> > 
> >pluginManager.executeMojo(session , mojoExecution);
> >  
> >  }
> >  catch ( Exception e )
> >  
> > {
> > 
> > throw new MojoExecutionException( "Error executing plugin " +
> > 
> > plugin + " with execution id " +
> > 
> >executionId, e );
> > 
> > }
> > 
> > }
> > 
> > Plugin B
> > 
> > /**
> > 
> >  * Goal which updates the VersionIF.java with the current version.
> >  * @goal updateVersion
> >  * @phase process-sources
> >  *
> >  */
> > 
> > public class VersionIFMojo extends AbstractMojo {
> > 
> > /**
> > 
> >  * The Maven project.
> >  *
> >  * @parameter expression="${project}"
> >  */
> > 
> > private MavenProject project;
> > 
> > /**
> > 
> >  * The Maven Session Object
> >  *
> >  * @parameter expression="${session}"
> >  * @readonly
> >  */
> > 
> > protected MavenSession session;
> > 
> > /**
> > 
> >  * Plugin manager used to invoke plugin executions.
> >  *
> >  * @required
> >  * @component
> > 
> > */
> > 
> >  private BuildPluginManager pManager;
> >
> ><...>
> > 
> > All worked well when using Maven 2 but after migrating to Maven 3 builds
> > stopped working.
> > Can somebody help me resolving this issue?
> > 
> > Thank you
> > 
> > Kind regards,
> > Richad
> > 
> > 
> > 
> > --
> > View this message in context:
> > http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-wh
> > en-executing-plugin-from-a-plugin-tp5716570.html Sent from the Maven -
> > Users mailing list archive at Nabble.com.
> > 
> > -
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org

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



Re: MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-09 Thread Olivier Lamy
Hi
Have a look at how we solve that in the site plugin sources
That will probably help you.

--
Olivier
Le 9 août 2012 09:29, "Kinai User"  a écrit :

> Hi there,
>
> I have developed a plugin which can execute other Maven plugins depending
> on
> certain properties available in a project.
>
> The process is like this:
> 1. Maven build starts
> 2. Plugin A is triggered which has several executions defined. Depending on
> properties in the project on hand a execution is triggered
> 3. Plugin B (or C, D etc) will be triggered.
>
> The problem is I do not have access to the MavenProject and MavenSession in
> Plugin B (or C, D) because these are not injected resulting in
> NullPointerExceptions. The BuildPluginManager however is correctly injected
> (however not needed in this plugin but added it to test the mechanism).
>
> I'm using the same syntax in Plugin A and there both MavenProject and
> MavenSession are injected.
>
> Some code examples:
>
> Plugin A executing other plugins:
> 
>   private void executePlugin ( Plugin plugin, String executionId, String
> goal ) throws MojoExecutionException
>{
>  try
>  {
>List repositories =
> session.getCurrentProject().getRemoteProjectRepositories();
>
>MojoDescriptor mojoDescriptor =
> pluginManager.getMojoDescriptor(plugin, goal,  repositories,
> session.getRepositorySession());
>MojoExecution mojoExecution = new MojoExecution( mojoDescriptor,
> executionId );
>getLog().info( "Executing goal " + goal + " within execution " +
> executionId + " for plugin " + plugin );
>pluginManager.executeMojo(session , mojoExecution);
>  }
>  catch ( Exception e )
> {
> throw new MojoExecutionException( "Error executing plugin " +
> plugin + " with execution id " +
>executionId, e );
> }
> }
>
>
> Plugin B
> 
> /**
>  * Goal which updates the VersionIF.java with the current version.
>  * @goal updateVersion
>  * @phase process-sources
>  *
>  */
>
> public class VersionIFMojo extends AbstractMojo {
>
> /**
>  * The Maven project.
>  *
>  * @parameter expression="${project}"
>  */
> private MavenProject project;
>
> /**
>  * The Maven Session Object
>  *
>  * @parameter expression="${session}"
>  * @readonly
>  */
> protected MavenSession session;
>
> /**
>  * Plugin manager used to invoke plugin executions.
>  *
>  * @required
>  * @component
> */
>  private BuildPluginManager pManager;
>
><...>
>
> All worked well when using Maven 2 but after migrating to Maven 3 builds
> stopped working.
> Can somebody help me resolving this issue?
>
> Thank you
>
> Kind regards,
> Richad
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


MavenProject/MavenSession not injected when executing plugin from a plugin

2012-08-09 Thread Kinai User
Hi there,

I have developed a plugin which can execute other Maven plugins depending on
certain properties available in a project.

The process is like this:
1. Maven build starts
2. Plugin A is triggered which has several executions defined. Depending on
properties in the project on hand a execution is triggered
3. Plugin B (or C, D etc) will be triggered.

The problem is I do not have access to the MavenProject and MavenSession in
Plugin B (or C, D) because these are not injected resulting in
NullPointerExceptions. The BuildPluginManager however is correctly injected
(however not needed in this plugin but added it to test the mechanism).

I'm using the same syntax in Plugin A and there both MavenProject and
MavenSession are injected.

Some code examples:

Plugin A executing other plugins:

  private void executePlugin ( Plugin plugin, String executionId, String
goal ) throws MojoExecutionException
   {
 try
 {
   List repositories =
session.getCurrentProject().getRemoteProjectRepositories();
   
   MojoDescriptor mojoDescriptor = 
pluginManager.getMojoDescriptor(plugin, goal,  repositories,   
session.getRepositorySession());
   MojoExecution mojoExecution = new MojoExecution( mojoDescriptor,
executionId );
   getLog().info( "Executing goal " + goal + " within execution " +
executionId + " for plugin " + plugin );
   pluginManager.executeMojo(session , mojoExecution);
 }
 catch ( Exception e )
{
throw new MojoExecutionException( "Error executing plugin " +
plugin + " with execution id " +  
   executionId, e );
}
}


Plugin B

/**
 * Goal which updates the VersionIF.java with the current version.
 * @goal updateVersion
 * @phase process-sources
 * 
 */

public class VersionIFMojo extends AbstractMojo {

/**
 * The Maven project.
 * 
 * @parameter expression="${project}"
 */
private MavenProject project;

/**
 * The Maven Session Object
 * 
 * @parameter expression="${session}"
 * @readonly
 */
protected MavenSession session;

/**
 * Plugin manager used to invoke plugin executions.
 * 
 * @required
 * @component
*/
 private BuildPluginManager pManager;

   <...>

All worked well when using Maven 2 but after migrating to Maven 3 builds
stopped working.
Can somebody help me resolving this issue?

Thank you

Kind regards,
Richad



--
View this message in context: 
http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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



Access MavenProject from a Doxia Macro

2012-03-08 Thread Gerhard Wipplinger
Hi everyone,

we would like to access some metadata of the MavenProject from our Doxia
Macros, e.g. groupId, baseDir, source-dirs, ...
Is there a way to inject the current MavenProject to a Doxia Macro?

Thanks in advance!
Kind regards,
Gerhard


Re: Programmatically instantiating a pom.xml as a MavenProject

2011-06-26 Thread Asmann, Roland
That won't work for me, I don't want to run the whole build.

I just want to have an instantiated MavenProject and call methods on it, 
not run the build.


On 26-06-11 16:45, Ansgar Konermann wrote:
> Am 26.06.2011 16:07, schrieb Asmann, Roland:
>> I am trying to read a pom.xml and instantiate it as a MavenProject for
>> testing.
>
> You also might want to have a look at
>
> http://maven.apache.org/shared/maven-invoker/
>
> http://maven.apache.org/plugins/maven-invoker-plugin/
>
> http://maven.apache.org/ref/3.0.3/maven-embedder/
>
> I use maven invoker plugin to instantiate poms for testing purposes, and
> it works great. Depending on your needs, maven-invoker and
> maven-embedder might be better for your case.
>
> AFAIK, the approach you currently follow using Xpp3Reader will give you
> a static XML-like model of the pom's xml text (think JAXB or JDOM), but
> this is far from a fully initialized maven project.
>
> Best regards
>
> Ansgar
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>

-- 
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock  T +43 1 2198790-27
Floridsdorfer Hauptstr. 1   F +43 1 2198790-927
A-1210 Wien M +43 664 88657566
E roland.asm...@adesso.at
W www.adesso.at

-
 >>> business. people. technology. <<<
-
-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: Programmatically instantiating a pom.xml as a MavenProject

2011-06-26 Thread Ansgar Konermann
Am 26.06.2011 16:07, schrieb Asmann, Roland:
> I am trying to read a pom.xml and instantiate it as a MavenProject for 
> testing.

You also might want to have a look at

http://maven.apache.org/shared/maven-invoker/

http://maven.apache.org/plugins/maven-invoker-plugin/

http://maven.apache.org/ref/3.0.3/maven-embedder/

I use maven invoker plugin to instantiate poms for testing purposes, and
it works great. Depending on your needs, maven-invoker and
maven-embedder might be better for your case.

AFAIK, the approach you currently follow using Xpp3Reader will give you
a static XML-like model of the pom's xml text (think JAXB or JDOM), but
this is far from a fully initialized maven project.

Best regards

Ansgar

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



Programmatically instantiating a pom.xml as a MavenProject

2011-06-26 Thread Asmann, Roland
Hi all,

I am trying to read a pom.xml and instantiate it as a MavenProject for 
testing. I am able to read it using the Xpp3Reader and then I gave the 
Model to a MavenProject.

The problem now, is that most of my attributes are not set. The most 
important one for me (at the moment) is the parent, which for some 
reason is null in the MavenProject. It is correctly set in the Model though.

Do I need to instantiate the MavenProject differently or tell it to 
resolve all attributes or something?

Current code is this:

MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(pomFile);
MavenProject project = new MavenProject(model);
return project.getParent();

Any help is appreciated!

Thanks,

-- 
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock  T +43 1 2198790-27
Floridsdorfer Hauptstr. 1   F +43 1 2198790-927
A-1210 Wien M +43 664 88657566
E roland.asm...@adesso.at
W www.adesso.at

-
 >>> business. people. technology. <<<
-
-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



get MavenProject reference from module path

2011-02-01 Thread Moser, Christian
I'm currently developing a custom enforcer rule.

 

How can I get object references to all modules of a parent pom ?

 

final List modulesRelativePath = parentProject.getModules();

 

delivers only the relative path to the project pom. I need something
like :

 

final List subSystemProjects =
baseSysProject.getProjectsFromModules();

 

Is there any Helper class which could deliver a MavenProject reference
by relativePath?

 

 

Thanks Christian

 



get MavenProject reference from module path

2011-02-01 Thread Moser, Christian
I'm currently developing a maven enforcer rule.

 

How can I get object references to all modules of a parent pom ?

 

 



Create a MavenProject from an Artifact in Maven3

2010-10-21 Thread Pieter van der Meer
Hi,

Im building a plugin that requires the dependencies of other pom files to to
its work. I am able to retrieve all the ArtifactInfo objects (pom files)
that i require.
The next step in the process is to get all the dependencies that are defined
in the specified pom file. I cant' figure out on how to do this. Yes I need
a ProjectBuilder but no matter what i try i get either a null pointer from
the Maven API or dont have any dependencies in the MavenProject i just
created.

>From the 3.0 javadoc  it seems to me that a need the ProjectBuilder
(DefaultProjectBuilder component) but so far no good.

Any help or pointers are appreciated.

Pieter


RE: What does this warning mean: [WARNING] Attempting to build MavenProject instance for Artifact of type jar; constructing POM artifact instead

2008-05-19 Thread Seva Popov
For me they don't appear to be the same either. 
I am going to file a bug. 

Thanks.

 
-Original Message-
From: Dennis Lundberg [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 19, 2008 11:33 AM
To: Maven Users List
Subject: Re: What does this warning mean: [WARNING] Attempting to build
MavenProject instance for Artifact of type jar; constructing POM
artifact instead

They don't appear to be the same.

I'm using Maven 2.0.8, if that might matter.

Seva Popov wrote:
> Dennis, 
> 
> Thanks for reply.  The report you filed is for when you run 'mvn site'
> to generate the plugin management report.
> 
> However, we observe these warnings in the different contexts, namely,
> when we run 'mvn clean install' for our projects. So, I am trying to
> understand whether this is the same kind of problem and whether we can
> safely ignore it. 
> 
> Example 1:
> 
> 
> 
> [INFO] [assembly:attached {execution: assemble-cli}]
> 
> [INFO] Reading assembly descriptor:
> /home/marina/tva/packaging/packager/cli/src/main/assembly/cli.xml
> 
> [INFO] Processing DependencySet (output=lib)
> 
> [INFO] snapshot com.tvworks.tva.mac:mac-data-types:3.2.4-SNAPSHOT:
> checking for updates from tva.proxy
> 
> [INFO] snapshot com.tvworks.tva.mac:mac-optimizer-api:3.2.4-SNAPSHOT:
> checking for updates from tva.proxy
> 
> [WARNING] Attempting to build MavenProject instance for Artifact
> (com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of
type:
> jar; constructing POM artifact instead.
> 
> [WARNING] Attempting to build MavenProject instance for Artifact
> (com.tvworks.tva.common:tva-common-lang:3.3-20080513.211757-62) of
type:
> jar; constructing POM artifact instead.
> 
> [WARNING] Attempting to build MavenProject instance for Artifact
> (com.tvworks.tva.common:tva-common-logging:3.3-20080513.211757-62) of
> type: jar; constructing POM artifact instead.
> 
> [INFO] Building tar :
>
/home/marina/tva/packaging/packager/cli/target/packager-cli-3.3-SNAPSHOT
> .tar.gz
> 
> [INFO] Processing DependencySet (output=lib)
> 
> 
> Example 2:
> 
> [INFO] [enforcer:enforce {execution: enforce-versions}]
> [WARNING] Attempting to build MavenProject instance for Artifact
>
(com.tvworks.tva.maven.plugins:maven-license-plugin:3.3-20080508.052638-
> 16) of type: maven-plugin; constructing POM artifact instead.
> [INFO] snapshot com.tvworks.tva.maven:plugin-utils:3.3-SNAPSHOT:
> checking for updates from tva.ci
>  [INFO] [tva-license:license {execution: default}]
> [INFO] Skipping license:license as this project is not of type: 'jar',
> 'war', 'component', or 'bundle'
> [WARNING] Attempting to build MavenProject instance for Artifact
>
(com.tvworks.tva.maven.plugins:maven-msgchk-plugin:3.3-20080508.052741-8
> ) of type: maven-plugin; constructing POM artifact instead.
> [INFO] [tva-msgchk:check {execution: msgchk}]
> [INFO] Msgchk plugin is skipped for "pom" project.
> [WARNING] Attempting to build MavenProject instance for Artifact
> (com.tvworks.tva.maven.plugins:maven
> 
> Thanks,
> Seva
> 
> 
> -Original Message-
> Dennis Lundberg
> Sat, 17 May 2008 03:30:19 -0700
> 
> This message comes from the "Plugin Management" report in
> maven-project-info-reports-plugin 2.1-SNAPSHOT. 
> 
> This has been report in JIRA at
http://jira.codehaus.org/browse/MPIR-99
> 
> Seva Popov wrote:
> Hi,
> 
> We switched from Maven 2.0.7 to Maven 2.0.9 and started observing the
> following warnings for our projects that we could not understand:
> [WARNING] Attempting to build MavenProject instance for Artifact 
> (com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of
type:
> jar; constructing POM artifact instead.
> 
> Please, let me know.
> 
> Thanks,
> Seva
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
Dennis Lundberg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: What does this warning mean: [WARNING] Attempting to build MavenProject instance for Artifact of type jar; constructing POM artifact instead

2008-05-19 Thread Dennis Lundberg

They don't appear to be the same.

I'm using Maven 2.0.8, if that might matter.

Seva Popov wrote:
Dennis, 


Thanks for reply.  The report you filed is for when you run 'mvn site'
to generate the plugin management report.

However, we observe these warnings in the different contexts, namely,
when we run 'mvn clean install' for our projects. So, I am trying to
understand whether this is the same kind of problem and whether we can
safely ignore it. 


Example 1:



[INFO] [assembly:attached {execution: assemble-cli}]

[INFO] Reading assembly descriptor:
/home/marina/tva/packaging/packager/cli/src/main/assembly/cli.xml

[INFO] Processing DependencySet (output=lib)

[INFO] snapshot com.tvworks.tva.mac:mac-data-types:3.2.4-SNAPSHOT:
checking for updates from tva.proxy

[INFO] snapshot com.tvworks.tva.mac:mac-optimizer-api:3.2.4-SNAPSHOT:
checking for updates from tva.proxy

[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of type:
jar; constructing POM artifact instead.

[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.common:tva-common-lang:3.3-20080513.211757-62) of type:
jar; constructing POM artifact instead.

[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.common:tva-common-logging:3.3-20080513.211757-62) of
type: jar; constructing POM artifact instead.

[INFO] Building tar :
/home/marina/tva/packaging/packager/cli/target/packager-cli-3.3-SNAPSHOT
.tar.gz

[INFO] Processing DependencySet (output=lib)


Example 2:

[INFO] [enforcer:enforce {execution: enforce-versions}]
[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.maven.plugins:maven-license-plugin:3.3-20080508.052638-
16) of type: maven-plugin; constructing POM artifact instead.
[INFO] snapshot com.tvworks.tva.maven:plugin-utils:3.3-SNAPSHOT:
checking for updates from tva.ci
 [INFO] [tva-license:license {execution: default}]
[INFO] Skipping license:license as this project is not of type: 'jar',
'war', 'component', or 'bundle'
[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.maven.plugins:maven-msgchk-plugin:3.3-20080508.052741-8
) of type: maven-plugin; constructing POM artifact instead.
[INFO] [tva-msgchk:check {execution: msgchk}]
[INFO] Msgchk plugin is skipped for "pom" project.
[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.maven.plugins:maven

Thanks,
Seva


-Original Message-
Dennis Lundberg
Sat, 17 May 2008 03:30:19 -0700

This message comes from the "Plugin Management" report in
maven-project-info-reports-plugin 2.1-SNAPSHOT. 


This has been report in JIRA at http://jira.codehaus.org/browse/MPIR-99

Seva Popov wrote:
Hi,

We switched from Maven 2.0.7 to Maven 2.0.9 and started observing the
following warnings for our projects that we could not understand:
[WARNING] Attempting to build MavenProject instance for Artifact 
(com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of type:

jar; constructing POM artifact instead.

Please, let me know.

Thanks,
Seva

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Dennis Lundberg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: What does this warning mean: [WARNING] Attempting to build MavenProject instance for Artifact of type jar; constructing POM artifact instead

2008-05-19 Thread Seva Popov
Dennis, 

Thanks for reply.  The report you filed is for when you run 'mvn site'
to generate the plugin management report.

However, we observe these warnings in the different contexts, namely,
when we run 'mvn clean install' for our projects. So, I am trying to
understand whether this is the same kind of problem and whether we can
safely ignore it. 

Example 1:



[INFO] [assembly:attached {execution: assemble-cli}]

[INFO] Reading assembly descriptor:
/home/marina/tva/packaging/packager/cli/src/main/assembly/cli.xml

[INFO] Processing DependencySet (output=lib)

[INFO] snapshot com.tvworks.tva.mac:mac-data-types:3.2.4-SNAPSHOT:
checking for updates from tva.proxy

[INFO] snapshot com.tvworks.tva.mac:mac-optimizer-api:3.2.4-SNAPSHOT:
checking for updates from tva.proxy

[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of type:
jar; constructing POM artifact instead.

[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.common:tva-common-lang:3.3-20080513.211757-62) of type:
jar; constructing POM artifact instead.

[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.common:tva-common-logging:3.3-20080513.211757-62) of
type: jar; constructing POM artifact instead.

[INFO] Building tar :
/home/marina/tva/packaging/packager/cli/target/packager-cli-3.3-SNAPSHOT
.tar.gz

[INFO] Processing DependencySet (output=lib)


Example 2:

[INFO] [enforcer:enforce {execution: enforce-versions}]
[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.maven.plugins:maven-license-plugin:3.3-20080508.052638-
16) of type: maven-plugin; constructing POM artifact instead.
[INFO] snapshot com.tvworks.tva.maven:plugin-utils:3.3-SNAPSHOT:
checking for updates from tva.ci
 [INFO] [tva-license:license {execution: default}]
[INFO] Skipping license:license as this project is not of type: 'jar',
'war', 'component', or 'bundle'
[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.maven.plugins:maven-msgchk-plugin:3.3-20080508.052741-8
) of type: maven-plugin; constructing POM artifact instead.
[INFO] [tva-msgchk:check {execution: msgchk}]
[INFO] Msgchk plugin is skipped for "pom" project.
[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.maven.plugins:maven

Thanks,
Seva


-Original Message-
Dennis Lundberg
Sat, 17 May 2008 03:30:19 -0700

This message comes from the "Plugin Management" report in
maven-project-info-reports-plugin 2.1-SNAPSHOT. 

This has been report in JIRA at http://jira.codehaus.org/browse/MPIR-99

Seva Popov wrote:
Hi,

We switched from Maven 2.0.7 to Maven 2.0.9 and started observing the
following warnings for our projects that we could not understand:
[WARNING] Attempting to build MavenProject instance for Artifact 
(com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of type:
jar; constructing POM artifact instead.

Please, let me know.

Thanks,
Seva

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: What does this warning mean: [WARNING] Attempting to build MavenProject instance for Artifact of type jar; constructing POM artifact instead

2008-05-17 Thread Dennis Lundberg
This message comes from the "Plugin Management" report in 
maven-project-info-reports-plugin 2.1-SNAPSHOT.


This has been report in JIRA at http://jira.codehaus.org/browse/MPIR-99

Seva Popov wrote:

Hi,

We switched from Maven 2.0.7 to Maven 2.0.9 and started observing the
following warnings for our projects that we could not understand:
 
[WARNING] Attempting to build MavenProject instance for Artifact

(com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of type:
jar; constructing POM artifact instead.

Please, let me know.

Thanks,
Seva


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Dennis Lundberg

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



What does this warning mean: [WARNING] Attempting to build MavenProject instance for Artifact of type jar; constructing POM artifact instead

2008-05-16 Thread Seva Popov
Hi,

We switched from Maven 2.0.7 to Maven 2.0.9 and started observing the
following warnings for our projects that we could not understand:
 
[WARNING] Attempting to build MavenProject instance for Artifact
(com.tvworks.tva.common:tva-common-util:3.3-20080513.211757-64) of type:
jar; constructing POM artifact instead.

Please, let me know.

Thanks,
Seva


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



hacky code in class MavenProject causing problems in multi-module build

2008-05-15 Thread torsten . reinhard
Hi, 

I have the following module-tree:

src\gide-parent
src\parent\ui-parent

src\common\ui
\services
src\gdcams\ui
\services
src\kvkams\ui
\services

In parent/ui-parent I have these modules:



../../common/gide-tools
../../common/ui/gide-common-ui-generator
 

../../common/services
../../gdcams/services
../../kvkams/services


../../common/ui
../../gdcams/ui
../../kvkams/ui
../../kvkams/ui/build-kvkams-ui-war


When executing a goal of a maven-plugin, I get the following stack:

Thread [main] (Suspended (breakpoint at line 337 in MavenProject)) 
MavenProject.getModulePathAdjustment(MavenProject) line: 337 
DefaultMavenProjectBuilder.buildInternal(String, Model, 
ProjectBuilderConfiguration, List, File, boolean) line: 844 
DefaultMavenProjectBuilder.buildFromSourceFileInternal(File, 
ProjectBuilderConfiguration, boolean) line: 506 
DefaultMavenProjectBuilder.build(File, 
ProjectBuilderConfiguration) line: 198 
DefaultMaven.getProject(File, MavenExecutionRequest) line: 583 
DefaultMaven.collectProjects(List, MavenExecutionRequest, boolean) 
line: 461 
DefaultMaven.getProjects(MavenExecutionRequest) line: 365 
DefaultMaven.doExecute(MavenExecutionRequest, EventDispatcher) 
line: 292 
DefaultMaven.execute(MavenExecutionRequest) line: 129 
MavenCli.main(String[], ClassWorld) line: 287 
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: 
not available [native method] 
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 
Method.invoke(Object, Object...) line: 585 
Launcher.launchEnhanced(String[]) line: 315 
Launcher.launch(String[]) line: 255 
Launcher.mainWithExitCode(String[]) line: 430 
Launcher.main(String[]) line: 375 

while iterating over all modules, the moduleAdjustments HashMap gets 
corrupted, because the moduleName is extracted as substring from the 
"modulePath".
So in my case, the moduleName "services" is added three times to the 
HashMap, overriding the last entry and adjustment !

...
moduleAdjustments.put( moduleName, adjustment );
...


I know that the root cause of the problem is the naming of my directories 
- they don´t match the artifactId in each case.
But maybe there´s a workaround or fix, that prevents me from renaming my 
whole directory structure?

Thanx, Torsten

P.S.: Should I file a bug for that issue ?




Re: [Unit Testing] Create MavenProject from a File

2007-12-04 Thread nicolas de loof
AFAIK the best way is to use MavenProjectBuilder.build( file,
localRepository, null );

I'm not sure if null can be passed for localrepository. It is required to
resolve project inheritence, so MAY be ignored.

Nico.


2007/12/4, Saloucious <[EMAIL PROTECTED]>:
>
>
> Hi,
>
> I would like to know which is the best way to build a MavenProject
> instance
> from a File.
>
> I do not want to use lookupMojo because i don't want to load my mojo but
> just unit testing an Util Class.
> --
> View this message in context:
> http://www.nabble.com/-Unit-Testing--Create-MavenProject-from-a-File-tf4944127s177.html#a14154043
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


[Unit Testing] Create MavenProject from a File

2007-12-04 Thread Saloucious

Hi, 

I would like to know which is the best way to build a MavenProject instance
from a File.

I do not want to use lookupMojo because i don't want to load my mojo but
just unit testing an Util Class.
-- 
View this message in context: 
http://www.nabble.com/-Unit-Testing--Create-MavenProject-from-a-File-tf4944127s177.html#a14154043
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: access to MavenProject help

2007-10-02 Thread Mark Russell
I got that code directly from the Mojo Developer Cookbook wiki page 
(http://docs/codehaus.org/MAVENUSER/Mojo+Developer+Cookbook).  It was wrong on the page so I went in and fixed the page.  It now 
contains the correct code.


 Hervé BOUTEMY wrote:

I see 1 typo that would explain the problem: parameter instead of @parameter

regards,

Hervé





--
Mark Russell
Instantiations, Inc.
724-368-3331 (land line)
http://www.instantiations.com



smime.p7s
Description: S/MIME Cryptographic Signature


Re: access to MavenProject help

2007-10-02 Thread Mark Russell

Thanks for the help.  I must have been working on that too long to see the 
error.

Many thanks for pointing that out to me that worked

Hervé BOUTEMY wrote:

I see 1 typo that would explain the problem: parameter instead of @parameter

regards,

Hervé

Le mardi 2 octobre 2007, Mark Russell a écrit :

I am trying to develop a plugin and get access to the MavenProject.  Here
is my code: /**
  *  parameter expression="${project}"
  */
     private MavenProject mavenProject;

. . .
     if (mavenProject != null) {
 List repositories = mavenProject.getRepositories();
 for (Object object : repositories) {
 getLog().info(object.getClass().getName());
 }
 }
 else {
 getLog().info("no project");
 }

All I ever get printed out is the no project message.  I also tried with
artifact repository and get the same results.  Here is my dependencies in
my pom:

   
  org.apache.maven
  maven-plugin-api
  2.0
   
   
  org.apache.maven
  maven-project
  2.0
   
   
  org.apache.maven
  maven-artifact
  2.0
   


I would like any help on this that I could get.  I need to get this code up
and running I have several people waiting for this. I have read the book
"Better Builds with Maven" and the MOJO Developer's handbook and  can not
seem to get this working.

thanks for your help in advance!




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Mark Russell
Instantiations, Inc.
724-368-3331 (land line)
http://www.instantiations.com



smime.p7s
Description: S/MIME Cryptographic Signature


Re: access to MavenProject help

2007-10-01 Thread Hervé BOUTEMY
I see 1 typo that would explain the problem: parameter instead of @parameter

regards,

Hervé

Le mardi 2 octobre 2007, Mark Russell a écrit :
> I am trying to develop a plugin and get access to the MavenProject.  Here
> is my code: /**
>   *  parameter expression="${project}"
>   */
>  private MavenProject mavenProject;
>
> . . .
>  if (mavenProject != null) {
>  List repositories = mavenProject.getRepositories();
>  for (Object object : repositories) {
>  getLog().info(object.getClass().getName());
>  }
>  }
>  else {
>  getLog().info("no project");
>  }
>
> All I ever get printed out is the no project message.  I also tried with
> artifact repository and get the same results.  Here is my dependencies in
> my pom:
> 
>
>   org.apache.maven
>   maven-plugin-api
>   2.0
>
>
>   org.apache.maven
>   maven-project
>   2.0
>
>
>   org.apache.maven
>   maven-artifact
>   2.0
>
> 
>
> I would like any help on this that I could get.  I need to get this code up
> and running I have several people waiting for this. I have read the book
> "Better Builds with Maven" and the MOJO Developer's handbook and  can not
> seem to get this working.
>
> thanks for your help in advance!



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



access to MavenProject help

2007-10-01 Thread Mark Russell

I am trying to develop a plugin and get access to the MavenProject.  Here is my 
code:
/**
 *  parameter expression="${project}"
 */
    private MavenProject mavenProject;

. . .
    if (mavenProject != null) {
List repositories = mavenProject.getRepositories();
for (Object object : repositories) {
getLog().info(object.getClass().getName());
}
}
else {
getLog().info("no project");
}

All I ever get printed out is the no project message.  I also tried with artifact repository and get the same results.  Here is 
my dependencies in my pom:

   
  
 org.apache.maven
 maven-plugin-api
 2.0
  
  
 org.apache.maven
 maven-project
 2.0
  
  
 org.apache.maven
 maven-artifact
 2.0
  
   

I would like any help on this that I could get.  I need to get this code up and running I have several people waiting for this. 
 I have read the book "Better Builds with Maven" and the MOJO Developer's handbook and  can not seem to get this working.


thanks for your help in advance!

--
Mark Russell
Instantiations, Inc.
724-368-3331 (land line)
http://www.instantiations.com


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [MOJO] What s the dependency including MavenProject class ?

2007-06-14 Thread Alexandre Touret

Thanks

Alexandre


Napoleon Esmundo C. Ramirez a écrit :

Hello Alexandre,

To help you fiddle with it, MavenProject is located in
org.apache.maven:maven-project.  Just check out the latest release. :)

Cheers!
Nap

On 6/14/07, Maria Odea Ching <[EMAIL PROTECTED]> wrote:


That's already included in Maven core.. you can find it inside the uber
jar in your $M2_HOME/lib.

-Deng

Alexandre Touret wrote:
> Hello,
> I m currently programming a mojo plugin.
> I d like to use the MavenProject class as described in the book
> "Better builds with maven". I created the project with a simple plugin
> archetype generation.
> However, the class MavenProject is not present in the dependencies and
> I didn t figure out where is the package including this class.
>
> Could you give me the corresponding library ?
>
> Thanks in advance
>
> Regards,
> Alexandre
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [MOJO] What s the dependency including MavenProject class ?

2007-06-13 Thread Napoleon Esmundo C. Ramirez

Hello Alexandre,

To help you fiddle with it, MavenProject is located in
org.apache.maven:maven-project.  Just check out the latest release. :)

Cheers!
Nap

On 6/14/07, Maria Odea Ching <[EMAIL PROTECTED]> wrote:


That's already included in Maven core.. you can find it inside the uber
jar in your $M2_HOME/lib.

-Deng

Alexandre Touret wrote:
> Hello,
> I m currently programming a mojo plugin.
> I d like to use the MavenProject class as described in the book
> "Better builds with maven". I created the project with a simple plugin
> archetype generation.
> However, the class MavenProject is not present in the dependencies and
> I didn t figure out where is the package including this class.
>
> Could you give me the corresponding library ?
>
> Thanks in advance
>
> Regards,
> Alexandre
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [MOJO] What s the dependency including MavenProject class ?

2007-06-13 Thread Maria Odea Ching
That's already included in Maven core.. you can find it inside the uber 
jar in your $M2_HOME/lib.


-Deng

Alexandre Touret wrote:

Hello,
I m currently programming a mojo plugin.
I d like to use the MavenProject class as described in the book 
"Better builds with maven". I created the project with a simple plugin 
archetype generation.
However, the class MavenProject is not present in the dependencies and 
I didn t figure out where is the package including this class.


Could you give me the corresponding library ?

Thanks in advance

Regards,
Alexandre



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[MOJO] What s the dependency including MavenProject class ?

2007-06-13 Thread Alexandre Touret

Hello,
I m currently programming a mojo plugin.
I d like to use the MavenProject class as described in the book "Better 
builds with maven". I created the project with a simple plugin archetype 
generation.
However, the class MavenProject is not present in the dependencies and I 
didn t figure out where is the package including this class.


Could you give me the corresponding library ?

Thanks in advance

Regards,
Alexandre



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Can I get MavenProject instance of plugin itself within a Mojo?

2007-02-13 Thread Janecek Jan
Hi,

Add this to your mojo:
/**
 * @parameter expression="${project}"
 * @readonly
 */
private MavenProject project;

See guides about plugin development in
http://maven.apache.org/guides/index.html

Regards,
Jan

-Original Message-
From: Jiaqi Guo [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 12, 2007 11:22 PM
To: users@maven.apache.org
Subject: Can I get MavenProject instance of plugin itself within a Mojo?

I need some of the maven2 plugin's dependencies during execute() method
of a Mojo. In maven1 there's ${plugin.get...} that I can use in jelly
script, how can I do similar thing in maven2 Mojo class?  Thanks in
advance.

I've tryed printing out getPluginContext() but it seems to return empty
Map.


Regards

-- 



Jiaqi Guo

http://www.cyclopsgroup.org
[EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



 
 
Tento e-mail je urcen pouze pro jeho adresata/adresaty a muze obsahovat duverne 
informace, jejichz ochrana muze byt vyzadovana pravnimi predpisy.
Jestlize jste zpravu obdrzel(a) omylem, neprodlene informujte jejiho 
odesilatele a tuto zpravu, jeji prilohy a pripadne kopie ihned vymazte. 
Jakakoli forma uziti, zverejneni, reprodukce, kopirovani, distribuce a sireni 
teto zpravy je v takovem pripade zakazana.
Komercni banka, a.s., neodpovida za mozne skody zpusobene neuplnym prenosem, 
moznou modifikaci ci zpozdenim teto zpravy behem prenosu od odesilatele k 
adresatovi.


This e-mail transmission is intended solely for the ordinary user of the e-mail 
address to which it was addressed. It may contain legally privileged and/or 
confidential information. 
If you have received this e-mail in error or are not an intended recipient 
please inform the sender with-out delay and delete this e-mail, attachments and 
possible copies immediately. The unauthorised use, disclosure, distribution 
and/or copying of this e-mail or any information it contains is prohibited. 
Komercni banka, a. s., does not accept liability for any damage caused by 
incomplete transmission, possible modification or delay of this e-mail during 
the transmission from the sender to the recipient.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [m2] Can I get MavenProject instance of plugin itself within a Mojo?

2007-02-13 Thread franz see

Good day to you, Jiaqi,

See the "http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook";
section in [1].

Cheers,
Franz

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


Jiaqi Guo wrote:
> 
> I need some of the maven2 plugin's dependencies during execute() method 
> of a Mojo. In maven1 there's ${plugin.get...} that I can use in jelly 
> script, how can I do similar thing in maven2 Mojo class?  Thanks in
> advance.
> 
> I've tryed printing out getPluginContext() but it seems to return empty
> Map.
> 
> 
> Regards
> 
> -- 
> 
> 
> 
> Jiaqi Guo
> 
> http://www.cyclopsgroup.org
> [EMAIL PROTECTED]
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Can-I-get-MavenProject-instance-of-plugin-itself-within-a-Mojo--tf3217048s177.html#a8942573
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Can I get MavenProject instance of plugin itself within a Mojo?

2007-02-12 Thread Jiaqi Guo
I need some of the maven2 plugin's dependencies during execute() method 
of a Mojo. In maven1 there's ${plugin.get...} that I can use in jelly 
script, how can I do similar thing in maven2 Mojo class?  Thanks in advance.


I've tryed printing out getPluginContext() but it seems to return empty Map.


Regards

--



Jiaqi Guo

http://www.cyclopsgroup.org
[EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Creating MavenProject within plugin

2006-11-10 Thread franz see

Good day to you, Jonas,

The way I see it, you have 4 choices here:
1. Instantiate a MavenProject and set all properties you need from it.
2. Use MavenProjectStub (but this is for testing only as Maria has
indicated)
3. Do something like:

/**
 * The maven project.
 *
 * @parameter expression="${project}"
 * @readonly
 */
protected MavenProject project;

And this will get your current project

4. Do this

/**
 * Project builder
 *
 * @component
 */
protected MavenProjectBuilder mavenProjectBuilder;

And use mavenProjectBuilder to build a MavenProject.

Cheers, 
Franz


Maria Odea Ching wrote:
> 
> Hi Jonas,
> 
> There's a MavenProjectStub class available in the 
> maven-plugin-testing-harness if you're interested. But
> its basically used for plugin testing. I'm not sure if it would be 
> useful for you, but you can take a look at it here:
> http://svn.apache.org/repos/asf/maven/shared/trunk/maven-plugin-testing-harness
> 
> Hope this helps! :-)
> 
> Thanks,
> Deng
> 
> Jonas Olsson wrote:
> 
>>Hi!
>>
>>This could be a no-no, but can I create a MavenProject object from a POM
>>(other than the one executed) within my plugin?
>>I've traversed the JavaDocs, but there is no obvious way (all methods
>>require arguments I cannot provide, e.g. ProfileManager).
>>
>>/jonas
>>
>>Detta e-mail har blivit undersökt av http://www.virus112.se
>>
>>
>>-
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>  
>>
> 
> 
> -----
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Creating-MavenProject-within-plugin-tf2601500s177.html#a7275985
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Creating MavenProject within plugin

2006-11-09 Thread Maria Odea Ching

Hi Jonas,

There's a MavenProjectStub class available in the 
maven-plugin-testing-harness if you're interested. But
its basically used for plugin testing. I'm not sure if it would be 
useful for you, but you can take a look at it here:

http://svn.apache.org/repos/asf/maven/shared/trunk/maven-plugin-testing-harness

Hope this helps! :-)

Thanks,
Deng

Jonas Olsson wrote:


Hi!

This could be a no-no, but can I create a MavenProject object from a POM
(other than the one executed) within my plugin?
I've traversed the JavaDocs, but there is no obvious way (all methods
require arguments I cannot provide, e.g. ProfileManager).

/jonas

Detta e-mail har blivit undersökt av http://www.virus112.se


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Creating MavenProject within plugin

2006-11-09 Thread Jonas Olsson
Hi!

This could be a no-no, but can I create a MavenProject object from a POM
(other than the one executed) within my plugin?
I've traversed the JavaDocs, but there is no obvious way (all methods
require arguments I cannot provide, e.g. ProfileManager).

/jonas

Detta e-mail har blivit undersökt av http://www.virus112.se


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: MavenProject from pom.xml

2006-10-09 Thread Kristian Nordal

On 10/6/06, Morten Kristiansen <[EMAIL PROTECTED]> wrote:


How can I load a pom.xml file from the filesystem into a MavenProject
object?



http://maven.apache.org/guides/mini/guide-embedding-m2.html

--
Cheers,
Kristian


MavenProject from pom.xml

2006-10-09 Thread Morten Kristiansen
How can I load a pom.xml file from the filesystem into a MavenProject
object?

Morten

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: MavenProject from pom.xml

2006-10-08 Thread MortenK

It's not for plugin testing! I simply need to load the pom.xml in a plugin
I'm working on to be able to read configurations for  several maven projects
specified by user.

MortenK


franz see wrote:
> 
> 
> 
> MortenK wrote:
>> 
>> How can I load a pom.xml file from the filesystem into a MavenProject
>> object?
>> 
>> Morten
>> 
> 
> Good day to you, MortenK,
> 
> Is this for plugin testing? If it is, you may want to try and extend
> org.apache.maven.plugin.testing.AbstractMojoTestCase which has
> lookupMojo(...) for generating an instance of your mojo given a specified
> pom.xml :-)
> 
> Cheers,
> Franz
> 

-- 
View this message in context: 
http://www.nabble.com/MavenProject-from-pom.xml-tf2396491.html#a6712176
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: MavenProject from pom.xml

2006-10-08 Thread franz see



MortenK wrote:
> 
> How can I load a pom.xml file from the filesystem into a MavenProject
> object?
> 
> Morten
> 

Good day to you, MortenK,

Is this for plugin testing? If it is, you may want to try and extend
org.apache.maven.plugin.testing.AbstractMojoTestCase which has
lookupMojo(...) for generating an instance of your mojo given a specified
pom.xml :-)

Cheers,
Franz
-- 
View this message in context: 
http://www.nabble.com/MavenProject-from-pom.xml-tf2396491.html#a6710620
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



MavenProject from pom.xml

2006-10-06 Thread MortenK

How can I load a pom.xml file from the filesystem into a MavenProject
object?

Morten
-- 
View this message in context: 
http://www.nabble.com/MavenProject-from-pom.xml-tf2396491.html#a6682277
Sent from the Maven - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Maven Embedder without MavenProject

2006-09-30 Thread Henrique Prange

Hi list,

I want to execute mvn install:install-file inside of a maven plug-in. 
I'm trying to use MavenEmbedder, but it depends at least on one 
MavenProject to call execute() method.


I want to use install:install-file, but like this plug-in, I don't want 
to require a project to run my plug-in. Is it possible with maven 
embedder? How can I do that?


Thanks in advance,

Henrique
--

\o/ Henrique Prange, Moleque de Idéias Educação e Tecnologia Ltda
 |  Phone: 55-21-2710-0178 E-mail: [EMAIL PROTECTED]
/ \ http://www.moleque.com.br

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



MavenProject property added by MOJO not inherited?

2006-09-21 Thread Pete

1) I have a MOJO that adds property to the MavenProject, using :-

 project.getProperties().put("myNewProperty", value);

This mojo gets invoked during the parent pom's generate-resources

2) But I then find that child poms cannot see the property, even
though they have the above as a parent.

Are properties like this supposed to be inherited ?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: MavenProject

2005-12-16 Thread Srepfler Srgjan

Christopher Cobb wrote:


I see several plugin examples on the Maven site that use MavenProject.  When
I try to use it, however, I get the error:



package org.apache.maven.project does not exist



How do I give my plugin access to MavenProject??


 


What does this plugin do and where can it be found?
Srgjan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: MavenProject

2005-12-15 Thread David H. DeWolf

To have it injected into your MoJo, use:

/**
 * @parameter expression="${project}"
 * @required
 * @readonly
 */
protected MavenProject project;

Jochen Wiedmann wrote:

Christopher Cobb wrote:


How do I give my plugin access to MavenProject??




  org.apache.maven
  maven-project
  2.0


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: MavenProject

2005-12-15 Thread Jochen Wiedmann

Christopher Cobb wrote:


How do I give my plugin access to MavenProject??



  org.apache.maven
  maven-project
  2.0


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: MavenProject

2005-12-15 Thread dan tran
if you take a look at the pom file and parent pom, you will see


  org.apache.maven
  maven-project
  2.0


-D

On 12/15/05, Christopher Cobb <[EMAIL PROTECTED]> wrote:
>
> I see several plugin examples on the Maven site that use
> MavenProject.  When
> I try to use it, however, I get the error:
>
>
>
> package org.apache.maven.project does not exist
>
>
>
> How do I give my plugin access to MavenProject??
>
>
>
> cc
>
>
>
>
>
>
> -
> Attention:
> Any views expressed in this message are those of the individual sender,
> except where the message states otherwise and the sender is authorized
> to state them to be the views of any such entity. The information
> contained in this message and or attachments is intended only for the
> person or entity to which it is addressed and may contain confidential
> and/or privileged material.  If you received this in error, please
> contact the sender and delete the material from any system and destroy
> any copies.
>
>


MavenProject

2005-12-15 Thread Christopher Cobb
I see several plugin examples on the Maven site that use MavenProject.  When
I try to use it, however, I get the error:

 

package org.apache.maven.project does not exist

 

How do I give my plugin access to MavenProject??

 

cc

 




-
Attention:
Any views expressed in this message are those of the individual sender,
except where the message states otherwise and the sender is authorized
to state them to be the views of any such entity. The information
contained in this message and or attachments is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged material.  If you received this in error, please
contact the sender and delete the material from any system and destroy
any copies.