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.h...@aurenz.de [mailto:g.h...@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-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to