apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.63k stars 841 forks source link

annotationProcessorPaths in Maven ignored, if child element name is not path #7658

Open matthiasblaesing opened 1 month ago

matthiasblaesing commented 1 month ago

Apache NetBeans version

Apache NetBeans 22

What happened

When a maven project has a pom.xml with a annotationProcessorPaths configuration, where the element names are not path like this:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <parameters>true</parameters>
                    <annotationProcessorPaths>
                        <annotationProcessorPath>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>1.5.5.Final</version>
                        </annotationProcessorPath>
                        <annotationProcessorPath>
                            <groupId>io.soabase.record-builder</groupId>
                            <artifactId>record-builder-processor</artifactId>
                            <version>42</version>
                        </annotationProcessorPath>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

the annotation processors are not found/ran, as NetBeans currently expects the children of annotationProcessorPaths are named path:

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <parameters>true</parameters>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>1.5.5.Final</version>
                        </path>
                        <path>
                            <groupId>io.soabase.record-builder</groupId>
                            <artifactId>record-builder-processor</artifactId>
                            <version>42</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

Full project: annotation-processor-netbeans-reproducer.zip

Language / Project Type / NetBeans Component

Java Maven project

How to reproduce

Open attached test project in NetBeans

Did this work correctly in an earlier version?

No / Don't know

Operating System

Ubuntu 24.04

JDK

Amazon Corretto 21

Apache NetBeans packaging

Own source build

Anything else

No response

Are you willing to submit a pull request?

Yes

mbien commented 1 month ago

regarding

    <annotationProcessorPaths>
        <annotationProcessorPath>

when I look at the usage doc it only mentions <path> as list element.

The type of annotationProcessorPaths is List<DependencyCoordinate>. So i am wondering if the element name matters at all (maybe there is a convention I am not aware of). I will take a look at this later, I am not near an IDE atm.

mbien commented 1 month ago

https://github.com/apache/maven-compiler-plugin/blob/419f1b614f41e855a7b384d88b5324e22defb200/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java#L347

so I believe the way it works is that Lists can have arbitrary element names, this will likely work too:

    <annotationProcessorPaths>
        <hugo>
            ...
        </hugo>
        <otto>
           ...
        </otto>
    </annotationProcessorPaths>

so if NB is only checking annotationProcessorPaths/path it should be updated to check annotationProcessorPaths/*

going to take a look if this can be fixed.

matthiasblaesing commented 1 month ago

No need. A patch branch is already locally done on my side.

Your assessment is correct and was documented already here: https://github.com/apache/netbeans/issues/7611#issuecomment-2282267641 (yes it would have been good to include it, but the issue was more as a todo for me)

mbien commented 1 month ago

oops, I just opened a PR. I didn't see that you checked that you wanted to open a PR yourself, my mistake.