Skip to content

Gradle skips the jmh task when attempting to run the benchmarks again #270

Description

@daniel-rusu

Describe the bug
When I attempt to run the jmh task a second time without making any code changes, Gradle skips running it. That's because Gradle sees that all the dependencies of the jmh task are unchanged so Gradle expects the output of the jmh task to be the same as the previous result and skips it.

To Reproduce

  1. Update some code that the benchmarks use.
  2. Run ./gradlew jmh. This will run the benchmarks successfully.
  3. Attempt to run ./gradlew jmh again without making any changes
  4. Bug: Gradle deems the jmh task as complete and skips it without attempting to run the benchmarks again

My Solution:
I'm not sure how to fix the gradle plugin but in case it helps, I fixed this problem on my end by adding the following to build.gradle.kts:

// Consider the output of the JMH task always out of date to allow running benchmarks again even if no code changed
tasks.withType<me.champeau.jmh.JMHTask> {
    outputs.upToDateWhen { false }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions