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

Enable up-to-date checking in Maven plugin by default #1621

Merged

Conversation

lutovich
Copy link
Contributor

Up-to-date checking has been supported for a long time. We haven't received any negative feedback about it. Neo4j is an example project that has up-to-date checking enabled to improve performance and haven't had problems with it: link.

It should be safe to enable up-to-date checking for all users of the Spotless Maven plugin.

This PR also fixes a problem where plugin execution would fail on a parent of a multimodule Maven project with up-to-date checking enabled. A parent project can configure Spotless as:

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        ...
      </plugin>
    </plugins>
  </pluginManagement>
</build>

It allows child projects to inherit plugin's version and configuration but the plugin is not enables by default.

PluginFingerprint did not handle such configuration correctly. It could only handle a simple configuration like:

<build>
  <plugins>
    <plugin>
      <groupId>com.diffplug.spotless</groupId>
      <artifactId>spotless-maven-plugin</artifactId>
      ...
    </plugin>
  </plugins>
</build>

And failed with "Spotless plugin absent from the project" error for a multimodule parent project with Spotless in <pluginManagement>.

@lutovich lutovich requested a review from nedtwigg March 12, 2023 20:24
checker = UpToDateChecker.forProject(project, indexFile, formatters, getLog());
} else {
getLog().info("Up-to-date checking disabled");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed logging slightly because disabled up-to-date checking will be an uncommon path that requires explicit configuration. Thus, the plugin should log something on such an uncommon path

Up-to-date checking has been supported for a long time. We haven't received any
negative feedback about it. Neo4j is an example project that has up-to-date
checking enabled to improve performance and haven't had problems with it:
https://github.com/neo4j/neo4j/blob/6ebc409772cea13354adb6a11aab4ed38da9d53e/pom.xml#L745-L747.

It should be safe to enable up-to-date checking for all users of the Spotless Maven plugin.

This commit also fixes the problem where plugin execution would fail on a parent of a multimodule
Maven project with up-to-date checking enabled. A parent project can configure Spotless as:

```xml
<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        ...
      </plugin>
    </plugins>
  </pluginManagement>
</build>
```

It allows child projects to inherit plugin's version and configuration but the
plugin is not enables by default.

PluginFingerprint did not handle such configuration correctly. It could only handle a simple
configuration like:

```xml
<build>
  <plugins>
    <plugin>
      <groupId>com.diffplug.spotless</groupId>
      <artifactId>spotless-maven-plugin</artifactId>
      ...
    </plugin>
  </plugins>
</build>
```

And failed with "Spotless plugin absent from the project" error for a multimodule
parent project with Spotless in `<pluginManagement>`.
@lutovich lutovich force-pushed the maven-up-to-date-checking-enabled-by-default branch from 1a7530b to 24abb54 Compare March 12, 2023 20:33
Copy link
Member

@nedtwigg nedtwigg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@nedtwigg nedtwigg merged commit 18de088 into diffplug:main Mar 13, 2023
@lutovich lutovich deleted the maven-up-to-date-checking-enabled-by-default branch March 13, 2023 09:04
@nedtwigg
Copy link
Member

Published in 2.35.0.

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

Successfully merging this pull request may close these issues.

2 participants