When using JMH Gradle Plugin 0.6.5 with Gradle 7.2 and configuration on demand, Gradle will complain about a missing dependency of :compileJmhJava to :compileTestJava unless jmh.includeTests has been explicitly set to false or the task dependency has been explicitly declared.
Gradle detected a problem with the following location: '/path/to/gradle-jmh-config-cache/build/classes/java/test'. Reason: Task ':compileJmhJava' uses this output of task ':compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Expected behavior:
When jmh.includeTests is true (default), the JMH Gradle Plugin should add the task dependency itself.
Details:
Gradle version details
```
# ./gradlew --version
------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------
Build time: 2021-08-17 09:59:03 UTC
Revision: a773786b58bb28710e3dc96c4d1a7063628952ad
Kotlin: 1.5.21
Groovy: 3.0.8
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.11 (Azul Systems, Inc. 11.0.11+9-LTS)
OS: Mac OS X 11.5 x86_64
```
Example Project
`build.gradle`
```groovy
plugins {
id 'java'
id "me.champeau.jmh" version "0.6.5"
}
repositories {
mavenCentral()
}
```
`src/test/java/com/example/Holder.java`
```java
package com.example;
public class Holder {
public int a = 1;
public int b = 2;
public int sum;
}
```
`./src/jmh/java/com/example/SimpleBenchmark.java`
```java
package com.example;
import org.openjdk.jmh.annotations.*;
public class SimpleBenchmark {
@State(Scope.Thread)
public static class BenchmarkState {
Holder holder = new Holder();
public BenchmarkState() {
holder.a = 1;
holder.b = 2;
}
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
@Fork(value = 1, warmups = 0)
public void testMethod(BenchmarkState state) {
state.holder.sum = state.holder.a + state.holder.b;
}
}
```
Output of Gradle 7.2:
```text
# ./gradlew --configure-on-demand --warning-mode all compileTestJava compileJmhJava
Configuration on demand is an incubating feature.
> Task :compileJmhJava
Execution optimizations have been disabled for task ':compileJmhJava' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/path/to/gradle-jmh-config-cache/build/classes/java/test'. Reason: Task ':compileJmhJava' uses this output of task ':compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: '/path/to/gradle-jmh-config-cache/build/classes/java/test'. Reason: Task ':compileJmhJava' uses this output of task ':compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
```
When using JMH Gradle Plugin 0.6.5 with Gradle 7.2 and configuration on demand, Gradle will complain about a missing dependency of
:compileJmhJava
to:compileTestJava
unlessjmh.includeTests
has been explicitly set tofalse
or the task dependency has been explicitly declared.Expected behavior: When
jmh.includeTests
istrue
(default), the JMH Gradle Plugin should add the task dependency itself.Details:
Gradle version details
``` # ./gradlew --version ------------------------------------------------------------ Gradle 7.2 ------------------------------------------------------------ Build time: 2021-08-17 09:59:03 UTC Revision: a773786b58bb28710e3dc96c4d1a7063628952ad Kotlin: 1.5.21 Groovy: 3.0.8 Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020 JVM: 11.0.11 (Azul Systems, Inc. 11.0.11+9-LTS) OS: Mac OS X 11.5 x86_64 ```Example Project
`build.gradle` ```groovy plugins { id 'java' id "me.champeau.jmh" version "0.6.5" } repositories { mavenCentral() } ``` `src/test/java/com/example/Holder.java` ```java package com.example; public class Holder { public int a = 1; public int b = 2; public int sum; } ``` `./src/jmh/java/com/example/SimpleBenchmark.java` ```java package com.example; import org.openjdk.jmh.annotations.*; public class SimpleBenchmark { @State(Scope.Thread) public static class BenchmarkState { Holder holder = new Holder(); public BenchmarkState() { holder.a = 1; holder.b = 2; } } @Benchmark @BenchmarkMode(Mode.Throughput) @Fork(value = 1, warmups = 0) public void testMethod(BenchmarkState state) { state.holder.sum = state.holder.a + state.holder.b; } } ``` Output of Gradle 7.2: ```text # ./gradlew --configure-on-demand --warning-mode all compileTestJava compileJmhJava Configuration on demand is an incubating feature. > Task :compileJmhJava Execution optimizations have been disabled for task ':compileJmhJava' to ensure correctness due to the following reasons: - Gradle detected a problem with the following location: '/path/to/gradle-jmh-config-cache/build/classes/java/test'. Reason: Task ':compileJmhJava' uses this output of task ':compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. Gradle detected a problem with the following location: '/path/to/gradle-jmh-config-cache/build/classes/java/test'. Reason: Task ':compileJmhJava' uses this output of task ':compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details. ```