diff --git a/build.gradle b/build.gradle index 797d192715..24c2294996 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ buildscript { repositories { mavenLocal() //for local testing of mockito-release-tools google() - maven { url 'https://plugins.gradle.org/m2/' } + gradlePluginPortal() } dependencies { @@ -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" } } @@ -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' @@ -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 diff --git a/gradle/java-library.gradle b/gradle/java-library.gradle index d6a9c175b8..71a3d4bd60 100644 --- a/gradle/java-library.gradle +++ b/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" diff --git a/gradle/java-publication.gradle b/gradle/java-publication.gradle index 4fe0103dfb..c6ef90c3a7 100644 --- a/gradle/java-publication.gradle +++ b/gradle/java-publication.gradle @@ -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 } @@ -48,7 +48,7 @@ publishing { from components.javaPlatform } - artifactId = project.archivesBaseName + artifactId = project.base.archivesName.get() pom { name = artifactId diff --git a/gradle/license.gradle b/gradle/license.gradle index f6eb52d899..d01c2e76bc 100644 --- a/gradle/license.gradle +++ b/gradle/license.gradle @@ -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) } } diff --git a/gradle/mockito-core/osgi.gradle b/gradle/mockito-core/osgi.gradle index f950f98de2..4403365ed2 100644 --- a/gradle/mockito-core/osgi.gradle +++ b/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', diff --git a/gradle/root/coverage.gradle b/gradle/root/coverage.gradle index 4b9b041113..2aee7f3988 100644 --- a/gradle/root/coverage.gradle +++ b/gradle/root/coverage.gradle @@ -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}" } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832f0..033e24c4cd 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 03ca076c8a..a7c2bd1bdc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/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 diff --git a/gradlew b/gradlew index a69d9cb6c2..fcb6fca147 100755 --- a/gradlew +++ b/gradlew @@ -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/. @@ -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 @@ -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 @@ -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 diff --git a/gradlew.bat b/gradlew.bat index f127cfd49d..93e3f59f13 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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% diff --git a/settings.gradle.kts b/settings.gradle.kts index a0a66b7764..dbe6fcb84f 100644 --- a/settings.gradle.kts +++ b/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", diff --git a/subprojects/bom/bom.gradle b/subprojects/bom/bom.gradle index 3582cfa78b..d91f0a92a8 100644 --- a/subprojects/bom/bom.gradle +++ b/subprojects/bom/bom.gradle @@ -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" diff --git a/subprojects/inlineTest/inlineTest.gradle b/subprojects/inlineTest/inlineTest.gradle index 4cc6726c5a..6130b556da 100644 --- a/subprojects/inlineTest/inlineTest.gradle +++ b/subprojects/inlineTest/inlineTest.gradle @@ -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 @@ -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' } diff --git a/subprojects/junit-jupiter/junit-jupiter.gradle b/subprojects/junit-jupiter/junit-jupiter.gradle index cbd25d34ab..26543df240 100644 --- a/subprojects/junit-jupiter/junit-jupiter.gradle +++ b/subprojects/junit-jupiter/junit-jupiter.gradle @@ -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', @@ -38,9 +38,9 @@ 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)"') } @@ -48,8 +48,8 @@ def osgiProperties = tasks.register('osgiProperties', WriteProperties) { // 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 } diff --git a/subprojects/junitJupiterExtensionTest/junitJupiterExtensionTest.gradle.kts b/subprojects/junitJupiterExtensionTest/junitJupiterExtensionTest.gradle.kts index 98d44d43f6..82a1ab4280 100644 --- a/subprojects/junitJupiterExtensionTest/junitJupiterExtensionTest.gradle.kts +++ b/subprojects/junitJupiterExtensionTest/junitJupiterExtensionTest.gradle.kts @@ -9,9 +9,9 @@ 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") { @@ -19,7 +19,7 @@ tasks.named("test") { } val Project.libraries - get() = rootProject.extra["libraries"] as Map + get() = @Suppress("UNCHECKED_CAST") (rootProject.extra["libraries"] as Map) fun Project.library(name: String) = libraries[name]!! diff --git a/subprojects/junitJupiterInlineMockMakerExtensionTest/junitJupiterInlineMockMakerExtensionTest.gradle.kts b/subprojects/junitJupiterInlineMockMakerExtensionTest/junitJupiterInlineMockMakerExtensionTest.gradle.kts index 442c64f0e9..dbdd389b1e 100644 --- a/subprojects/junitJupiterInlineMockMakerExtensionTest/junitJupiterInlineMockMakerExtensionTest.gradle.kts +++ b/subprojects/junitJupiterInlineMockMakerExtensionTest/junitJupiterInlineMockMakerExtensionTest.gradle.kts @@ -9,9 +9,9 @@ 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") { @@ -19,7 +19,7 @@ tasks.named("test") { } val Project.libraries - get() = rootProject.extra["libraries"] as Map + get() = @Suppress("UNCHECKED_CAST") (rootProject.extra["libraries"] as Map) fun Project.library(name: String) = libraries[name]!! diff --git a/subprojects/junitJupiterParallelTest/junitJupiterParallelTest.gradle b/subprojects/junitJupiterParallelTest/junitJupiterParallelTest.gradle index 5db1c32702..2a1e8e9910 100644 --- a/subprojects/junitJupiterParallelTest/junitJupiterParallelTest.gradle +++ b/subprojects/junitJupiterParallelTest/junitJupiterParallelTest.gradle @@ -8,6 +8,7 @@ dependencies { testImplementation libraries.junitJupiterApi testImplementation project(":junit-jupiter") testRuntimeOnly libraries.junitJupiterEngine + testRuntimeOnly libraries.junitPlatformLauncher } test { diff --git a/subprojects/kotlinReleaseCoroutinesTest/kotlinReleaseCoroutinesTest.gradle b/subprojects/kotlinReleaseCoroutinesTest/kotlinReleaseCoroutinesTest.gradle index 284b3bdfb7..2ac86f00c1 100644 --- a/subprojects/kotlinReleaseCoroutinesTest/kotlinReleaseCoroutinesTest.gradle +++ b/subprojects/kotlinReleaseCoroutinesTest/kotlinReleaseCoroutinesTest.gradle @@ -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 { diff --git a/subprojects/kotlinTest/kotlinTest.gradle b/subprojects/kotlinTest/kotlinTest.gradle index 99397def9f..adb3b8056b 100644 --- a/subprojects/kotlinTest/kotlinTest.gradle +++ b/subprojects/kotlinTest/kotlinTest.gradle @@ -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 { diff --git a/subprojects/module-test/module-test.gradle b/subprojects/module-test/module-test.gradle index d38a32c7d1..8ef84af11d 100644 --- a/subprojects/module-test/module-test.gradle +++ b/subprojects/module-test/module-test.gradle @@ -14,5 +14,7 @@ dependencies { tasks.javadoc.enabled = false -sourceCompatibility = 11 -targetCompatibility = 11 +java { + sourceCompatibility = 11 + targetCompatibility = 11 +} diff --git a/subprojects/osgi-test/osgi-test-bundles.gradle b/subprojects/osgi-test/osgi-test-bundles.gradle index 49ba81b70a..608f9727b8 100644 --- a/subprojects/osgi-test/osgi-test-bundles.gradle +++ b/subprojects/osgi-test/osgi-test-bundles.gradle @@ -34,8 +34,10 @@ task otherBundle(type: Bundle) { tasks.withType(Bundle) { archiveAppendix = name - bnd = """ -Bundle-SymbolicName: $name --exportcontents: * -""" + bundle { // this: BundleTaskExtension + bnd = """ + Bundle-SymbolicName: $name + -exportcontents: * + """.stripIndent() + } } diff --git a/subprojects/osgi-test/osgi-test.gradle b/subprojects/osgi-test/osgi-test.gradle index 0861fd7f46..fcd02fb493 100644 --- a/subprojects/osgi-test/osgi-test.gradle +++ b/subprojects/osgi-test/osgi-test.gradle @@ -55,6 +55,6 @@ class RuntimeBundlesProvider implements CommandLineArgumentProvider { @Override Iterable asArguments() { String[] absolutePaths = files.stream().map {it.absolutePath}.toArray() - ["-DtestRuntimeBundles=${CollectionUtils.join(File.pathSeparator, absolutePaths)}".toString()] + ["-DtestRuntimeBundles=${absolutePaths.join(File.pathSeparator)}".toString()] } } diff --git a/subprojects/programmatic-test/programmatic-test.gradle b/subprojects/programmatic-test/programmatic-test.gradle index 39db6c6442..44e158ab5f 100644 --- a/subprojects/programmatic-test/programmatic-test.gradle +++ b/subprojects/programmatic-test/programmatic-test.gradle @@ -14,8 +14,10 @@ dependencies { tasks.javadoc.enabled = false -sourceCompatibility = 11 -targetCompatibility = 11 +java { + sourceCompatibility = 11 + targetCompatibility = 11 +} test { forkEvery = 1