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

Spotless apparently not configured properly #9117

Closed
pihme opened this issue Apr 13, 2022 · 3 comments · Fixed by #9184
Closed

Spotless apparently not configured properly #9117

pihme opened this issue Apr 13, 2022 · 3 comments · Fixed by #9184
Assignees
Labels
area/maintainability Marks an issue as improving the maintainability of the project kind/toil Categorizes an issue or PR as general maintenance, i.e. cleanup, refactoring, etc. version:8.1.0-alpha1 Marks an issue as being completely or in parts released in 8.1.0-alpha1 version:8.1.0 Marks an issue as being completely or in parts released in 8.1.0

Comments

@pihme
Copy link
Contributor

pihme commented Apr 13, 2022

Description

Cannot really pinpoint the exact conditions, but lately I often have spotless errors in Jenkins.

  • I save my files with Idea and would assume that it applies the code style automatically.
  • running mvn clean install -DskipTests -DskipChecks does not change any files
  • running mvn spotless:apply results in this error: [ERROR] No plugin found for prefix 'spotless' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/peter/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

Running com.diffplug.spotless:spotless-maven-plugin:apply does work. But it is a bit hard to remember

@pihme pihme changed the title Spotless not configured properly Spotless apparently not configured properly Apr 13, 2022
@npepinpe
Copy link
Member

@korthout could you have a look? Did we change anything recently?

@npepinpe npepinpe added area/maintainability Marks an issue as improving the maintainability of the project kind/toil Categorizes an issue or PR as general maintenance, i.e. cleanup, refactoring, etc. labels Apr 13, 2022
@npepinpe
Copy link
Member

I just realized Nico is absent, probably for a while. As there's a workaround, I think we can wait until he's back, otherwise let me know and we can reassign.

@korthout
Copy link
Member

Considering this part:

  • running mvn spotless:apply results in this error: [ERROR] No plugin found for prefix 'spotless' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/peter/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

Running com.diffplug.spotless:spotless-maven-plugin:apply does work. But it is a bit hard to remember

This is something I had been running into when setting up spotless originally, and at the time I didn't understand why mvn spotless:apply didn't just work. Especially, because the root project had the spotless plugin in its build plugins.

I just played around with it a bit, and it seems the problem is related to the maven reactor. zeebe-bom is the first project that is executed by the maven reactor, but it does not know the spotless plugin. TBH, it does 'know' about it because the parent of the zeebe-bom has defined it in the pluginManagement tag, but that does not appear to be used for the plugin prefixes. To use plugins by their prefix, they need to be registered in the build plugins tag. I've opened a new PR (#9184) to fix that.

Considering this part:

  • I save my files with Idea and would assume that it applies the code style automatically.
  • running mvn clean install -DskipTests -DskipChecks does not change any files

@pihme I'd be interested to see a situation where this diff occurs between running it locally and on CI. It's hard to say what's causing this without an example. Let me know if you encounter it again, or if you can point me to a CI run where this happened. We can also pair on this if you run into it again locally.

zeebe-bors-camunda bot added a commit that referenced this issue Apr 21, 2022
9184: Support running `mvn spotless:apply` for convenience r=pihme a=korthout

## Description

<!-- Please explain the changes you made here. -->

When the spotless check fails, it recommends running `mvn spotless:apply` to automatically the formatting. However, if you try to run this locally you'll be greeted by the following message:

> [ERROR] No plugin found for prefix 'spotless' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/korthout/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

The 'spotless' prefix is not available, because the first project that is run, is not the root-project but the zeebe-bom. And the zeebe-bom project does not have knowledge of the spotless plugin in its build plugins.

This PR fixes this by adding the spotless plugin to the zeebe-bom's build plugins. Adding the plugin like this to the build doesn't do anything else except register the plugin for usage, because no executions are specified. The executions are still controlled by the profiles defined in the parent-pom.

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #9117



Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
@deepthidevaki deepthidevaki added the version:8.1.0-alpha1 Marks an issue as being completely or in parts released in 8.1.0-alpha1 label May 3, 2022
@Zelldon Zelldon added the version:8.1.0 Marks an issue as being completely or in parts released in 8.1.0 label Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maintainability Marks an issue as improving the maintainability of the project kind/toil Categorizes an issue or PR as general maintenance, i.e. cleanup, refactoring, etc. version:8.1.0-alpha1 Marks an issue as being completely or in parts released in 8.1.0-alpha1 version:8.1.0 Marks an issue as being completely or in parts released in 8.1.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants