0

I am creating a new Maven plugin, following the instructions here.

I can create a new parameter, as per the documentation, like this:

@Parameter( property = "sayhi.greeting", defaultValue = "Hello World!" )
private String greeting;

Now I want to use this in my pom.xml

<plugin>
    <groupId>com.foo</groupId>
    <artifactId>my-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate-client-source</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <greeting>Hello, world!</greeting>
    </configuration>
</plugin>

However my editor of choice (IntelliJ) doesn't know about my plugin's parameter, so the <greeting> element is turned red, warning me of a possible syntax error.

I could create an XSD and add it to the <project> element, but I have a couple of questions.

  1. Is it possible to auto-generate the XSD from my source files, and have it packaged as part of the plugin build process?
  2. How do I reference it in my <project> element?
tom
  • 1,331
  • 1
  • 15
  • 28
  • You can't add it to the project element, cause the definition is fixed and the area `...` is defined by the plugin which means you will never have a complete XSD to define that...Apart from that you can't create an XSD from your source file which is not necessary...BTW: What is the intention of the plugin? – khmarbaise Dec 19 '15 at 13:36
  • I'm thinking something could parse my plugin source file and generate an XSD for all the configurable items. The plugin is taking production source code server-side beans, using reflection, and then generating client-side beans which will be part of a REST client. – tom Dec 19 '15 at 14:11
  • If you have the XSD who should use it? There are so many plugins out there...so i bet you will miss one...and you will never get a full XSD for pom.xml..... – khmarbaise Dec 19 '15 at 14:19
  • It would only be me using it, but I just didn't know if there was something built into Maven to make this happen auto-magically. I'm wondering how other plugin authors' configuration parameters become part of the XSD. Maybe this is a problem with every custom plugin? Maybe writing plugins is uncommon enough that it's not a problem that has bothered to be solved? – tom Dec 19 '15 at 14:36
  • First there is nothing build into Maven to make this happen auto-magically, second parameters of plugins will never become part of the [maven.xsd](http://maven.apache.org/xsd/maven-4.0.0.xsd)...writing plugins is not uncommons...http://maven.apache.org/plugins/, and if you google you will see how many there are...If you might need support for your ide (Eclipse, IntelliJ etc.) you might find support in this area for eclipse in m2e ...(I'm not sure at this point. You might ask on the maven users mailing list... – khmarbaise Dec 19 '15 at 19:06

0 Answers0