diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml index 1722a7e888..7b7beaf15f 100644 --- a/.github/workflows/dependency-check.yml +++ b/.github/workflows/dependency-check.yml @@ -29,7 +29,7 @@ jobs: uses: ./.github/actions/run-gradle with: java: ${{ env.JAVA_VERSION }} - arguments: dependencyCheckAggregate + arguments: dependencyCheckAggregate --no-configuration-cache - name: Check file existence id: check_files uses: andstor/file-existence-action@v2 diff --git a/build.gradle b/build.gradle index e8d4be5083..fb4b79c4df 100644 --- a/build.gradle +++ b/build.gradle @@ -41,12 +41,10 @@ allprojects { } dependencies { - def ignored = [ - 'api', 'apiElements', 'archives', 'compileClasspath', 'compileOnlyApi', 'default', - 'implementation', 'javadocElements', 'runtimeClasspath', 'runtimeElements', 'runtimeOnly', - 'sourcesElements', 'testCompileClasspath', 'testRuntimeClasspath'] + def ignored = ['api', 'compileOnlyApi', 'implementation', + 'javadocElements', 'runtimeOnly', 'sourcesElements'] configurations.configureEach { configuration -> - if (name !in ignored) { + if ((name !in ignored) && configuration.canBeDeclaredAgainst) { restrictions.each { module, version -> constraints.add(configuration.name, module).version { require version } } diff --git a/caffeine/build.gradle b/caffeine/build.gradle index 7f18b31ced..77b2435869 100644 --- a/caffeine/build.gradle +++ b/caffeine/build.gradle @@ -159,7 +159,7 @@ tasks.register('memoryOverhead', JavaExec) { classpath sourceSets.jmh.runtimeClasspath classpath sourceSets.codeGen.runtimeClasspath mainClass = 'com.github.benmanes.caffeine.cache.MemoryBenchmark' - jvmArgs += [ + jvmArgs [ '--add-opens', 'java.base/java.util.concurrent.atomic=ALL-UNNAMED', '--add-opens', 'java.base/java.util.concurrent.locks=ALL-UNNAMED', '--add-opens', 'java.base/java.util.concurrent=ALL-UNNAMED', diff --git a/caffeine/testing.gradle b/caffeine/testing.gradle index 88b714d641..2cc9031519 100644 --- a/caffeine/testing.gradle +++ b/caffeine/testing.gradle @@ -86,7 +86,7 @@ tasks.withType(Test).configureEach { maxHeapSize = '3g' } else if (name.startsWith('lincheck')) { options.includeGroups = ['lincheck'] - jvmArgs += [ + jvmArgs [ '--add-opens', 'java.base/jdk.internal.vm=ALL-UNNAMED', '--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED', '--add-opens', 'java.base/jdk.internal.access=ALL-UNNAMED', @@ -109,12 +109,13 @@ tasks.withType(Test).configureEach { class Stresser extends DefaultTask { @Input @Optional @Option(option = 'workload', description = 'The workload type') String operation + @InputFiles @Classpath + FileCollection classpath @TaskAction def run() { project.javaexec { mainClass = 'com.github.benmanes.caffeine.cache.Stresser' - classpath project.sourceSets.codeGen.runtimeClasspath - classpath project.sourceSets.test.runtimeClasspath + classpath this.classpath if (operation) { args '--workload', operation } else { @@ -126,8 +127,7 @@ class Stresser extends DefaultTask { tasks.register('stress', Stresser) { group = 'Cache tests' description = 'Executes a stress test' - notCompatibleWithConfigurationCache( - "The ${name} task is not compatible with the configuration cache") + classpath = sourceSets.codeGen.runtimeClasspath + sourceSets.test.runtimeClasspath outputs.upToDateWhen { false } dependsOn compileTestJava } diff --git a/gradle.properties b/gradle.properties index 68a882a746..4c4f5885d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx2g -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError org.gradle.java.installations.fromEnv=JDK_CI -org.gradle.unsafe.configuration-cache=true +org.gradle.configuration-cache=true org.gradle.configureondemand=true org.gradle.parallel=true org.gradle.caching=true diff --git a/gradle/codeQuality.gradle b/gradle/codeQuality.gradle index 142efad56b..14293a3cbc 100644 --- a/gradle/codeQuality.gradle +++ b/gradle/codeQuality.gradle @@ -129,7 +129,7 @@ def JVM_ARGS_STRONG_ENCAPSULATION = [ ] tasks.withType(JavaExec).configureEach { - jvmArgs += JVM_ARGS_STRONG_ENCAPSULATION + jvmArgs JVM_ARGS_STRONG_ENCAPSULATION javaLauncher = javaToolchains.launcherFor { languageVersion = java.toolchain.languageVersion } @@ -227,8 +227,6 @@ tasks.matching { it.name.startsWith('forbiddenApis') }.configureEach { } tasks.matching { it.name.startsWith('spotbugs') }.configureEach { - notCompatibleWithConfigurationCache( - "The ${name} task is not compatible with the configuration cache") enabled = System.properties.containsKey('spotbugs') group = 'SpotBugs' reports { diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 0b4efd64b3..7267208d6d 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -84,7 +84,7 @@ ext { osgiUtilFunction: '1.2.0', osgiUtilPromise: '1.3.0', paxExam: '4.13.5', - slf4jTest: '2.8.1', + slf4jTest: '2.9.0', testng: '7.7.1', truth: '1.1.3', ] @@ -107,7 +107,7 @@ ext { sonarqube: '4.0.0.2929', spotbugs: '4.7.3', spotbugsContrib: '7.6.0', - spotbugsPlugin: '5.0.13', + spotbugsPlugin: '5.0.14', versions: '0.46.0', ] platformVersions = [ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7a9e52585e..775f1f1366 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-rc-1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java index defe4c1cc1..be5dde40fa 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java @@ -31,6 +31,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("serial") final class JCacheEntryEvent extends CacheEntryEvent implements Iterable> { private static final long serialVersionUID = 1L; diff --git a/settings.gradle b/settings.gradle index 192dcb7cbf..95d173ff3a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -45,7 +45,6 @@ dependencyResolutionManagement.repositories { mavenCentral() } -enableFeaturePreview 'STABLE_CONFIGURATION_CACHE' rootProject.name = 'caffeine' include 'caffeine' diff --git a/simulator/build.gradle b/simulator/build.gradle index de05e3f686..449f9ec242 100644 --- a/simulator/build.gradle +++ b/simulator/build.gradle @@ -83,14 +83,14 @@ tasks.named('run').configure { } jvmArgs '-XX:+UseParallelGC', '-Xmx4g' - if (project.hasProperty('jvmArgs')) { + if (hasProperty('jvmArgs')) { jvmArgs project.jvmArgs.split(',') } } class Simulate extends DefaultTask { @Input @Optional @Option(option = 'jvmArgs', description = 'The jvm arguments') - String jvmArguments + String jvmOptions @Input @Option(option = 'maximumSize', description = 'The maximum cache sizes') List maximumSizes = [] @Input @Option(option = 'metric', description = 'The metric to compare') @@ -100,14 +100,28 @@ class Simulate extends DefaultTask { @Input @Option(option = 'theme', description = 'The chart theme') String theme = 'light' @OutputDirectory - File reportDir = new File("${project.buildDir}/reports/${name}") + File reportDir + + @Input + Map systemProperties + @Input + List defaultJvmArgs + @InputFiles @Classpath + FileCollection classpath + @Internal + ExecOperations external + + @Inject + public Simulate(ExecOperations external, ProjectLayout layout) { + reportDir = new File(layout.buildDirectory.get().asFile, "/reports/${name}") + this.external = external + } @TaskAction def run() { if (maximumSizes.isEmpty()) { def yellow = { "\033[33m${it}\033[0m" } def italic = { "\033[3m${it}\033[0m" } - project.logger.error( - "\t${yellow('--maximumSize=')}${italic('[,...]')} is required") + logger.error("\t${yellow('--maximumSize=')}${italic('[,...]')} is required") return } def reports = [:] @@ -120,13 +134,13 @@ class Simulate extends DefaultTask { printf 'Running with maximumSize=%,d...%n ', maximumSize def report = "${reportDir}/${baseName}_${maximumSize}.csv" reports[maximumSize] = new File(report) - project.javaexec { - systemProperties project.tasks.run.systemProperties - classpath = project.sourceSets.main.runtimeClasspath - mainClass = project.application.mainClass - jvmArgs project.tasks.run.allJvmArgs - if (jvmArguments) { - jvmArgs jvmArguments.split(',') + external.javaexec { + mainClass = 'com.github.benmanes.caffeine.cache.simulator.Simulator' + systemProperties this.systemProperties + classpath = this.classpath + jvmArgs defaultJvmArgs + if (jvmOptions) { + jvmArgs (jvmOptions.split(',') as List) } systemProperties [ 'caffeine.simulator.report.format': 'csv', @@ -137,9 +151,9 @@ class Simulate extends DefaultTask { } def combinedReport = "${reportDir}/${baseName}.csv" - project.javaexec { + external.javaexec { mainClass = 'com.github.benmanes.caffeine.cache.simulator.report.csv.CombinedCsvReport' - classpath = project.sourceSets.main.runtimeClasspath + classpath = this.classpath reports.each { maximumSize, report -> args '--inputFiles', "${maximumSize}=${report}" } @@ -148,9 +162,9 @@ class Simulate extends DefaultTask { } def chart = "${reportDir}/${baseName}.png" - project.javaexec { + external.javaexec { mainClass = 'com.github.benmanes.caffeine.cache.simulator.report.csv.PlotCsv' - classpath = project.sourceSets.main.runtimeClasspath + classpath = this.classpath args '--inputFile', combinedReport args '--outputFile', chart args '--metric', metric @@ -162,8 +176,9 @@ class Simulate extends DefaultTask { tasks.register('simulate', Simulate) { group 'Application' description 'Runs multiple simulations and generates an aggregate report' - notCompatibleWithConfigurationCache( - "The ${name} task is not compatible with the configuration cache") + systemProperties = tasks.run.systemProperties + classpath = sourceSets.main.runtimeClasspath + defaultJvmArgs = tasks.run.allJvmArgs dependsOn processResources, compileJava outputs.upToDateWhen { false } } @@ -178,9 +193,19 @@ class Rewrite extends DefaultTask { @Input @Optional @Option(option = 'outputFormat', description = 'The trace output format') String outputFormat + @InputFiles @Classpath + FileCollection classpath + @Internal + ExecOperations external + + @Inject + public Rewrite(ExecOperations external) { + this.external = external + } + @TaskAction def run() { - project.javaexec { - classpath = project.sourceSets.main.runtimeClasspath + external.javaexec { + classpath = this.classpath mainClass = 'com.github.benmanes.caffeine.cache.simulator.parser.Rewriter' if (inputFiles) { args '--inputFiles', inputFiles.join(',') @@ -203,8 +228,7 @@ class Rewrite extends DefaultTask { tasks.register('rewrite', Rewrite) { group 'Application' description 'Rewrite traces into the format used by other simulators' - notCompatibleWithConfigurationCache( - "The ${name} task is not compatible with the configuration cache") + classpath = sourceSets.main.runtimeClasspath dependsOn processResources, compileJava outputs.upToDateWhen { false } }