You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by g....@aurenz.de on 2018/04/13 13:01:39 UTC
Writing own plugin: The parameter annotation - does it work?
Hello everyone, :-)
I'm currently writing a Maven plug-in again. And I'm experiencing some
add odd behavior.
Maybe I should add first that I'm currently executing my Mojo using the
MojoRule within a JUnit test.
The parameters of my Mojo are annotated using the @Parameter annotation
of Maven.
That annotation has a property name() (from the Javadoc):
name of the bean property used to get/set the field: by default, field
name is used.
So I thought I can use that when the name of the property in the Mojo
and in the POM file differ.
Let's say I have a Mojo property "hdd", but I want to use
"hardDiskDrive" in the POM file.
But it seems that Maven doesn't care for that annotation as I get an
error:
org.codehaus.plexus.component.configurator.ComponentConfigurationExcepti
on: Cannot find 'hardDiskDrive' in class test.example.MyMojo
at
org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHel
per.java:252)
at
org.codehaus.plexus.component.configurator.converters.composite.ObjectWi
thFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:10
1)
at
org.codehaus.plexus.component.configurator.BasicComponentConfigurator.co
nfigureComponent(BasicComponentConfigurator.java:34)
at
org.codehaus.plexus.component.configurator.AbstractComponentConfigurator
.configureComponent(AbstractComponentConfigurator.java:44)
at
org.apache.maven.plugin.testing.AbstractMojoTestCase.lookupConfiguredMoj
o(AbstractMojoTestCase.java:484)
at
org.apache.maven.plugin.testing.MojoRule.lookupConfiguredMojo(MojoRule.j
ava:197)
[...]
Any ideas about that? Are annotations not evaluated by the classes used
by MojoRule?
I also realized that the property readonly() of the @Parameter
annotation is totally ignored in this scenerio.
Regards
Gerrit
AW: Writing own plugin: The parameter annotation - does it work?
Posted by g....@aurenz.de.
Hi Mark,
that sounds / looks promising. Thanks a lot. :)
Unfortunately I don't have time at the moment to test it (next task is already waiting), but surely will as soon as I will work on the plug-in again.
Regards
Gerrit
-----Ursprüngliche Nachricht-----
Von: Mark Raynsford [mailto:org.apache.maven.user@io7m.com]
Gesendet: Montag, 16. April 2018 11:21
An: Hohl, Gerrit
Cc: Maven Users List
Betreff: Re: Writing own plugin: The parameter annotation - does it work?
On 2018-04-16T09:26:08 +0200
<g....@aurenz.de> wrote:
>
> Until then proper Maven Plug-in testing is not possible using JUnit - especially not if it is in the IDE (Eclipse+M2E) and not during the Maven build.
>
I came to the same conclusion (at least with the plain testing
harness). I switched to takari-plugin-testing, which seems to have been
written at least in part as a reaction to the fact that nothing else
worked properly.
I have a very small project that can serve as an example of how to use
it:
https://github.com/io7m/minisite
Take a look at the com.io7m.minisite.tests module. Primarily the
MinSiteMojoTest class, and the takari plugin execution in the tests
module pom. I can attest that it does work from inside the IDE, but you
may need to run an initial build to run the plugin's testProperties
goal (Eclipse & M2E may be able to do this for you these days, I'm not
sure).
--
Mark Raynsford | http://www.io7m.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Writing own plugin: The parameter annotation - does it work?
Posted by Mark Raynsford <or...@io7m.com>.
On 2018-04-16T09:26:08 +0200
<g....@aurenz.de> wrote:
>
> Until then proper Maven Plug-in testing is not possible using JUnit - especially not if it is in the IDE (Eclipse+M2E) and not during the Maven build.
>
I came to the same conclusion (at least with the plain testing
harness). I switched to takari-plugin-testing, which seems to have been
written at least in part as a reaction to the fact that nothing else
worked properly.
I have a very small project that can serve as an example of how to use
it:
https://github.com/io7m/minisite
Take a look at the com.io7m.minisite.tests module. Primarily the
MinSiteMojoTest class, and the takari plugin execution in the tests
module pom. I can attest that it does work from inside the IDE, but you
may need to run an initial build to run the plugin's testProperties
goal (Eclipse & M2E may be able to do this for you these days, I'm not
sure).
--
Mark Raynsford | http://www.io7m.com
AW: Writing own plugin: The parameter annotation - does it work?
Posted by g....@aurenz.de.
Hi Martin,
thanks a lot. :)
I'll have a look at it.
Regards,
Gerrit
-----Ursprüngliche Nachricht-----
Von: Martin Hoeller [mailto:martin@xss.co.at]
Gesendet: Dienstag, 17. April 2018 11:19
An: users@maven.apache.org
Betreff: Re: Writing own plugin: The parameter annotation - does it work?
Hi Gerrit!
If you search for some examples have a look at
https://github.com/matinh/vdldoc-maven-plugin
I created this project some time ago as a proove of concept for myself
to write a simple maven plugin including integration testing. Use the
"run-its" profile to enable integration-tests and have a look at the
main pom.xml resp. the POMs of the ITs in src/it/*.
hth,
- martin
On Tue, 17 Apr 2018 09:25 wrote <rf...@apache.org>:
> With Maven Invoker you create Maven projects like your plugin-users
> do. And then Maven will be called to run this project. It is as close
> as possible to the real world .
> If you want to make unittests, maven-plugin-testing-harness should
> work, but it lacks good documentation.
> Downside of this is that you're testing it with 1 specific version
> of Maven. The takari plugin seems to be able to cover multiple Maven
> versions, but you won't be able to debug issues for a specific Maven
> version.
>
> thanks,
> Robert
>
> On Tue, 17 Apr 2018 09:16:51 +0200, <g....@aurenz.de> wrote:
>
> > Hi Robert,
> >
> > thanks a lot for your mail.
> > I create 2 issues about this.
> >
> > About that Maven Invoker Plugin:
> > Are there any examples how to use that in a JUnit test?
> >
> > Regards,
> > Gerrit
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Writing own plugin: The parameter annotation - does it work?
Posted by Martin Hoeller <ma...@xss.co.at>.
Hi Gerrit!
If you search for some examples have a look at
https://github.com/matinh/vdldoc-maven-plugin
I created this project some time ago as a proove of concept for myself
to write a simple maven plugin including integration testing. Use the
"run-its" profile to enable integration-tests and have a look at the
main pom.xml resp. the POMs of the ITs in src/it/*.
hth,
- martin
On Tue, 17 Apr 2018 09:25 wrote <rf...@apache.org>:
> With Maven Invoker you create Maven projects like your plugin-users
> do. And then Maven will be called to run this project. It is as close
> as possible to the real world .
> If you want to make unittests, maven-plugin-testing-harness should
> work, but it lacks good documentation.
> Downside of this is that you're testing it with 1 specific version
> of Maven. The takari plugin seems to be able to cover multiple Maven
> versions, but you won't be able to debug issues for a specific Maven
> version.
>
> thanks,
> Robert
>
> On Tue, 17 Apr 2018 09:16:51 +0200, <g....@aurenz.de> wrote:
>
> > Hi Robert,
> >
> > thanks a lot for your mail.
> > I create 2 issues about this.
> >
> > About that Maven Invoker Plugin:
> > Are there any examples how to use that in a JUnit test?
> >
> > Regards,
> > Gerrit
Re: AW: AW: Writing own plugin: The parameter annotation - does it
work?
Posted by Robert Scholte <rf...@apache.org>.
With Maven Invoker you create Maven projects like your plugin-users do.
And then Maven will be called to run this project. It is as close as
possible to the real world .
If you want to make unittests, maven-plugin-testing-harness should work,
but it lacks good documentation.
Downside of this is that you're testing it with 1 specific version of
Maven. The takari plugin seems to be able to cover multiple Maven
versions, but you won't be able to debug issues for a specific Maven
version.
thanks,
Robert
On Tue, 17 Apr 2018 09:16:51 +0200, <g....@aurenz.de> wrote:
> Hi Robert,
>
> thanks a lot for your mail.
> I create 2 issues about this.
>
> About that Maven Invoker Plugin:
> Are there any examples how to use that in a JUnit test?
>
> Regards,
> Gerrit
>
> -----Ursprüngliche Nachricht-----
> Von: Robert Scholte [mailto:rfscholte@apache.org]
> Gesendet: Montag, 16. April 2018 22:12
> An: Maven Users List
> Betreff: Re: AW: Writing own plugin: The parameter annotation - does it
> work?
>
> Hi,
>
> the docs are not up-to-date, all issues have been migrated to
> http://issues.apache.org/jira/browse/MPLUGINTESTING
> You are correct that there's not a lot of activity on this subproject,
> because most of our Maven Plugins use the Maven Invoker Plugin for
> testing. It's all a matter of priority.
>
> thanks,
> Robert
>
> On Mon, 16 Apr 2018 09:26:08 +0200, <g....@aurenz.de> wrote:
>
>> Hello everyone,
>>
>> after trying different approaches and seeing the efforts needed I give
>> up on this.
>> Especially as I realized that the maven-plugin-testing-harness latest
>> version 3.3.0 was realized at 2014-12-17.
>> I thought about opening an issue in the issue tracking system of the
>> project, just to realize that they had it at Codehaus, which closed its
>> doors some time ago.
>>
>> Hopefully someone of the "Maven Plugin Testing Mechanism" will read
>> this.
>>
>> Until then proper Maven Plug-in testing is not possible using JUnit -
>> especially not if it is in the IDE (Eclipse+M2E) and not during the
>> Maven build.
>>
>> Regards,
>> Gerrit
>>
>> -----Ursprüngliche Nachricht-----
>> Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
>> Gesendet: Freitag, 13. April 2018 15:53
>> An: users@maven.apache.org
>> Betreff: AW: Writing own plugin: The parameter annotation - does it
>> work?
>>
>> Hello everyone,
>>
>> after some analyzing I realized that the MojoRule is trying to read the
>> plug-in description.
>> This file is created during the build process by the maven-plugin-plugin
>> and is located:
>> target\classes\META-INF\maven\plugin.xml
>> If I only execute the test via JUnit in Eclipse that files - of course -
>> isn't created.
>> So I let the build run one time.
>> Now I have the information of the @Parameter annotation there.
>> And somehow I'm sure that annotation won't be touched at any other time
>> than when that maven-plugin-plugin is creating the plugin.xml...
>>
>> The file is now present and I also saw that MojoRule is reading it.
>> But it seems it isn't using it as the error is still there.
>>
>> Any ideas?
>>
>>
>> Regards,
>> Gerrit
>>
>> -----Ursprüngliche Nachricht-----
>> Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
>> Gesendet: Freitag, 13. April 2018 15:02
>> An: users@maven.apache.org
>> Betreff: Writing own plugin: The parameter annotation - does it work?
>>
>> Hello everyone, :-)
>>
>>
>> I'm currently writing a Maven plug-in again. And I'm experiencing some
>> add odd behavior.
>>
>> Maybe I should add first that I'm currently executing my Mojo using the
>> MojoRule within a JUnit test.
>>
>> The parameters of my Mojo are annotated using the @Parameter annotation
>> of Maven.
>>
>>
>> That annotation has a property name() (from the Javadoc):
>>
>>
>> name of the bean property used to get/set the field: by default, field
>> name is used.
>>
>>
>> So I thought I can use that when the name of the property in the Mojo
>> and in the POM file differ.
>>
>> Let's say I have a Mojo property "hdd", but I want to use
>> "hardDiskDrive" in the POM file.
>>
>> But it seems that Maven doesn't care for that annotation as I get an
>> error:
>>
>>
>> org.codehaus.plexus.component.configurator.ComponentConfigurationExcepti
>> on: Cannot find 'hardDiskDrive' in class test.example.MyMojo
>>
>> at
>> org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHel
>> per.java:252)
>>
>> at
>> org.codehaus.plexus.component.configurator.converters.composite.ObjectWi
>> thFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:10
>> 1)
>>
>> at
>> org.codehaus.plexus.component.configurator.BasicComponentConfigurator.co
>> nfigureComponent(BasicComponentConfigurator.java:34)
>>
>> at
>> org.codehaus.plexus.component.configurator.AbstractComponentConfigurator
>> .configureComponent(AbstractComponentConfigurator.java:44)
>>
>> at
>> org.apache.maven.plugin.testing.AbstractMojoTestCase.lookupConfiguredMoj
>> o(AbstractMojoTestCase.java:484)
>>
>> at
>> org.apache.maven.plugin.testing.MojoRule.lookupConfiguredMojo(MojoRule.j
>> ava:197)
>>
>> [...]
>>
>>
>> Any ideas about that? Are annotations not evaluated by the classes used
>> by MojoRule?
>>
>>
>> I also realized that the property readonly() of the @Parameter
>> annotation is totally ignored in this scenerio.
>>
>>
>> Regards
>>
>> Gerrit
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
AW: AW: Writing own plugin: The parameter annotation - does it work?
Posted by g....@aurenz.de.
Hi Robert,
thanks a lot for your mail.
I create 2 issues about this.
About that Maven Invoker Plugin:
Are there any examples how to use that in a JUnit test?
Regards,
Gerrit
-----Ursprüngliche Nachricht-----
Von: Robert Scholte [mailto:rfscholte@apache.org]
Gesendet: Montag, 16. April 2018 22:12
An: Maven Users List
Betreff: Re: AW: Writing own plugin: The parameter annotation - does it work?
Hi,
the docs are not up-to-date, all issues have been migrated to
http://issues.apache.org/jira/browse/MPLUGINTESTING
You are correct that there's not a lot of activity on this subproject,
because most of our Maven Plugins use the Maven Invoker Plugin for
testing. It's all a matter of priority.
thanks,
Robert
On Mon, 16 Apr 2018 09:26:08 +0200, <g....@aurenz.de> wrote:
> Hello everyone,
>
> after trying different approaches and seeing the efforts needed I give
> up on this.
> Especially as I realized that the maven-plugin-testing-harness latest
> version 3.3.0 was realized at 2014-12-17.
> I thought about opening an issue in the issue tracking system of the
> project, just to realize that they had it at Codehaus, which closed its
> doors some time ago.
>
> Hopefully someone of the "Maven Plugin Testing Mechanism" will read this.
>
> Until then proper Maven Plug-in testing is not possible using JUnit -
> especially not if it is in the IDE (Eclipse+M2E) and not during the
> Maven build.
>
> Regards,
> Gerrit
>
> -----Ursprüngliche Nachricht-----
> Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
> Gesendet: Freitag, 13. April 2018 15:53
> An: users@maven.apache.org
> Betreff: AW: Writing own plugin: The parameter annotation - does it work?
>
> Hello everyone,
>
> after some analyzing I realized that the MojoRule is trying to read the
> plug-in description.
> This file is created during the build process by the maven-plugin-plugin
> and is located:
> target\classes\META-INF\maven\plugin.xml
> If I only execute the test via JUnit in Eclipse that files - of course -
> isn't created.
> So I let the build run one time.
> Now I have the information of the @Parameter annotation there.
> And somehow I'm sure that annotation won't be touched at any other time
> than when that maven-plugin-plugin is creating the plugin.xml...
>
> The file is now present and I also saw that MojoRule is reading it.
> But it seems it isn't using it as the error is still there.
>
> Any ideas?
>
>
> Regards,
> Gerrit
>
> -----Ursprüngliche Nachricht-----
> Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
> Gesendet: Freitag, 13. April 2018 15:02
> An: users@maven.apache.org
> Betreff: Writing own plugin: The parameter annotation - does it work?
>
> Hello everyone, :-)
>
>
> I'm currently writing a Maven plug-in again. And I'm experiencing some
> add odd behavior.
>
> Maybe I should add first that I'm currently executing my Mojo using the
> MojoRule within a JUnit test.
>
> The parameters of my Mojo are annotated using the @Parameter annotation
> of Maven.
>
>
> That annotation has a property name() (from the Javadoc):
>
>
> name of the bean property used to get/set the field: by default, field
> name is used.
>
>
> So I thought I can use that when the name of the property in the Mojo
> and in the POM file differ.
>
> Let's say I have a Mojo property "hdd", but I want to use
> "hardDiskDrive" in the POM file.
>
> But it seems that Maven doesn't care for that annotation as I get an
> error:
>
>
> org.codehaus.plexus.component.configurator.ComponentConfigurationExcepti
> on: Cannot find 'hardDiskDrive' in class test.example.MyMojo
>
> at
> org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHel
> per.java:252)
>
> at
> org.codehaus.plexus.component.configurator.converters.composite.ObjectWi
> thFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:10
> 1)
>
> at
> org.codehaus.plexus.component.configurator.BasicComponentConfigurator.co
> nfigureComponent(BasicComponentConfigurator.java:34)
>
> at
> org.codehaus.plexus.component.configurator.AbstractComponentConfigurator
> .configureComponent(AbstractComponentConfigurator.java:44)
>
> at
> org.apache.maven.plugin.testing.AbstractMojoTestCase.lookupConfiguredMoj
> o(AbstractMojoTestCase.java:484)
>
> at
> org.apache.maven.plugin.testing.MojoRule.lookupConfiguredMojo(MojoRule.j
> ava:197)
>
> [...]
>
>
> Any ideas about that? Are annotations not evaluated by the classes used
> by MojoRule?
>
>
> I also realized that the property readonly() of the @Parameter
> annotation is totally ignored in this scenerio.
>
>
> Regards
>
> Gerrit
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: AW: Writing own plugin: The parameter annotation - does it work?
Posted by Robert Scholte <rf...@apache.org>.
Hi,
the docs are not up-to-date, all issues have been migrated to
http://issues.apache.org/jira/browse/MPLUGINTESTING
You are correct that there's not a lot of activity on this subproject,
because most of our Maven Plugins use the Maven Invoker Plugin for
testing. It's all a matter of priority.
thanks,
Robert
On Mon, 16 Apr 2018 09:26:08 +0200, <g....@aurenz.de> wrote:
> Hello everyone,
>
> after trying different approaches and seeing the efforts needed I give
> up on this.
> Especially as I realized that the maven-plugin-testing-harness latest
> version 3.3.0 was realized at 2014-12-17.
> I thought about opening an issue in the issue tracking system of the
> project, just to realize that they had it at Codehaus, which closed its
> doors some time ago.
>
> Hopefully someone of the "Maven Plugin Testing Mechanism" will read this.
>
> Until then proper Maven Plug-in testing is not possible using JUnit -
> especially not if it is in the IDE (Eclipse+M2E) and not during the
> Maven build.
>
> Regards,
> Gerrit
>
> -----Ursprüngliche Nachricht-----
> Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
> Gesendet: Freitag, 13. April 2018 15:53
> An: users@maven.apache.org
> Betreff: AW: Writing own plugin: The parameter annotation - does it work?
>
> Hello everyone,
>
> after some analyzing I realized that the MojoRule is trying to read the
> plug-in description.
> This file is created during the build process by the maven-plugin-plugin
> and is located:
> target\classes\META-INF\maven\plugin.xml
> If I only execute the test via JUnit in Eclipse that files - of course -
> isn't created.
> So I let the build run one time.
> Now I have the information of the @Parameter annotation there.
> And somehow I'm sure that annotation won't be touched at any other time
> than when that maven-plugin-plugin is creating the plugin.xml...
>
> The file is now present and I also saw that MojoRule is reading it.
> But it seems it isn't using it as the error is still there.
>
> Any ideas?
>
>
> Regards,
> Gerrit
>
> -----Ursprüngliche Nachricht-----
> Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
> Gesendet: Freitag, 13. April 2018 15:02
> An: users@maven.apache.org
> Betreff: Writing own plugin: The parameter annotation - does it work?
>
> Hello everyone, :-)
>
>
> I'm currently writing a Maven plug-in again. And I'm experiencing some
> add odd behavior.
>
> Maybe I should add first that I'm currently executing my Mojo using the
> MojoRule within a JUnit test.
>
> The parameters of my Mojo are annotated using the @Parameter annotation
> of Maven.
>
>
> That annotation has a property name() (from the Javadoc):
>
>
> name of the bean property used to get/set the field: by default, field
> name is used.
>
>
> So I thought I can use that when the name of the property in the Mojo
> and in the POM file differ.
>
> Let's say I have a Mojo property "hdd", but I want to use
> "hardDiskDrive" in the POM file.
>
> But it seems that Maven doesn't care for that annotation as I get an
> error:
>
>
> org.codehaus.plexus.component.configurator.ComponentConfigurationExcepti
> on: Cannot find 'hardDiskDrive' in class test.example.MyMojo
>
> at
> org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHel
> per.java:252)
>
> at
> org.codehaus.plexus.component.configurator.converters.composite.ObjectWi
> thFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:10
> 1)
>
> at
> org.codehaus.plexus.component.configurator.BasicComponentConfigurator.co
> nfigureComponent(BasicComponentConfigurator.java:34)
>
> at
> org.codehaus.plexus.component.configurator.AbstractComponentConfigurator
> .configureComponent(AbstractComponentConfigurator.java:44)
>
> at
> org.apache.maven.plugin.testing.AbstractMojoTestCase.lookupConfiguredMoj
> o(AbstractMojoTestCase.java:484)
>
> at
> org.apache.maven.plugin.testing.MojoRule.lookupConfiguredMojo(MojoRule.j
> ava:197)
>
> [...]
>
>
> Any ideas about that? Are annotations not evaluated by the classes used
> by MojoRule?
>
>
> I also realized that the property readonly() of the @Parameter
> annotation is totally ignored in this scenerio.
>
>
> Regards
>
> Gerrit
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
AW: Writing own plugin: The parameter annotation - does it work?
Posted by g....@aurenz.de.
Hello everyone,
after trying different approaches and seeing the efforts needed I give up on this.
Especially as I realized that the maven-plugin-testing-harness latest version 3.3.0 was realized at 2014-12-17.
I thought about opening an issue in the issue tracking system of the project, just to realize that they had it at Codehaus, which closed its doors some time ago.
Hopefully someone of the "Maven Plugin Testing Mechanism" will read this.
Until then proper Maven Plug-in testing is not possible using JUnit - especially not if it is in the IDE (Eclipse+M2E) and not during the Maven build.
Regards,
Gerrit
-----Ursprüngliche Nachricht-----
Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
Gesendet: Freitag, 13. April 2018 15:53
An: users@maven.apache.org
Betreff: AW: Writing own plugin: The parameter annotation - does it work?
Hello everyone,
after some analyzing I realized that the MojoRule is trying to read the plug-in description.
This file is created during the build process by the maven-plugin-plugin and is located:
target\classes\META-INF\maven\plugin.xml
If I only execute the test via JUnit in Eclipse that files - of course - isn't created.
So I let the build run one time.
Now I have the information of the @Parameter annotation there.
And somehow I'm sure that annotation won't be touched at any other time than when that maven-plugin-plugin is creating the plugin.xml...
The file is now present and I also saw that MojoRule is reading it.
But it seems it isn't using it as the error is still there.
Any ideas?
Regards,
Gerrit
-----Ursprüngliche Nachricht-----
Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
Gesendet: Freitag, 13. April 2018 15:02
An: users@maven.apache.org
Betreff: Writing own plugin: The parameter annotation - does it work?
Hello everyone, :-)
I'm currently writing a Maven plug-in again. And I'm experiencing some
add odd behavior.
Maybe I should add first that I'm currently executing my Mojo using the
MojoRule within a JUnit test.
The parameters of my Mojo are annotated using the @Parameter annotation
of Maven.
That annotation has a property name() (from the Javadoc):
name of the bean property used to get/set the field: by default, field
name is used.
So I thought I can use that when the name of the property in the Mojo
and in the POM file differ.
Let's say I have a Mojo property "hdd", but I want to use
"hardDiskDrive" in the POM file.
But it seems that Maven doesn't care for that annotation as I get an
error:
org.codehaus.plexus.component.configurator.ComponentConfigurationExcepti
on: Cannot find 'hardDiskDrive' in class test.example.MyMojo
at
org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHel
per.java:252)
at
org.codehaus.plexus.component.configurator.converters.composite.ObjectWi
thFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:10
1)
at
org.codehaus.plexus.component.configurator.BasicComponentConfigurator.co
nfigureComponent(BasicComponentConfigurator.java:34)
at
org.codehaus.plexus.component.configurator.AbstractComponentConfigurator
.configureComponent(AbstractComponentConfigurator.java:44)
at
org.apache.maven.plugin.testing.AbstractMojoTestCase.lookupConfiguredMoj
o(AbstractMojoTestCase.java:484)
at
org.apache.maven.plugin.testing.MojoRule.lookupConfiguredMojo(MojoRule.j
ava:197)
[...]
Any ideas about that? Are annotations not evaluated by the classes used
by MojoRule?
I also realized that the property readonly() of the @Parameter
annotation is totally ignored in this scenerio.
Regards
Gerrit
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
AW: Writing own plugin: The parameter annotation - does it work?
Posted by g....@aurenz.de.
Hello everyone,
after some analyzing I realized that the MojoRule is trying to read the plug-in description.
This file is created during the build process by the maven-plugin-plugin and is located:
target\classes\META-INF\maven\plugin.xml
If I only execute the test via JUnit in Eclipse that files - of course - isn't created.
So I let the build run one time.
Now I have the information of the @Parameter annotation there.
And somehow I'm sure that annotation won't be touched at any other time than when that maven-plugin-plugin is creating the plugin.xml...
The file is now present and I also saw that MojoRule is reading it.
But it seems it isn't using it as the error is still there.
Any ideas?
Regards,
Gerrit
-----Ursprüngliche Nachricht-----
Von: g.hohl@aurenz.de [mailto:g.hohl@aurenz.de]
Gesendet: Freitag, 13. April 2018 15:02
An: users@maven.apache.org
Betreff: Writing own plugin: The parameter annotation - does it work?
Hello everyone, :-)
I'm currently writing a Maven plug-in again. And I'm experiencing some
add odd behavior.
Maybe I should add first that I'm currently executing my Mojo using the
MojoRule within a JUnit test.
The parameters of my Mojo are annotated using the @Parameter annotation
of Maven.
That annotation has a property name() (from the Javadoc):
name of the bean property used to get/set the field: by default, field
name is used.
So I thought I can use that when the name of the property in the Mojo
and in the POM file differ.
Let's say I have a Mojo property "hdd", but I want to use
"hardDiskDrive" in the POM file.
But it seems that Maven doesn't care for that annotation as I get an
error:
org.codehaus.plexus.component.configurator.ComponentConfigurationExcepti
on: Cannot find 'hardDiskDrive' in class test.example.MyMojo
at
org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHel
per.java:252)
at
org.codehaus.plexus.component.configurator.converters.composite.ObjectWi
thFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:10
1)
at
org.codehaus.plexus.component.configurator.BasicComponentConfigurator.co
nfigureComponent(BasicComponentConfigurator.java:34)
at
org.codehaus.plexus.component.configurator.AbstractComponentConfigurator
.configureComponent(AbstractComponentConfigurator.java:44)
at
org.apache.maven.plugin.testing.AbstractMojoTestCase.lookupConfiguredMoj
o(AbstractMojoTestCase.java:484)
at
org.apache.maven.plugin.testing.MojoRule.lookupConfiguredMojo(MojoRule.j
ava:197)
[...]
Any ideas about that? Are annotations not evaluated by the classes used
by MojoRule?
I also realized that the property readonly() of the @Parameter
annotation is totally ignored in this scenerio.
Regards
Gerrit
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org