Plugin prefix resolution regression in 3.9.12
Affected version
3.9.12
Bug description
Plugin prefix resolution for spotless-maven-plugin fails with 3.9.12 but works on 3.9.11 and below. It resolves spotless as the avro plugin instead of the spotless plugin. Example:
➜ mvn spotless:apply
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.100 s
[INFO] Finished at: 2025-12-22T10:28:23+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'apply' in plugin org.apache.avro:avro-maven-plugin:1.11.0 among available goals help, idl-protocol, induce, protocol, schema -> [Help 1]
In 3.9.11 and below we get the correct behaviour:
➜ mvn spotless:apply
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.example:plugin-maven >----------------------
[INFO] Building plugin-maven 0.0.1-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- spotless:3.1.0:apply (default-cli) @ plugin-maven ---
[INFO] Spotless.Java is keeping 2 files clean - 0 were changed to be clean, 0 were already clean, 2 were skipped because caching determined they were already clean
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.295 s
[INFO] Finished at: 2025-12-22T10:30:23+01:00
[INFO] ------------------------------------------------------------------------
This happens when using the pom.xml below:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.example</groupId>
<artifactId>plugin-maven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>plugin-maven</name>
<description>plugin-maven</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.11.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>protocol</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<fieldVisibility>PRIVATE</fieldVisibility>
<stringType>String</stringType>
<enableDecimalLogicalType>true</enableDecimalLogicalType>
<sourceDirectory>target/generated-sources/avro</sourceDirectory>
<testSourceDirectory>target/generated-test-sources/avro</testSourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<java>
<googleJavaFormat>
<version>1.17.0</version>
<style>AOSP</style>
</googleJavaFormat>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
and this settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<url>http://our.internal.nexus.host.se/content/groups/public</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</settings>
When used without settings.xml or a settings.xml without mirror-configuration, the prefix resolution works as before.
Howdy, as you say, without MRM prefix resolution works as expected, thus, it has to be your MRM that has some invalid metadata.
Based on your mirror config I assume you use NX w/ public "supergroup". Try out these (replace URL to your):
$ curl http://our.internal.nexus.host.se/content/groups/public/com/diffplug/spotless/maven-metadata.xml
$ curl http://our.internal.nexus.host.se/content/groups/public/org/apache/avro/maven-metadata.xml
The corresponding metadata in Maven Central are these:
- https://repo.maven.apache.org/maven2/com/diffplug/spotless/maven-metadata.xml -- spotless has no G level Maven Metadata
- https://repo.maven.apache.org/maven2/org/apache/avro/maven-metadata.xml -- avro has G level Maven Metadata
Try to figure out from where the corrupt metadata comes from, that Makes maven wrongly resolve the group.
Also, try to use -X (use less or something similar as you will get a LOT of log), and try to figure out what Maven does:
[DEBUG] Resolving plugin prefix spotless from [eu.maveniverse.maven.plugins, org.apache.maven.plugins, org.codehaus.mojo]
...
[DEBUG] Resolved plugin prefix spotless to com.diffplug.spotless:spotless-maven-plugin from repository null
Finally, re-supergroups, my own stance: https://maveniverse.eu/blog/2025/11/09/why-are-mrm-group-repositories-bad/
Hint: once you found out the corrupt metadata (using curl and/or -X debug output of Maven), inspect it like this from browser (if MRM is NX2):
- http://our.internal.nexus.host.se/content/groups/public/org/apache/avro/maven-metadata.xml?describe
And observe related entries, for example:
Thanks!
Our internal nexus instance has this G-level metadata for avro, which seems to be the culprit:
<metadata>
<plugins>
<plugin>
<name>Apache Avro Maven Plugin</name>
<prefix>avro</prefix>
<artifactId>avro-maven-plugin</artifactId>
</plugin>
<plugin>
<name>Apache Avro Maven Plugin</name>
<prefix>spotless</prefix>
<artifactId>avro-maven-plugin</artifactId>
</plugin>
</plugins>
</metadata>
I have no idea how it got there (but will try to get someone to help me get it synced from central again).
So in 3.9.12 this entry is preferred over ${prefix}-maven-plugin ?
Locally I have these in .m2/repository/org/apache/avro:
maven-metadata-central.xml maven-metadata-nexus.xml
where maven-metadata-nexus.xml hosts the spotless-prefix config.
The ${prefix}-maven-plugin was never preferred, in those cases prefix was used as part of heuristic (during plugin build time) to figure out wanted prefix, but many plugins artifactId did not follow this pattern and literally ended up prefix-less. Hence, while started supporting Maven 3 and Maven 4 plugins in parallel, in Maven Plugin Tools we made prefix mandatory https://github.com/apache/maven-plugin-tools/issues/767
With that, there was another bug in Maven: excessive plugin resolution (basically Maven resolved all plugins in project) when invoking ad-hoc plugin goals: https://github.com/apache/maven/issues/11067
And finally we got a bit of step-back too, as for example spotless lacks G metadata in Central https://github.com/apache/maven/issues/11252
So, in short: Maven when looking for "prefix resolution", it does it in this order:
- uses repository G level metadata (for configured plugin groups) -- is fast but requires "good metadata"
- (if project present) falls back to POM defined plugins -- is slow, as it needs to blindly resolve and crank up plugins to figure out prefix, if applicable.
All that said, I can envision an improvement: in your case (invalid metadata) Maven resolves prefix spotless to org.apache.avro:avro-maven-plugin GA, and maybe should warn or even fail, as once avro-maven-plugin is resolved and Plugin descriptor loaded, it becomes clear that spotless prefix != avro prefix (IF avro-maven-plugin does have prefix!).
@cstamas @KingBuzzer hello sir, I would like to contribute to this issue plss assign to me if its open and looking forward to learn and growth
A warning would make it easier to understand what is happening anyway.
We got rid of the issue by removing the repo (mulesoft) from the group repo, which had the avro version with this problem, https://issues.apache.org/jira/browse/AVRO-2497. And as your blog post said, group repos are very fragile here where they just merge the metadata from different underlying repos. Hopefully no developer in our org will fetch that bad version again :-)
I guess the only safe fix is to get spotless to publish (or let sonatype generate it during publish) group level metadata (https://github.com/diffplug/spotless/issues/2673) in 3.9.12+?
Same issue here since 3.9.12, worked in 3.9.11.
The same defective maven-metadata-central-mirror.xml than https://github.com/apache/maven/issues/11596#issuecomment-3681860504 was downloaded locally, with the <prefix>spotless</prefix> entry on the Apache Avro Maven Plugin.
It was cached by our binary manager. Resolved by clearing the cache on org/apache/avro on our side.
The issue is resolved, or at least explained by bad remote metadata. Question is, from where they come?