Skip to content

Commit

Permalink
upgrade to gradle 8.1-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Mar 22, 2023
1 parent 891095b commit c8ed5e8
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down
2 changes: 1 addition & 1 deletion caffeine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions caffeine/testing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 {
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions gradle/codeQuality.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
Expand All @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author ben.manes@gmail.com (Ben Manes)
*/
@SuppressWarnings("serial")
final class JCacheEntryEvent<K, V> extends CacheEntryEvent<K, V>
implements Iterable<CacheEntryEvent<? extends K, ? extends V>> {
private static final long serialVersionUID = 1L;
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dependencyResolutionManagement.repositories {
mavenCentral()
}

enableFeaturePreview 'STABLE_CONFIGURATION_CACHE'
rootProject.name = 'caffeine'

include 'caffeine'
Expand Down
68 changes: 46 additions & 22 deletions simulator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> maximumSizes = []
@Input @Option(option = 'metric', description = 'The metric to compare')
Expand All @@ -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<String, String> systemProperties
@Input
List<String> 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('<Long>[,<Long>...]')} is required")
logger.error("\t${yellow('--maximumSize=')}${italic('<Long>[,<Long>...]')} is required")
return
}
def reports = [:]
Expand All @@ -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',
Expand All @@ -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}"
}
Expand All @@ -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
Expand All @@ -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 }
}
Expand All @@ -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(',')
Expand All @@ -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 }
}

0 comments on commit c8ed5e8

Please sign in to comment.