You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Robert Scholte <rf...@apache.org> on 2020/08/01 13:06:24 UTC

Re: Complex types as properties and/or profile configuration

The Parameter annotation only works on the Mojo, not inside the complex object.

What you can do is the following:

    private ComplexObject complexObect = new ComplexObject()
    
    @Parameter( property = "acme.name")
    private String name;
    
    public void setName( String name ) {
        this.complexObject.setName( name );
    }

Most important: the setter must be public.
Now the setter is called instead of the field being set (the field acts as a marker and will stay null, unless you improve setName())

Robert
On 30-7-2020 08:21:49, Alexander Broekhuis <a....@gmail.com> wrote:
Hi All,

I am using a plugin that uses several complex types as configuration. This
all looks nice when having a single plugin config, with properties
grouped together. But now I want to be able to override several of these
properties via the commandline or via a profile.

Afaik, setting complex properties is not possible on the commandline. What
seems to work is to add a set(String) method to my complex type and use
some string formatting to set the property as one string.

Is this correct, or is there a better way to do this? What bothers me most
is that I need to set a list of complex types. For a list the comma is used
as a separator, so for the actual complex type some other character is
needed, which might make the format and parsing overly complicated. Perhaps
there is a cleaner solution..

Likewise, instead of setting properties via the commandline, can I somehow
add complex types to the properties section of the pom? Simply adding an
xml element to it results in errors. That it is not easily possible via the
commandline makes sense to me, but I somehow expected that it would be
possible to set them in the properties section :(.

To continue on this, in my pom I use several profiles to have different
configurations for plugins, and here I have the same issue. Is it possible
to have complex types in profiles? I know I can create a complete new
plugin configuration, but that results in a lot of duplication, which makes
the pom file quite long.

TIA!

--
Met vriendelijke groet,

Alexander Broekhuis

Re: Complex types as properties and/or profile configuration

Posted by Alexander Broekhuis <a....@gmail.com>.
Thanks for the reply,

While this helps with some of the "parameters", this doesn't help me with
lists of complex parameters.

Also, is it not possible to use xml structures inside the plugin properties?

Op za 1 aug. 2020 om 15:07 schreef Robert Scholte <rf...@apache.org>:

> The Parameter annotation only works on the Mojo, not inside the complex
> object.
>
> What you can do is the following:
>
>     private ComplexObject complexObect = new ComplexObject()
>
>     @Parameter( property = "acme.name")
>     private String name;
>
>     public void setName( String name ) {
>         this.complexObject.setName( name );
>     }
>
> Most important: the setter must be public.
> Now the setter is called instead of the field being set (the field acts as
> a marker and will stay null, unless you improve setName())
>
> Robert
> On 30-7-2020 08:21:49, Alexander Broekhuis <a....@gmail.com> wrote:
> Hi All,
>
> I am using a plugin that uses several complex types as configuration. This
> all looks nice when having a single plugin config, with properties
> grouped together. But now I want to be able to override several of these
> properties via the commandline or via a profile.
>
> Afaik, setting complex properties is not possible on the commandline. What
> seems to work is to add a set(String) method to my complex type and use
> some string formatting to set the property as one string.
>
> Is this correct, or is there a better way to do this? What bothers me most
> is that I need to set a list of complex types. For a list the comma is used
> as a separator, so for the actual complex type some other character is
> needed, which might make the format and parsing overly complicated. Perhaps
> there is a cleaner solution..
>
> Likewise, instead of setting properties via the commandline, can I somehow
> add complex types to the properties section of the pom? Simply adding an
> xml element to it results in errors. That it is not easily possible via the
> commandline makes sense to me, but I somehow expected that it would be
> possible to set them in the properties section :(.
>
> To continue on this, in my pom I use several profiles to have different
> configurations for plugins, and here I have the same issue. Is it possible
> to have complex types in profiles? I know I can create a complete new
> plugin configuration, but that results in a lot of duplication, which makes
> the pom file quite long.
>
> TIA!
>
> --
> Met vriendelijke groet,
>
> Alexander Broekhuis
>


-- 
Met vriendelijke groet,

Alexander Broekhuis