Skip to content

Move to Gradle conventions plugins #3464

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

Merged
merged 17 commits into from
Oct 16, 2024
Merged

Move to Gradle conventions plugins #3464

merged 17 commits into from
Oct 16, 2024

Conversation

bric3
Copy link
Contributor

@bric3 bric3 commented Oct 7, 2024

This PR port most of the existing sparse Groovy DSL scripts as convention plugins, this is done to switch from decade old accumulation of scripting from the early days of Gradle to best practice of today. Fortunately our script were well split.

For the full motivation see #3446

At this stage, this PR port is almost a 1 to 1, i.e. it doesn't aim at introducing or changing the build behavior. It is not complete, the coverage, shipkit, spotless, licenses still remain to be converted.

tl;dr: what this PR does is changing apply from: ....gradle to a convention plugin plugins { id("mockito....-conventions") }. THese plugin are added in the standard buildSrc

  • Create the buildSrc project for the conventions plugins

    • Declares the moved plugin in the version catalog file
  • Java lib config

    • java-library.gradle --> mockito.library-conventions.gradle.kts, which applies other convention plugins below

    • java-library.gradle --> mockito.java-library-conventions.gradle.kts, also sets up Java related configurations found in the root build.gradle, and applies mockito.java-conventions

    • osgi.gradle --> mockito.osgi-conventions.gradle.kts, this only applies the plugin as config differ between mockito-core and mockito-junit-jupiter.

    • java-publication.gradle --> mockito.publication-conventions.gradle.kts

    • checkstyle.gradle --> mockito.checkstyle-conventions.gradle.kts

    • errorprone.gradle merged in mockito.java-library-conventions.gradle.kts

    • animalSniffer config in mockito-core/build.gradle and mockito-junit-jupiter/build.gradle --> extracted to mockito.java-backward-compatibility-checks-conventions.gradle.kts

  • Tests

    • java-test.gradle --> mockito.test-conventions.gradle.kts (which applies mockito.test-jfr-profiler-conventions, mockito.java-conventions)
    • jfr.gradle --> mockito.test-jfr-profiler-conventions.gradle.kts
    • test-launcher.gradle --> mockito.test-launcher-conventions.gradle.kts
    • retry-test.gradle --> mockito.test-retry-conventions.gradle.kts
  • Javadoc

    • mockito-core/javadoc.gradle and mockito-junit-jupiter/javadoc.gradle --> mockito.javadoc-conventions.gradle.kts
    • mockito-core/src/main/javadoc -> config/javadoc/resources, because it's shared with junit jupiter extension.

Now Mockito Libraries (core and extensions) declare this

plugins {
    id("mockito.library-conventions")
    id("mockito.java-backward-compatibility-checks-conventions") // if needed
    id("mockito.javadoc-conventions") // if needed
}

And integration tests have this

plugins {
    id("java")
    id("mockito.test-conventions")
}

Android test project also applies our convention.

plugins {
    id("com.android.application")
    id("kotlin-android")
    id("mockito.test-conventions")
}

Two approaches for the review

  1. Take a look at all the file changes.
  2. Review commit by commit, starting with this one : 94132ac, navigate back and forth with previous / next.

Checklist

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should mention Fixes #<issue number> if relevant

@bric3 bric3 force-pushed the conventions-plugins-3446 branch 2 times, most recently from d0243bc to 3009e45 Compare October 7, 2024 20:42
@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.77%. Comparing base (594a2d7) to head (4888857).
Report is 17 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3464      +/-   ##
============================================
+ Coverage     85.74%   85.77%   +0.02%     
- Complexity     2951     2953       +2     
============================================
  Files           341      341              
  Lines          8946     8946              
  Branches       1114     1114              
============================================
+ Hits           7671     7673       +2     
  Misses          988      988              
+ Partials        287      285       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bric3 bric3 force-pushed the conventions-plugins-3446 branch 14 times, most recently from 3528e52 to e54583d Compare October 10, 2024 11:12
@bric3 bric3 requested a review from TimvdLippe October 10, 2024 12:13
@bric3 bric3 marked this pull request as ready for review October 14, 2024 22:57
Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

Thanks for all the work and fixing the commit messages as well, much appreciated!

@TimvdLippe
Copy link
Contributor

Ah, I merged some plugin updates and didn't realize that would cause merge conflicts again :(

@bric3 bric3 force-pushed the conventions-plugins-3446 branch from 13f9cd0 to 2926146 Compare October 16, 2024 14:39
@bric3 bric3 force-pushed the conventions-plugins-3446 branch from 2926146 to 4888857 Compare October 16, 2024 15:14
@bric3 bric3 merged commit 3f1169c into main Oct 16, 2024
18 checks passed
@bric3 bric3 deleted the conventions-plugins-3446 branch October 16, 2024 15:25
@acktsap acktsap mentioned this pull request Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants