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

Gradle build script improvements #3062

Merged
merged 10 commits into from Jul 15, 2023
Merged

Gradle build script improvements #3062

merged 10 commits into from Jul 15, 2023

Conversation

TWiStErRob
Copy link
Contributor

A step towards #2898

This is in preparation for an other PR introducing toolchains which is a cross-module configuration. I did some generalization and consistency improvements to make it easier to make global changes. Some of the diffs in the PR might look strange, I recommend looking commit by commit to make sense of them.

Many modules already had java-library.gradle included. So I created a parallel java-test.gradle. With this there's now two named types of modules. Each subproject belongs to one of these types, except:

  • androidTest is an Android module, very special (because no java plugin)
  • bom is published, but not a library

There are some special-setup modules which still extend one of the named modules:

  • rootProject/mockito-core is a java-library (among many other things).
  • groovyInlineTest and groovyTest are Groovy modules too.
  • kotlinReleaseCoroutinesTest and kotlinTest are Kotlin modules too.
  • osgi-test does things.

There were several (test) modules missing Java compatiblility declaration:

  • Now they're all using Java 11 source/target for compilation.

Testing:

  • Generate repo snapshot by changing
    -repositories { maven { url = "$buildDir/repo" } }
    +repositories { maven { url = "${rootProject.buildDir}/repo" } }
    
  • Running gradlew clean followed by gradlew publishAllPublicationsToMavenRepository --no-build-cache
  • Grab contents of rootProject/build/repo/
  • Rename all files that have timestamps replacing timestamp with a constant.
    Test matrix:
  • I repeated this on master with JAVA_HOME=JDK11, JAVA_HOME=JDK17.
  • and on the branch with JAVA_HOME=JDK11, JAVA_HOME=JDK17.
  • and on the branch with JAVA_HOME=JDK17 + -Pmockito.test.java=11

The changes all looked expected. Diffs were:

  • javadoc timestamps
  • Maven metadata (SNAPSHOT timestamps and artifact order)
  • Java 11 and 17 generate the same decompiled classes, but different class files and constant pools. This is on master already.

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

It also needs more hacky code than benefits.
Builds will be faster too.
…n project() objects.

Even if it was, a repositories {} inside a build.gradle file doesn't override, it appends (confirmed with `println(repositories.collect())` before and after the block; so globally declared repos might win in resolution.
imports
plugins { }
apply from:
description
dependencies
... everything else

and make plugin syntax consistent.

Also fix ordering dependency on description being set before including a file.
Change: junitJupiterExtensionTest and junitJupiterInlineMockMakerExtensionTest had the javadoc task enabled.
Change: memory-test, osgi-test, junitJupiterExtensionTest and junitJupiterInlineMockMakerExtensionTest had no java compatibility declared, now it's 11.
Change: extTest, junitJupiterParallelTest, groovyTest, groovyInlineTest had no java compatibility declared, now it's 11.

Change: extTest, junitJupiterParallelTest, groovyTest, groovyInlineTest, kotlinReleaseCoroutinesTest and kotlinTest had the javadoc task enabled.
@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (69e0a6c) 85.45% compared to head (4c303f9) 85.45%.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #3062   +/-   ##
=========================================
  Coverage     85.45%   85.45%           
  Complexity     2888     2888           
=========================================
  Files           329      329           
  Lines          8801     8801           
  Branches       1093     1093           
=========================================
  Hits           7521     7521           
  Misses          992      992           
  Partials        288      288           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

Awesome. Thanks!

@TimvdLippe TimvdLippe merged commit a7bc931 into mockito:main Jul 15, 2023
13 checks passed
@TWiStErRob TWiStErRob deleted the gradle branch July 16, 2023 22:02
@TWiStErRob TWiStErRob mentioned this pull request Jul 16, 2023
8 tasks
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.

None yet

3 participants