eclipse-tycho / tycho

Tycho project repository (tycho)
https://tycho.eclipseprojects.io
Eclipse Public License 2.0
170 stars 190 forks source link

Missing version for build-helper-maven-plugin in generated pom #4174

Closed ptziegler closed 1 month ago

ptziegler commented 2 months ago

Within our build (using Tycho 4.0.8), I see several warnings of the form:

[WARNING] Some problems were encountered while building the effective model for <...>
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:build-helper-maven-plugin is missing.
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

Which is weird, given that we don't use this plugin anywhere. But after looking through the files that are generated as part of our pomless build, I noticed the following entry that explains this weird behavior:

<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>eclipse-classpath-add-source-1</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src-gen</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

This execution is added by the TychoBundleMapping, so it seems the version qualifier is simply omitted? As a workaround, I've specified the version via a pluginManagement entry. But given that the generated poms are normally not visible, I assume that this isn't the proper solution?

https://github.com/eclipse-tycho/tycho/blob/573719292a99b4938c1a054d929c5cc3ed77aca2/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoBundleMapping.java#L157-L176

laeubi commented 2 months ago

As a workaround, I've specified the version via a pluginManagement entry.

This is the correct (maven) way.

I assume that this isn't the proper solution?

Due to how maven work we only have two options:

  1. Let the user choose / configure the version in the parent pom
  2. Specify a fixed version that is not upgradable/changeable

Tycho currently uses option 1.

ptziegler commented 2 months ago

The problem I see is that it's not really clear why the user has to configure the version. At least from my side, I saw this warning, looked through the project for all references of the "build-helper-maven-plugin" and ended up really confused, because the search returned nothing.

Perhaps it would make sense for Tycho to create a dedicated log message in such a situation? Simply to give the user a clue what's causing this warning, rather than leaving them completely in the dark.

laeubi commented 2 months ago

Perhaps it would make sense for Tycho to create a dedicated log message in such a situation?

The problem is that at that phase Tycho is mostly "blind" about the final maven pom model.

ptziegler commented 1 month ago

By explicitly setting the version for the build-helper-maven-plugin, the warning no longer shows up. Perhaps there is a better way to handle, but for the time being, I think it's resolved.