diff --git a/build.gradle b/build.gradle index 095b98a5..0c29473e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,7 @@ import com.diffplug.gradle.spotless.JavaExtension - -buildscript { - dependencies { - classpath 'org.revapi:gradle-revapi:1.8.0' - } -} - plugins { id 'java-library' - id 'me.champeau.mrjar' version "0.1.1" id 'jacoco' id 'me.champeau.jmh' version '0.7.2' id 'org.sonarqube' version '5.1.0.4882' @@ -18,10 +10,9 @@ plugins { id 'signing' id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' id 'net.ltgt.errorprone' version '4.1.0' + id "org.revapi.revapi-gradle-plugin" version "1.8.0" } -apply plugin: 'org.revapi.revapi-gradle-plugin' - repositories { mavenCentral() gradlePluginPortal() @@ -40,13 +31,106 @@ dependencies { testImplementation group: 'com.appmattus.crypto', name: 'cryptohash', version: '1.0.2' testImplementation group: 'org.greenrobot', name: 'essentials', version: '3.1.0' testImplementation group: 'com.sangupta', name: 'murmur', version: '1.0.0' - errorprone group:'com.google.errorprone',name:'error_prone_core', version: '2.31.0' // upgrade not possible as >= 2.32.0 requires java >= 17 and the multi-release plugin me.champeau.mrjar is not able to use java 17 for java 11 compilation, see https://github.com/melix/mrjar-gradle-plugin/issues/7 + errorprone group:'com.google.errorprone',name:'error_prone_core', version: '2.36.0' +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } + withJavadocJar() + withSourcesJar() +} + + +sourceSets { + jmh + main + test + java21 { + java { + srcDir 'src/main/java21' + } + dependencies { + // add Java 21 dependencies here to make them available for Java 21 code + } + // include main source code to make it accessible from Java 21 + compileClasspath += sourceSets.main.output + runtimeClasspath += sourceSets.main.output + } + java21Test { + java { + srcDir 'src/test/java21' + } + dependencies { + // add Java 21 dependencies here to make them available for Java 21 code + } + // include test source code to make it accessible from Java 21 + compileClasspath += sourceSets.test.output + runtimeClasspath += sourceSets.test.output + } +} + +jar { + dependsOn 'compileJava21Java' + into('META-INF/versions/21') { + from sourceSets.java21.output + } + manifest { + attributes 'Multi-Release': 'true' + } +} + +tasks.compileJava { + options.release.set(11) +} + +tasks.compileTestJava { + options.release.set(11) +} + +tasks.compileJava21Java { + options.release.set(21) +} +tasks.compileJava21TestJava { + options.release.set(21) +} + +tasks.test { + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(11) + } +} + +tasks.register("java21Test", Test) { + // compare https://github.com/melix/mrjar-gradle-plugin/blob/dac99aadd451e3c2176aa6e13af7ad39e20c2cb9/plugin/src/main/java/me/champeau/mrjar/MultiReleaseExtension.java group=LifecycleBasePlugin.VERIFICATION_GROUP + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(21) + } + // run Java 21 specific and generic tests + testClassesDirs = sourceSets.java21Test.output + sourceSets.test.output + classpath = files(jar) + sourceSets.java21Test.runtimeClasspath + sourceSets.test.runtimeClasspath } -multiRelease { - targetVersions 11, 21 +tasks.check { + dependsOn(java21Test) } +tasks.withType(Test).configureEach { + useJUnitPlatform() + maxHeapSize '8g' +} + +tasks.withType(JavaCompile).configureEach { + options.compilerArgs << "-Werror" + options.errorprone.disableWarningsInGeneratedCode = false + // options.errorprone.enabled = false +} + +group = 'com.dynatrace.hash4j' +version = '0.18.0' + + static def readJavaLicense(licenseName) { File licenseFile = new File('licenses/' + licenseName + '.txt') def line @@ -83,20 +167,11 @@ static def readPythonLicense(licenseName) { return s } -java { - withJavadocJar() - withSourcesJar() -} - -group = 'com.dynatrace.hash4j' -version = '0.18.0' - - spotless { - def googleJavaFormatVersion = '1.23.0' - def eclipseCdtVersion = '11.3' - def blackVersion = '24.4.2' - def greclipseVersion = '4.29' + def googleJavaFormatVersion = '1.25.0' + def eclipseCdtVersion = '11.6' + def blackVersion = '24.10.0' + def greclipseVersion = '4.32' ratchetFrom 'origin/main' apply plugin: 'groovy' @@ -302,12 +377,6 @@ tasks.copyBenchmarkReport.dependsOn checkStatusForBenchmarks tasks.simulateHyperLogLogEstimationErrors.finalizedBy evaluateEstimationErrors tasks.simulateUltraLogLogEstimationErrors.finalizedBy evaluateEstimationErrors -sourceSets { - jmh - main - test -} - javadoc { failOnError true title 'hash4j ' + project.version + ' API' @@ -388,17 +457,6 @@ nexusPublishing { } } -tasks.withType(Test).configureEach { - useJUnitPlatform() - maxHeapSize '8g' -} - -tasks.withType(JavaCompile).configureEach { - options.compilerArgs << "-Werror" - options.errorprone.disableWarningsInGeneratedCode = false - // options.errorprone.enabled = false -} - if (file("extra-configuration.gradle").exists()) { apply from: 'extra-configuration.gradle' } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136..2c352119 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 09523c0e..e2847c82 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf13..f5feea6d 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30db..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/requirements.txt b/requirements.txt index 371fd1bc..6d83d490 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -black==24.3.0 +black==24.10.0 click==8.1.7 GitPython==3.1.41 matplotlib==3.8.2 diff --git a/src/main/java/com/dynatrace/hash4j/distinctcount/UltraLogLog.java b/src/main/java/com/dynatrace/hash4j/distinctcount/UltraLogLog.java index 3ddb113e..b6f77ca3 100644 --- a/src/main/java/com/dynatrace/hash4j/distinctcount/UltraLogLog.java +++ b/src/main/java/com/dynatrace/hash4j/distinctcount/UltraLogLog.java @@ -534,8 +534,8 @@ static double calculateTheoreticalRelativeStandardError(int p) { 5.059288069986326E14, 2.3575295235667005E15, 1.0985627213141412E16, - 5.1190876745155888E16, - 2.38539483395717152E17 + 5.119087674515589E16, + 2.3853948339571715E17 }; static final double[] REGISTER_CONTRIBUTIONS = {