Skip to content

Maven can't locate this plugin due to "org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix 'spotless'" #520

Open

Description

@matts19

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)

Activity

  1. Shanky2304 commented on Feb 1, 2020

    @Shanky2304

    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"

  2. nedtwigg commented on Feb 1, 2020

    @nedtwigg
    Member

    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 your settings.xml comes 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:

    task createPomXml(dependsOn: installLocalDependencies) {
    doLast {
    def additionalDependencies = project.configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts.findAll {
    return !libs.contains(it.moduleVersion.id.name)
    }.collect {
    return " <dependency>\n" +
    " <groupId>${it.moduleVersion.id.group}</groupId>\n" +
    " <artifactId>${it.moduleVersion.id.name}</artifactId>\n" +
    " <version>${it.moduleVersion.id.version}</version>\n" +
    " </dependency>\n"
    }.join()
    def versions = [
    spotlessMavenPluginVersion: version,
    mavenApiVersion : VER_MAVEN_API,
    eclipseAetherVersion : VER_ECLIPSE_AETHER,
    spotlessLibVersion : libVersion,
    additionalDependencies : additionalDependencies
    ]
    def pomXmlTemplate = Paths.get(PROJECT_DIR, "src/test/resources/pom-build.xml.mustache")
    def newPomXml = Paths.get(MAVEN_PROJECT_DIR, "pom.xml")
    Files.newBufferedReader(pomXmlTemplate).withCloseable { reader ->
    Files.newBufferedWriter(newPomXml, UTF_8, CREATE_NEW, TRUNCATE_EXISTING).withCloseable { writer ->
    def mustache = new DefaultMustacheFactory().compile(reader, "pom")
    mustache.execute(writer, versions)
    }
    }
    }
    }
    task runMavenBuild(type: Exec, dependsOn: [
    cleanMavenProjectDir,
    copySourceFiles,
    copyMvnw,
    createPomXml
    ]) {
    workingDir MAVEN_PROJECT_DIR
    // -B batch mode to make dependency download logging less verbose
    commandLine mvnw("clean install -B -Dmaven.repo.local=${LOCAL_MAVEN_REPO_DIR}")
    }

    I'm happy to help with any gradle integration issues, but I don't know anything about the maven part.

  3. nedtwigg commented on May 6, 2020

    @nedtwigg
    Member

    Closing due to inactivity and inability to replicate. Happy to reopen with an open source repo that demonstrates the issue.

  4. vlaw commented on Nov 10, 2022

    @vlaw

    I have the same issue.

    $ mvn -X spotless:check
    ...
    [DEBUG] Could not find metadata com.diffplug.spotless/maven-metadata.xml in central (https://repo.maven.apache.org/maven2)
    ......
    ......
    [ERROR] No plugin found for prefix 'spotless' in the current project and in the plugin groups [com.diffplug.spotless, com.github.spotbugs, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/luowentao/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

    I'm not familiar with building a maven plugin neither. But I do find something, I guess.
    There is NO maven-metadata.xml under https://repo.maven.apache.org/maven2/com/diffplug/spotless/.

    As a contrast, there are two other pluginGroups , which have maven-metadata.xml in centra repo.

    <metadata>
    <plugins>
      <plugin>
        <name>SpotBugs Maven Plugin</name>
        <prefix>spotbugs</prefix>      <!-- HERE -->
        <artifactId>spotbugs-maven-plugin</artifactId>
      </plugin>
    </plugins>
    </metadata>

    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.

  5. glucazeau commented on Jun 12, 2024

    @glucazeau

    👋 It is unfortunately still an issue.

    As @vlaw said the repository is missing maven-metadata file (another example for sonar:sonar plugin : 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)

  6. a-t-90 commented on Aug 7, 2024

    @a-t-90

    For anyone searching to resolve the same No plugin found for prefix 'spotless' error, here is a solution (that uses Maven).

  7. firmianaQ commented on Apr 9, 2025

    @firmianaQ

    I have the same issue.
    jdk21
    Maven Plugin v2.44.3

  8. hiawui commented on Dec 19, 2025

    @hiawui

    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.

  9. mnk commented on Apr 26, 2026

    @mnk

    I am also hit by this issue. For each invocation of ./mnvw spotless:check Maven tries unsuccessfully to find a plugin that claims the spotless prefix by downloading maven-metadata.xml for all registered plugins in the project - this adds 2-5 seconds of delay. Eg.

    Downloading from central: https://repo.maven.apache.org/maven2/org/cyclonedx/maven-metadata.xml
    Downloading from central: https://repo.maven.apache.org/maven2/com/diffplug/spotless/maven-metadata.xml
    Downloading from central: https://repo.maven.apache.org/maven2/com/google/cloud/tools/maven-metadata.xml
    Downloading from central: https://repo.maven.apache.org/maven2/io/fabric8/maven-metadata.xml
    Downloaded from central: https://repo.maven.apache.org/maven2/com/google/cloud/tools/maven-metadata.xml (708 B at 1.5 kB/s)
    Downloading from central: https://repo.maven.apache.org/maven2/org/flywaydb/maven-metadata.xml
    Downloaded from central: https://repo.maven.apache.org/maven2/io/fabric8/maven-metadata.xml (1.9 kB at 4.0 kB/s)
    ...
    

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions