Skip to content

Commit

Permalink
Upgrade Gradle to 8.2 (#3051)
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob committed Jul 4, 2023
1 parent da0abbe commit b2e7541
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 74 deletions.
24 changes: 3 additions & 21 deletions build.gradle
Expand Up @@ -2,7 +2,7 @@ buildscript {
repositories {
mavenLocal() //for local testing of mockito-release-tools
google()
maven { url 'https://plugins.gradle.org/m2/' }
gradlePluginPortal()
}

dependencies {
Expand All @@ -14,7 +14,7 @@ buildscript {
classpath 'org.shipkit:shipkit-auto-version:1.2.2'

classpath 'com.google.googlejavaformat:google-java-format:1.17.0'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22"
}
}
Expand All @@ -30,7 +30,7 @@ plugins {
description = 'Mockito mock objects library core API and implementation'

apply plugin: 'base'
archivesBaseName = 'mockito-core'
base.archivesName = 'mockito-core'

apply from: 'gradle/shipkit.gradle'

Expand Down Expand Up @@ -136,21 +136,3 @@ spotless {
targetExclude 'src/test/java/org/mockitousage/internal/junit/UnusedStubbingsFinderTest.java'
}
}


//workaround for #1444, delete when Shipkit bug is fixed
subprojects {
eclipse {
project {
name = rootProject.name + '-' + project.name
}
}

afterEvaluate {
def lib = publishing.publications.javaLibrary
if(lib && !lib.artifactId.startsWith("mockito-")) {
lib.artifactId = "mockito-" + lib.artifactId
}
}
}
//end workaround
16 changes: 9 additions & 7 deletions gradle/java-library.gradle
@@ -1,21 +1,23 @@
apply plugin: "java"
apply plugin: "java-library"

if (!archivesBaseName.startsWith("mockito-")) {
archivesBaseName = "mockito-" + project.name
if (!base.archivesName.get().startsWith("mockito-")) {
base.archivesName = "mockito-" + project.name
}

apply from: "$rootDir/gradle/java-publication.gradle"

generatePomFileForJavaLibraryPublication.doLast {
//validates the the pom has correct artifact id to avoid issues like #1444
def pom = new XmlSlurper().parse(destination)
assert pom.artifactId == archivesBaseName
assert pom.name == archivesBaseName
def pom = new groovy.xml.XmlSlurper().parse(destination)
assert pom.artifactId == base.archivesName.get()
assert pom.name == base.archivesName.get()
}

sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = 11
targetCompatibility = 11
}

test {
include "**/*Test.class"
Expand Down
6 changes: 3 additions & 3 deletions gradle/java-publication.gradle
Expand Up @@ -8,13 +8,13 @@ plugins.withId("java") {
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
with licenseSpec
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from tasks.javadoc
with licenseSpec
}
Expand Down Expand Up @@ -48,7 +48,7 @@ publishing {
from components.javaPlatform
}

artifactId = project.archivesBaseName
artifactId = project.base.archivesName.get()

pom {
name = artifactId
Expand Down
6 changes: 6 additions & 0 deletions gradle/license.gradle
Expand Up @@ -11,6 +11,12 @@ allprojects {
java = 'SLASHSTAR_STYLE'
groovy = 'SLASHSTAR_STYLE'
}

exclude "junit-platform.properties"
exclude "mockito-extensions/org.mockito.plugins.*"
exclude "META-INF/services/org.junit.jupiter.api.extension.Extension"
exclude "org/mockito/internal/util/concurrent/README.md"
exclude "org/mockito/internal/util/concurrent/LICENSE"
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
}
4 changes: 2 additions & 2 deletions gradle/mockito-core/osgi.gradle
@@ -1,8 +1,8 @@
apply plugin: 'biz.aQute.bnd.builder'

jar {
classpath = project.configurations.compileClasspath
bundle {
bundle { // this: BundleTaskExtension
classpath = project.configurations.compileClasspath
bnd(
'Bundle-Name': 'Mockito Mock Library for Java. Core bundle requires Byte Buddy and Objenesis.',
'Bundle-SymbolicName': 'org.mockito.mockito-core',
Expand Down
5 changes: 3 additions & 2 deletions gradle/root/coverage.gradle
Expand Up @@ -37,11 +37,12 @@ task mockitoCoverage(type: JacocoReport) {
reports {
xml.required = true
html.required = true
html.destination file("${buildDir}/jacocoHtml")
html.outputLocation = file("${buildDir}/jacocoHtml")
}

doLast {
logger.lifecycle "Jacoco HTML created: file://${new File(reports.html.destination, "index.html").toURI().path}"
def reportFile = new File(reports.html.outputLocation.get().asFile, "index.html")
logger.lifecycle "Jacoco HTML created: file://${reportFile.toURI().path}"
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionSha256Sum=38f66cd6eef217b4c35855bb11ea4e9fbc53594ccccb5fb82dfd317ef8c2c5a3
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
24 changes: 16 additions & 8 deletions gradlew
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +130,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
@@ -1,5 +1,5 @@
plugins {
id("com.gradle.enterprise").version("3.3.4")
id("com.gradle.enterprise").version("3.13.4")
}

include("subclass",
Expand Down
4 changes: 2 additions & 2 deletions subprojects/bom/bom.gradle
Expand Up @@ -4,8 +4,8 @@ plugins {

description = "Mockito Bill of Materials (BOM)"

if (!archivesBaseName.startsWith("mockito-")) {
archivesBaseName = "mockito-" + project.name
if (!base.archivesName.get().startsWith("mockito-")) {
base.archivesName = "mockito-" + project.name
}

apply from: "$rootDir/gradle/java-publication.gradle"
Expand Down
17 changes: 14 additions & 3 deletions subprojects/inlineTest/inlineTest.gradle
Expand Up @@ -6,8 +6,10 @@ description = "Mockito preconfigured inline mock maker (intermediate and to be s

apply from: "$rootDir/gradle/dependencies.gradle"

sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = 11
targetCompatibility = 11
}

dependencies {
implementation project.rootProject
Expand All @@ -18,7 +20,16 @@ dependencies {
tasks.javadoc.enabled = false

test {
jvmArgs '--illegal-access=deny'
if (JavaVersion.VERSION_17 <= JavaVersion.current()) {
// For Java 17: https://openjdk.org/jeps/403
// > Ignoring option --illegal-access=deny; support was removed in 17.0
} else if (JavaVersion.VERSION_16 <= JavaVersion.current()) {
// For Java 16: https://openjdk.org/jeps/396
// --illegal-access=deny is the default.
} else if (JavaVersion.VERSION_1_9 <= JavaVersion.current()) {
// For Java 9-15: https://openjdk.org/jeps/261#Relaxed-strong-encapsulation
jvmArgs '--illegal-access=deny'
}
//required by the "StressTest.java" and "OneLinerStubStressTest.java"
maxHeapSize '256m'
}
12 changes: 6 additions & 6 deletions subprojects/junit-jupiter/junit-jupiter.gradle
Expand Up @@ -18,8 +18,8 @@ tasks.withType(Test) {
}

jar {
classpath = project.configurations.runtimeClasspath
bundle {
bundle { // this: BundleTaskExtension
classpath = project.configurations.runtimeClasspath
bnd(
'Bundle-Name': 'Mockito Extension Library for JUnit 5.',
'Bundle-SymbolicName': 'org.mockito.junit-jupiter',
Expand All @@ -38,18 +38,18 @@ jar {
// task writes out the properties necessary for it to verify the OSGi
// metadata.
def osgiProperties = tasks.register('osgiProperties', WriteProperties) {
outputFile = layout.getBuildDirectory().file("verifyOSGiProperties.bndrun")
destinationFile = layout.buildDirectory.file("verifyOSGiProperties.bndrun")
property('-standalone', true)
property('-runee', "JavaSE-${targetCompatibility}")
property('-runee', "JavaSE-${java.targetCompatibility}")
property('-runrequires', 'osgi.identity;filter:="(osgi.identity=org.mockito.junit-jupiter)"')
}

// Bnd's Resolve task is what verifies that a jar can be used in OSGi and
// that its metadata is valid. If the metadata is invalid this task will
// fail.
def verifyOSGi = tasks.register('verifyOSGi', Resolve) {
getBndrun().fileProvider(osgiProperties.map { it.outputFile })
getOutputBndrun().set(layout.getBuildDirectory().file("resolvedOSGiProperties.bndrun"))
getBndrun().value(osgiProperties.flatMap { it.destinationFile })
getOutputBndrun().set(layout.buildDirectory.file("resolvedOSGiProperties.bndrun"))
reportOptional = false
}

Expand Down
Expand Up @@ -9,17 +9,17 @@ description = "End-to-end tests for automatic registration of MockitoExtension."
dependencies {
testImplementation(project(":junit-jupiter"))
testImplementation(library("assertj"))
testImplementation(library("junitPlatformLauncher"))
testImplementation(library("junitJupiterApi"))
testRuntimeOnly(library("junitJupiterEngine"))
testRuntimeOnly(library("junitPlatformLauncher"))
}

tasks.named<Test>("test") {
useJUnitPlatform()
}

val Project.libraries
get() = rootProject.extra["libraries"] as Map<String, Any>
get() = @Suppress("UNCHECKED_CAST") (rootProject.extra["libraries"] as Map<String, Any>)

fun Project.library(name: String) =
libraries[name]!!
Expand Up @@ -9,17 +9,17 @@ description = "End-to-end tests for automatic registration of MockitoExtension w
dependencies {
testImplementation(project(":junit-jupiter"))
testImplementation(library("assertj"))
testImplementation(library("junitPlatformLauncher"))
testImplementation(library("junitJupiterApi"))
testRuntimeOnly(library("junitJupiterEngine"))
testRuntimeOnly(library("junitPlatformLauncher"))
}

tasks.named<Test>("test") {
useJUnitPlatform()
}

val Project.libraries
get() = rootProject.extra["libraries"] as Map<String, Any>
get() = @Suppress("UNCHECKED_CAST") (rootProject.extra["libraries"] as Map<String, Any>)

fun Project.library(name: String) =
libraries[name]!!
Expand Up @@ -8,6 +8,7 @@ dependencies {
testImplementation libraries.junitJupiterApi
testImplementation project(":junit-jupiter")
testRuntimeOnly libraries.junitJupiterEngine
testRuntimeOnly libraries.junitPlatformLauncher
}

test {
Expand Down
Expand Up @@ -20,8 +20,10 @@ repositories {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}

sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = 11
targetCompatibility = 11
}

tasks.withType(KotlinCompile).configureEach {
compilerOptions {
Expand Down
6 changes: 4 additions & 2 deletions subprojects/kotlinTest/kotlinTest.gradle
Expand Up @@ -10,8 +10,10 @@ description = "Kotlin tests for Mockito."

apply from: "$rootDir/gradle/dependencies.gradle"

sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = 11
targetCompatibility = 11
}

tasks.withType(KotlinCompile).configureEach {
compilerOptions {
Expand Down
6 changes: 4 additions & 2 deletions subprojects/module-test/module-test.gradle
Expand Up @@ -14,5 +14,7 @@ dependencies {

tasks.javadoc.enabled = false

sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = 11
targetCompatibility = 11
}

0 comments on commit b2e7541

Please sign in to comment.