vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
879 stars 57 forks source link

Reduce plugin configuration complexity #545

Open Lodin opened 1 year ago

Lodin commented 1 year ago

For now, we have some unnecessary complexity for the plugin configuration. E.g., if you want to change the default configuration of NonnullPlugin, you write something like the following Maven configuration:

<plugin>
    <groupId>dev.hilla</groupId>
    <artifactId>hilla-maven-plugin</artifactId>
    <version>${hilla.version}</version>
    <configuration>
        <parser>
            <use>
                <plugin>
                    <name>dev.hilla.parser.plugins.nonnull.NonnullPlugin</name>
                    <configuration implementation="dev.hilla.parser.plugins.nonnull.NonnullPluginConfig">
                        <use>
                            <annotation>
                                <name>com.example.application.Nonnull</name>
                                <makesNullable>false</makesNullable>
                                <score>30</score>
                            </annotation>
                        </use>
                    </configuration>
                </plugin>
            </use>
        </parser>
    </configuration>
    ...
</plugin>

Here you see the usage of the <use> tag. However, if you want to disable some default plugin, you still need to write something like that:

<plugin>
    <groupId>dev.hilla</groupId>
    <artifactId>hilla-maven-plugin</artifactId>
    <version>${hilla.version}</version>
    <configuration>
        <parser>
            <disable>
                <plugin>
                    <name>dev.hilla.parser.plugins.nonnull.NonnullPlugin</name>
                </plugin>
            </disable>
        </parser>
    </configuration>
    ...
</plugin>

I assume it is unnecessary and should be simplified to the following:

<plugin>
    <groupId>dev.hilla</groupId>
    <artifactId>hilla-maven-plugin</artifactId>
    <version>${hilla.version}</version>
    <configuration>
        <parser>
            <disable>
                <plugin>dev.hilla.parser.plugins.nonnull.NonnullPlugin</plugin>
            </disable>
        </parser>
    </configuration>
    ...
</plugin>

We need to use only the specific ID (class name) to disable an element instead of using the fully capable class that allows user to specify configuration etc.

P.S. It also affects everything that extends dev.hilla.parser.utils.ConfigList from parser-jvm-utils package.

Legioth commented 1 year ago

I would suggest that the configuration complexity should be completely moved somewhere else so that we would have a configuration mechanism that would work the same also with Gradle.