Switch to use pluginManagement, Use gradle plugin for jmh. (#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
This commit is contained in:
Bogdan Drutu 2020-02-21 10:19:51 -08:00 committed by GitHub
parent 24e470522d
commit a148263597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 184 additions and 211 deletions

View File

@ -1,3 +1,8 @@
plugins {
id "java"
id "ru.vyarus.animalsniffer"
}
description = "OpenTelemetry All"
ext.moduleName = "io.opentelemetry.all"

View File

@ -1,3 +1,12 @@
plugins {
id "java"
id "maven-publish"
id "io.morethan.jmhreport"
id "me.champeau.gradle.jmh"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry API'
ext.moduleName = "io.opentelemetry.api"

View File

@ -1,26 +1,12 @@
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
mavenLocal()
}
dependencies {
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.1.1'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.8"
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8'
classpath "gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.0"
}
plugins {
id "com.github.sherter.google-java-format" apply false
id "com.jfrog.artifactory" apply false
id "me.champeau.gradle.jmh" apply false
id "net.ltgt.errorprone" apply false
id "ru.vyarus.animalsniffer" apply false
id "io.morethan.jmhreport" apply false
}
// Display the version report using: ./gradlew dependencyUpdates
// Also see https://github.com/ben-manes/gradle-versions-plugin.
apply plugin: 'com.github.ben-manes.versions'
subprojects {
apply plugin: 'checkstyle'
apply plugin: 'eclipse'
@ -30,26 +16,24 @@ subprojects {
apply plugin: 'signing'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
// The plugin only has an effect if a signature is specified
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'com.github.sherter.google-java-format'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'io.morethan.jmhreport'
apply from: "$rootDir/jmh.gradle"
apply plugin: "com.jfrog.artifactory"
group = "io.opentelemetry"
version = "0.3.0-SNAPSHOT" // CURRENT_VERSION
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
jcenter()
mavenLocal()
}
[compileJava, compileTestJava, compileJmhJava].each() {
sourceCompatibility = 1.7
targetCompatibility = 1.7
tasks.withType(JavaCompile) {
// We suppress the "try" warning because it disallows managing an auto-closeable with
// try-with-resources without referencing the auto-closeable within the try block.
// We suppress the "processing" warning as suggested in
@ -184,8 +168,10 @@ subprojects {
configProperties["rootDir"] = rootDir
}
jacoco { toolVersion = "0.8.2" }
googleJavaFormat {
toolVersion '1.7'
toolVersion = '1.7'
}
afterEvaluate { // Allow subproject to add more source sets.
@ -239,12 +225,38 @@ subprojects {
maxHeapSize = '1500m'
}
jmhReport {
jmhResultPath = project.file("${project.buildDir}/results/results.json")
jmhReportOutput = project.file("${project.buildDir}/results")
plugins.withId("me.champeau.gradle.jmh") {
dependencies {
jmh 'org.openjdk.jmh:jmh-core:1.19',
'org.openjdk.jmh:jmh-generator-bytecode:1.19'
}
tasks.jmhRun.finalizedBy tasks.jmhReport
// invoke jmh on a single benchmark class like so:
// ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
jmh {
warmupIterations = 5
iterations = 10
fork = 1
failOnError = true
resultFormat = 'JSON'
// None of our benchmarks need the tests, and we have pseudo-circular
// dependencies that break when including them. (context's testCompile
// depends on core; core's testCompile depends on testing)
includeTests = false
if (project.hasProperty('jmhIncludeSingleClass')) {
include = [
project.property('jmhIncludeSingleClass')
]
}
}
jmhReport {
jmhResultPath = project.file("${project.buildDir}/reports/jmh/results.json")
jmhReportOutput = project.file("${project.buildDir}/reports/jmh")
}
tasks.jmh.finalizedBy tasks.jmhReport
}
apply from: "${rootProject.projectDir}/gradle/publish.gradle"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry Context Propagation'
ext.moduleName = "io.opentelemetry.context.propagation"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry Contrib Runtime Metrics'
ext.moduleName = "io.opentelemetry.contrib.metrics.runtime"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry Contrib Trace Utils'
ext.moduleName = "io.opentelemetry.contrib.trace"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry InMemory Export'
ext.moduleName = "io.opentelemetry.exporters.inmemory"
@ -5,4 +12,7 @@ dependencies {
api project(':opentelemetry-sdk')
testImplementation "com.google.protobuf:protobuf-java:${protobufVersion}"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature"
}

View File

@ -1,17 +1,14 @@
plugins {
id "java"
id "maven-publish"
id "com.google.protobuf"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry - Jaeger Exporter'
ext.moduleName = "io.opentelemetry.exporters.jaeger"
apply plugin: 'com.google.protobuf'
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
}
}
dependencies {
api project(':opentelemetry-sdk')

View File

@ -1,12 +1,13 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry - Logging Exporter'
ext.moduleName = "io.opentelemetry.exporters.logging"
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
}
dependencies {
api project(':opentelemetry-sdk')

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry Protocol Exporter'
ext.moduleName = "io.opentelemetry.exporters.otprotocol"

View File

@ -1,143 +0,0 @@
/*
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* This file should be imported in the top-level Gradle project.
* To add JMH microbenchmarks to any sub-project simply create 'src/jmh/java'
* and if required 'src/jmh/resource'. This JMH Gradle script will check for
* this sourceset, and will add tasks if it exists, and build any benchmarks.
*
* Running benchmarks can be done either through gradle using the task runJMH,
* or by downloading the created artifact and required dependencies.
*
* To use Gradle to download the benchmark for a specific version you can use
* a basic Gradle build file like the following.
*
* apply plugin: 'java'
*
* repositories {
* ...
* }
*
* dependencies {
* compile(group: 'GROUP', name: 'NAME', version: 'VERSION')
* compile(group: 'GROUP', name: 'NAME', version: 'VERSION', classifier: 'jmh')
* }
*
* task copyDependencies(type: Copy) {
* into 'execute'
* }
*
* task setup {
* dependsOn copyDependencies
* }
*
* $ gradle setup
* $ java -jar execute/group-name-version-jmh.jar
*/
sourceSets {
jmh {
java.srcDir 'src/jmh/java'
resources.srcDir 'src/jmh/resources'
compileClasspath += main.output
runtimeClasspath += main.output
}
}
def benchmarksAvailable = sourceSets.jmh.java.getFiles().any { f -> f.exists() }
dependencies {
jmhCompile 'org.openjdk.jmh:jmh-core:1.23'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.23'
}
configurations {
jmhCompile {
extendsFrom compile
}
jmhImplementation {
extendsFrom implementation
extendsFrom jmhCompile
}
jmh {
extendsFrom runtime
extendsFrom jmhCompile
}
}
compileJmhJava {
enabled benchmarksAvailable
options.compilerArgs = compileJava.options.compilerArgs
options.fork = compileJava.options.fork
options.forkOptions = compileJava.options.forkOptions
}
task jmhRun(type: JavaExec) {
enabled benchmarksAvailable
description 'Run JMH benchmark(s). Use the property jmhFilter to set benchmark filtering regex.'
group 'Verification'
classpath = sourceSets.jmh.runtimeClasspath
main = 'org.openjdk.jmh.Main'
// Allows users to filter JMH benchmarks using a regex
mkdir("${project.buildDir}/results")
args "--rf", "json", "--rff", "${project.buildDir}/results/results.json"
args project.findProperty("jmhFilter") ?: ''
}
task jmhJar(type: Jar) {
dependsOn = ['compileJmhJava']
enabled benchmarksAvailable
description 'Generate executable JMH benchmark JAR, if any benchmarks exists.'
group 'Build'
classifier "jmh"
doFirst {
manifest {
attributes('Main-Class': 'org.openjdk.jmh.Main', 'Class-Path': ([jar.archiveFileName.get()] + configurations.runtimeClasspath.files.collect { it.getName() }).join(' '))
}
}
from {
(configurations.jmhRuntimeClasspath.files + configurations.runtimeClasspath.files).collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
exclude 'log4j.properties'
}
from (sourceSets.jmh.output + sourceSets.main.output)
}
artifacts {
if (benchmarksAvailable) {
archives jmhJar
}
}
publishing {
publications {
mavenJava(MavenPublication) {
if (benchmarksAvailable) {
artifact jmhJar {
classifier "jmh"
}
}
}
}
}

View File

@ -1,15 +1,17 @@
plugins {
id "java"
id "maven-publish"
}
description = 'OpenTelemetry OpenTracing Bridge'
ext.moduleName = "io.opentelemetry.opentracingshim"
def protobufVersion = '3.7.1'
dependencies {
api project(':opentelemetry-api'),
libraries.opentracing
testImplementation project(':opentelemetry-sdk'),
project(':opentelemetry-exporters-inmemory'),
libraries.protobuf,
libraries.junit,
libraries.truth,
libraries.slf4jsimple,

View File

@ -1,17 +1,14 @@
plugins {
id "java"
id "maven-publish"
id "com.google.protobuf"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry Proto'
ext.moduleName = 'io.opentelemetry.proto'
apply plugin: 'com.google.protobuf'
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
}
}
dependencies {
api libraries.protobuf

View File

@ -1,3 +1,12 @@
plugins {
id "java"
id "maven-publish"
id "io.morethan.jmhreport"
id "me.champeau.gradle.jmh"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry SDK'
ext.moduleName = "io.opentelemetry.sdk"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry SDK Contrib'
ext.moduleName = "io.opentelemetry.sdk.contrib.trace.export"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry SDK Contrib for Configuration'
ext.moduleName = "io.opentelemetry.sdk.contrib.config"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry SDK AWS SDK v1.x Support'
ext.moduleName = "io.opentelemetry.sdk.contrib.trace.aws"

View File

@ -1,3 +1,10 @@
plugins {
id "java"
id "maven-publish"
id "ru.vyarus.animalsniffer"
}
description = 'OpenTelemetry SDK Testbed'
ext.moduleName = 'io.opentelemetry.sdk.contrib.trace.testbed'

View File

@ -1,5 +1,23 @@
rootProject.name = "opentelemetry-java"
pluginManagement {
plugins {
id "com.github.ben-manes.versions" version "0.20.0"
id "com.github.kt3k.coveralls" version "2.0.1"
id 'com.github.sherter.google-java-format' version "0.8"
id "com.google.protobuf" version "0.8.8"
id "com.jfrog.artifactory" version "4.13.0"
id "io.morethan.jmhreport" version "0.9.0"
id "me.champeau.gradle.jmh" version "0.5.0"
id "net.ltgt.errorprone" version "0.8.1"
id "ru.vyarus.animalsniffer" version "1.5.0"
}
repositories {
gradlePluginPortal()
google()
}
}
rootProject.name = "opentelemetry-java"
include ":opentelemetry-all",
":opentelemetry-api",
":opentelemetry-context-prop",