Switch to use pluginManagement, Use gradle plugin for jmh. (#903) · goodjava/opentelemetry-java@a148263 · GitHub
Skip to content

Commit a148263

Browse files
authored
Switch to use pluginManagement, Use gradle plugin for jmh. (open-telemetry#903)
* Switch to use pluginManagement, Use gradle plugin for jmh. Signed-off-by: Bogdan Cristian Drutu <bogdandrutu@gmail.com> * Fix jmh report Signed-off-by: Bogdan Cristian Drutu <bogdandrutu@gmail.com> * Use ' for the moment for plugin ids in main gradle
1 parent 24e4705 commit a148263

19 files changed

Lines changed: 184 additions & 211 deletions

File tree

all/build.gradle

Lines changed: 5 additions & 0 deletions

api/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
plugins {
2+
id "java"
3+
id "maven-publish"
4+
5+
id "io.morethan.jmhreport"
6+
id "me.champeau.gradle.jmh"
7+
id "ru.vyarus.animalsniffer"
8+
}
9+
110
description = 'OpenTelemetry API'
211
ext.moduleName = "io.opentelemetry.api"
312

build.gradle

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
4-
jcenter()
5-
maven {
6-
url "https://plugins.gradle.org/m2/"
7-
}
8-
mavenLocal()
9-
}
10-
dependencies {
11-
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.0'
12-
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.1.1'
13-
classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
14-
classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.8"
15-
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8'
16-
classpath "gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.0"
17-
}
1+
plugins {
2+
id "com.github.sherter.google-java-format" apply false
3+
id "com.jfrog.artifactory" apply false
4+
id "me.champeau.gradle.jmh" apply false
5+
id "net.ltgt.errorprone" apply false
6+
id "ru.vyarus.animalsniffer" apply false
7+
id "io.morethan.jmhreport" apply false
188
}
199

20-
// Display the version report using: ./gradlew dependencyUpdates
21-
// Also see https://github.com/ben-manes/gradle-versions-plugin.
22-
apply plugin: 'com.github.ben-manes.versions'
23-
2410
subprojects {
2511
apply plugin: 'checkstyle'
2612
apply plugin: 'eclipse'
@@ -30,26 +16,24 @@ subprojects {
3016
apply plugin: 'signing'
3117
apply plugin: 'jacoco'
3218
apply plugin: 'maven-publish'
33-
// The plugin only has an effect if a signature is specified
34-
apply plugin: 'ru.vyarus.animalsniffer'
19+
3520
apply plugin: 'com.github.sherter.google-java-format'
3621
apply plugin: 'net.ltgt.errorprone'
37-
apply plugin: 'com.jfrog.artifactory'
38-
apply plugin: 'io.morethan.jmhreport'
39-
apply from: "$rootDir/jmh.gradle"
22+
apply plugin: "com.jfrog.artifactory"
4023

4124
group = "io.opentelemetry"
4225
version = "0.3.0-SNAPSHOT" // CURRENT_VERSION
4326

44-
sourceCompatibility = 1.7
45-
targetCompatibility = 1.7
46-
4727
repositories {
4828
mavenCentral()
29+
jcenter()
4930
mavenLocal()
5031
}
5132

52-
[compileJava, compileTestJava, compileJmhJava].each() {
33+
sourceCompatibility = 1.7
34+
targetCompatibility = 1.7
35+
36+
tasks.withType(JavaCompile) {
5337
// We suppress the "try" warning because it disallows managing an auto-closeable with
5438
// try-with-resources without referencing the auto-closeable within the try block.
5539
// We suppress the "processing" warning as suggested in
@@ -184,8 +168,10 @@ subprojects {
184168
configProperties["rootDir"] = rootDir
185169
}
186170

171+
jacoco { toolVersion = "0.8.2" }
172+
187173
googleJavaFormat {
188-
toolVersion '1.7'
174+
toolVersion = '1.7'
189175
}
190176

191177
afterEvaluate { // Allow subproject to add more source sets.
@@ -239,12 +225,38 @@ subprojects {
239225
maxHeapSize = '1500m'
240226
}
241227

242-
jmhReport {
243-
jmhResultPath = project.file("${project.buildDir}/results/results.json")
244-
jmhReportOutput = project.file("${project.buildDir}/results")
245-
}
228+
plugins.withId("me.champeau.gradle.jmh") {
229+
dependencies {
230+
jmh 'org.openjdk.jmh:jmh-core:1.19',
231+
'org.openjdk.jmh:jmh-generator-bytecode:1.19'
232+
}
246233

247-
tasks.jmhRun.finalizedBy tasks.jmhReport
234+
// invoke jmh on a single benchmark class like so:
235+
// ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
236+
jmh {
237+
warmupIterations = 5
238+
iterations = 10
239+
fork = 1
240+
failOnError = true
241+
resultFormat = 'JSON'
242+
// None of our benchmarks need the tests, and we have pseudo-circular
243+
// dependencies that break when including them. (context's testCompile
244+
// depends on core; core's testCompile depends on testing)
245+
includeTests = false
246+
if (project.hasProperty('jmhIncludeSingleClass')) {
247+
include = [
248+
project.property('jmhIncludeSingleClass')
249+
]
250+
}
251+
}
252+
253+
jmhReport {
254+
jmhResultPath = project.file("${project.buildDir}/reports/jmh/results.json")
255+
jmhReportOutput = project.file("${project.buildDir}/reports/jmh")
256+
}
257+
258+
tasks.jmh.finalizedBy tasks.jmhReport
259+
}
248260

249261
apply from: "${rootProject.projectDir}/gradle/publish.gradle"
250262

context_prop/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
plugins {
2+
id "java"
3+
id "maven-publish"
4+
5+
id "ru.vyarus.animalsniffer"
6+
}
7+
18
description = 'OpenTelemetry Context Propagation'
29
ext.moduleName = "io.opentelemetry.context.propagation"
310

contrib/runtime_metrics/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
plugins {
2+
id "java"
3+
id "maven-publish"
4+
5+
id "ru.vyarus.animalsniffer"
6+
}
7+
18
description = 'OpenTelemetry Contrib Runtime Metrics'
29
ext.moduleName = "io.opentelemetry.contrib.metrics.runtime"
310

contrib/trace_utils/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
plugins {
2+
id "java"
3+
id "maven-publish"
4+
5+
id "ru.vyarus.animalsniffer"
6+
}
7+
18
description = 'OpenTelemetry Contrib Trace Utils'
29
ext.moduleName = "io.opentelemetry.contrib.trace"
310

exporters/inmemory/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
plugins {
2+
id "java"
3+
id "maven-publish"
4+
5+
id "ru.vyarus.animalsniffer"
6+
}
7+
18
description = 'OpenTelemetry InMemory Export'
29
ext.moduleName = "io.opentelemetry.exporters.inmemory"
310

411
dependencies {
512
api project(':opentelemetry-sdk')
613

714
testImplementation "com.google.protobuf:protobuf-java:${protobufVersion}"
15+
16+
signature "org.codehaus.mojo.signature:java17:1.0@signature"
17+
signature "net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature"
818
}

exporters/jaeger/build.gradle

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
description = 'OpenTelemetry - Jaeger Exporter'
2-
ext.moduleName = "io.opentelemetry.exporters.jaeger"
1+
plugins {
2+
id "java"
3+
id "maven-publish"
34

4-
apply plugin: 'com.google.protobuf'
5-
6-
buildscript {
7-
repositories {
8-
maven { url "https://plugins.gradle.org/m2/" }
9-
}
10-
dependencies {
11-
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
12-
}
5+
id "com.google.protobuf"
6+
id "ru.vyarus.animalsniffer"
137
}
148

9+
description = 'OpenTelemetry - Jaeger Exporter'
10+
ext.moduleName = "io.opentelemetry.exporters.jaeger"
11+
1512
dependencies {
1613
api project(':opentelemetry-sdk')
1714

exporters/logging/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
description = 'OpenTelemetry - Logging Exporter'
2-
ext.moduleName = "io.opentelemetry.exporters.logging"
1+
plugins {
2+
id "java"
3+
id "maven-publish"
34

4-
buildscript {
5-
repositories {
6-
maven { url "https://plugins.gradle.org/m2/" }
7-
}
5+
id "ru.vyarus.animalsniffer"
86
}
97

8+
description = 'OpenTelemetry - Logging Exporter'
9+
ext.moduleName = "io.opentelemetry.exporters.logging"
10+
1011
dependencies {
1112
api project(':opentelemetry-sdk')
1213

exporters/otprotocol/build.gradle

Lines changed: 7 additions & 0 deletions

0 commit comments

Comments
 (0)