Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ptziegler opened this issue Aug 22, 2024 · 4 comments
Closed

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

ptziegler opened this issue Aug 22, 2024 · 4 comments

Comments

@ptziegler
Copy link
Contributor

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?

private void addAdditionalFolders(List<SourceFolderClasspathEntry> folders, Model model, Path bundleRoot,
String goal) {
Plugin buildHelperPlugin = null;
for (SourceFolderClasspathEntry entry : folders) {
if (buildHelperPlugin == null) {
buildHelperPlugin = getPlugin(model, "org.codehaus.mojo", "build-helper-maven-plugin");
}
addPluginExecution(buildHelperPlugin, execution -> {
execution.setId("eclipse-classpath-" + goal + "-" + ID.incrementAndGet());
execution.setPhase("initialize");
execution.getGoals().add(goal);
MavenConfiguation configuration = getConfiguration(execution);
MavenConfiguation sources = configuration.addChild("sources");
MavenConfiguation source = sources.addChild("source");
Path additionalSourcePath = entry.getSourcePath().toPath();
String additionalPath = bundleRoot.relativize(additionalSourcePath).toString();
source.setValue(additionalPath);
});
}
}

@laeubi
Copy link
Member

laeubi commented Aug 22, 2024

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
Copy link
Contributor Author

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
Copy link
Member

laeubi commented Aug 22, 2024

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
Copy link
Contributor Author

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.

@ptziegler ptziegler closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants