Repository navigation
Open
Labels
Description
When try to run "mvn -s settings.xml spotless:check", it can't locate this plugin due to "org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix 'spotless'"
I even entered the plugin group info in settings.xml:
<pluginGroups>
<pluginGroup>com.diffplug.spotless</pluginGroup>
</pluginGroups>
But maven refuses to find this plugin via prefix. Full naming works though (com.diffplug.spotless:spotless-maven-plugin:check).
For the prefix to work my understanding is that the plugin should provide prefix info in its maven-metadata.xml at the group level. But this plugin does not come with such meta data file. It only has maven-metadata.xml at the artifact level for each artifact version. That is, I could not find maven-metadata.xml which content like this:
<metadata>
<plugins>
<plugin>
<name>Some Awesome Maven Plugin</name>
<prefix>somePrefix</prefix>
<artifactId>some-maven-plugin</artifactId>
</plugin>
</plugins>
</metadata>
- [ ] gradle or maven version
Maven 3.5.0
- [ ] spotless version
1.27.0 but I tried many other versions
- [ ] operating system and version
Ubuntu Xenial
- [ ] copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
It's very simple.
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>1.21.0</version>
<configuration>
<java>
<removeUnusedImports/>
</java>
</configuration>
</plugin>
- [ ] copy-paste the full content of any console errors
[DEBUG] Resolving plugin prefix spotless from [com.diffplug.spotless, org.apache.maven.plugins, org.codehaus.mojo]
[DEBUG] Using mirror repo (http://scctools.dt.vmware.com:8081/artifactory/repo) for plexus-snapshots (https://oss.sonatype.org/content/repositories/plexus-snapshots).
[DEBUG] Using mirror repo (http://scctools.dt.vmware.com:8081/artifactory/repo) for apache.snapshots (http://repository.apache.org/snapshots).
[DEBUG] Using mirror repo (http://scctools.dt.vmware.com:8081/artifactory/repo) for codehaus.org (http://snapshots.repository.codehaus.org).
[DEBUG] Could not find metadata com.diffplug.spotless/maven-metadata.xml in local (/home/jenkins/.m2/repository)
[DEBUG] Could not find metadata org.apache.maven.plugins/maven-metadata.xml in local (/home/jenkins/.m2/repository)
[DEBUG] Could not find metadata org.codehaus.mojo/maven-metadata.xml in local (/home/jenkins/.m2/repository)
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://scctools.dt.vmware.com:8081/artifactory/repo
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://scctools.dt.vmware.com:8081/artifactory/repo
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://scctools.dt.vmware.com:8081/artifactory/repo
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://scctools.dt.vmware.com:8081/artifactory/repo
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://scctools.dt.vmware.com:8081/artifactory/repo
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://scctools.dt.vmware.com:8081/artifactory/repo
Downloading: http://scctools.dt.vmware.com:8081/artifactory/repo/org/apache/maven/plugins/maven-metadata.xml
Downloading: http://scctools.dt.vmware.com:8081/artifactory/repo/org/codehaus/mojo/maven-metadata.xml
Downloading: http://scctools.dt.vmware.com:8081/artifactory/repo/com/diffplug/spotless/maven-metadata.xml
[DEBUG] Writing tracking file /home/jenkins/.m2/repository/com/diffplug/spotless/resolver-status.properties
<snipped....>
[DEBUG] Could not find metadata com.diffplug.spotless/maven-metadata.xml in repo (http://scctools.dt.vmware.com:8081/artifactory/repo)
[DEBUG] Could not find metadata com.diffplug.spotless/maven-metadata.xml in local (/home/jenkins/.m2/repository)
[DEBUG] Skipped remote request for com.diffplug.spotless/maven-metadata.xml, already updated during this session.
[DEBUG] Failure to find com.diffplug.spotless/maven-metadata.xml in http://scctools.dt.vmware.com:8081/artifactory/repo was cached in the local repository, resolution will not be reattempted until the update interval of repo has elapsed or updates are forced
[DEBUG] Could not find metadata org.apache.maven.plugins/maven-metadata.xml in local (/home/jenkins/.m2/repository)
[DEBUG] Could not find metadata org.codehaus.mojo/maven-metadata.xml in local (/home/jenkins/.m2/repository)
Reacted by Mathias Nicolajsen Kjærgaard
Activity
Shanky2304 commentedon Feb 1, 2020
I have the same issue. It'll be much more handy if people can use the shorter version for this plugin otherwise it will just fizzle out as one of those "recommendations"
nedtwigg commentedon Feb 1, 2020
This might be a dumb question, but I'm not great with maven. At the very top of our plugin-maven readme, we've got a little plugin block to copy, and it looks like you copied it exactly right. We also have an example command line
mvn spotless:check. I do a little integration testing for each release to confirm that it is still working, and it is, for me.I don't understand how having a
<pluginGroups>in yoursettings.xmlcomes into it at all. I read these maven docs which reference it, but I still don't get it.Regardless of whether I understand the problem or not, we're happy to take a PR to fix/improve it. Here is our POM template:
https://github.com/diffplug/spotless/blob/e870e78999887595d8480c699c4ef71c9e974b32/plugin-maven/src/test/resources/pom-build.xml.mustache
And here is how we populate and run it:
spotless/plugin-maven/build.gradle
Lines 139 to 180 in e870e78
I'm happy to help with any gradle integration issues, but I don't know anything about the maven part.
nedtwigg commentedon May 6, 2020
Closing due to inactivity and inability to replicate. Happy to reopen with an open source repo that demonstrates the issue.
vlaw commentedon Nov 10, 2022
I have the same issue.
I'm not familiar with building a maven plugin neither. But I do find something, I guess.
There is NO
maven-metadata.xmlunder https://repo.maven.apache.org/maven2/com/diffplug/spotless/.As a contrast, there are two other pluginGroups , which have
maven-metadata.xmlin centra repo.So, maybe there is something go wrong during DEPLOY phrase, or maybe maven-publish error?
I'm not quit sure, hope this will give some clue.
glucazeau commentedon Jun 12, 2024
👋 It is unfortunately still an issue.
As @vlaw said the repository is missing maven-metadata file (another example for
sonar:sonarplugin : maven-metadata.xml)According to the documentation, this file at group level should be automatically uploaded when using "maven-plugin" as packaging type.
I couldn't find where and if this packaging type is specified somewhere in the Gradle build configuration of the plugin.
Furthermore, it says here that the Gradle "maven-publish" plugin seems to ignore the packaging type.
I don't know if it's still the case, but I would suppose that this plugin is used for traditional Maven projects, and that most of the Maven plugins are built and published with Maven itself.
I hope this can help, it would be really nice to be able to simply call
mvn spotless:check(on a global GitHub workflow for instance)a-t-90 commentedon Aug 7, 2024
For anyone searching to resolve the same
No plugin found for prefix 'spotless'error, here is a solution (that uses Maven).firmianaQ commentedon Apr 9, 2025
I have the same issue.
jdk21
Maven Plugin v2.44.3
hiawui commentedon Dec 19, 2025
This is because spotless is missing the groupId-level /com/diffplug/spotless/maven-metadata.xml.
The prefix 'spotless' can only be used if the groupId-level maven-metadata.xml is provided and the spotless tag is defined within it.
Can refer to the groupId-level /org/apache/maven/plugins/maven-metadata.xml for org.apache.maven.plugins as an example.
mnk commentedon Apr 26, 2026
I am also hit by this issue. For each invocation of
./mnvw spotless:checkMaven tries unsuccessfully to find a plugin that claims thespotlessprefix by downloading maven-metadata.xml for all registered plugins in the project - this adds 2-5 seconds of delay. Eg.This issue is also causing unnecessary load on https://repo.maven.apache.org.
I created a PR that might resolve this issue, but this can only be tested by project maintainers: #2905. I am happy to help verify if the patch is applied.