Skip to content

Commit 63a1eca

Browse files
committed
testScope param for maven plugin
1 parent 16900be commit 63a1eca

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ The maven goal has several config params:
173173
| `apiPrincipal` | `String` | Will be used once we support multiple users | `null` |
174174
| `apiKey` | `String` | Will be used once we support multiple users | `null` |
175175
| `skip` | `boolean` | if `true` the goal will do nothing | `false` |
176+
| `testScope` | `boolean` | if `true` benchmarks under `src/test/java` will be executed | `true` |
176177
177178
### Testdata from Maven projects
178179

jmh-maven-plugin/src/main/java/com/openelements/benchscape/jmh/maven/JmhMojo.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ public class JmhMojo extends AbstractMojo {
5757
public static final String CLASSPATH_ARG = "-cp";
5858
public static final String JAR_TYPE = "jar";
5959

60-
/**
61-
* If true benchmarks in test scope will be executed (Java classes of benchmarks must be placed under
62-
* {@code src/main/java}).
63-
*/
64-
private boolean benchmarksInTestScope = false;
6560

6661
@Parameter(defaultValue = "${project}", readonly = true)
6762
private MavenProject project;
@@ -72,6 +67,13 @@ public class JmhMojo extends AbstractMojo {
7267
@Parameter(defaultValue = "true")
7368
private boolean writeToFile;
7469

70+
/**
71+
* If true benchmarks in test scope will be executed (Java classes of benchmarks must be placed under
72+
* {@code src/test/java}).
73+
*/
74+
@Parameter(defaultValue = "true")
75+
private boolean testScope;
76+
7577
@Parameter(defaultValue = "${project.build.directory}/jmh-results.json")
7678
private String file;
7779

@@ -157,7 +159,7 @@ private List<String> getClasspathForBenchmarkRun() throws DependencyResolutionRe
157159

158160
final List<String> classpath = new ArrayList<>();
159161
classpath.addAll(project.getRuntimeClasspathElements());
160-
if (benchmarksInTestScope) {
162+
if (testScope) {
161163
classpath.addAll(project.getTestClasspathElements());
162164
}
163165
classpath.addAll(dependencies);
@@ -289,7 +291,7 @@ private List<String> resolveArtifact(@NonNull final String groupId, @NonNull fin
289291
*/
290292
@NonNull
291293
private File getBenchmarkList() {
292-
if (benchmarksInTestScope) {
294+
if (testScope) {
293295
return new File(new File(project.getBuild().getTestOutputDirectory(), META_INF),
294296
BENCHMARK_LIST_FILE);
295297
} else {

0 commit comments

Comments
 (0)