opentelemetry-java-instrume.../build.gradle

178 lines
4.8 KiB
Groovy

import java.time.Duration
import nebula.plugin.release.git.opinion.Strategies
plugins {
id 'idea'
id "io.github.gradle-nexus.publish-plugin"
id "nebula.release"
id 'org.gradle.test-retry' apply false
id 'org.unbroken-dome.test-sets' apply false
id 'com.github.ben-manes.versions'
id "com.github.johnrengelman.shadow" apply false
id "com.diffplug.spotless"
id "net.ltgt.errorprone" apply false
id "net.ltgt.nullaway" apply false
}
release {
defaultVersionStrategy = Strategies.SNAPSHOT
}
nebulaRelease {
addReleaseBranchPattern(/v\d+\.\d+\.x/)
}
nexusPublishing {
packageGroup = "io.opentelemetry"
repositories {
sonatype {
username = System.getenv('SONATYPE_USER')
password = System.getenv('SONATYPE_KEY')
}
}
connectTimeout = Duration.ofMinutes(5)
clientTimeout = Duration.ofMinutes(5)
transitionCheckOptions {
// We have many artifacts so Maven Central takes a long time on its compliance checks. This sets
// the timeout for waiting for the repository to close to a comfortable 50 minutes.
maxRetries.set(300)
delayBetween.set(Duration.ofSeconds(10))
}
}
// Enable after verifying Maven Central publishing once through manual closing
// tasks.release.finalizedBy tasks.closeAndReleaseRepository
allprojects {
apply from: "$rootDir/gradle/util.gradle"
}
description = 'OpenTelemetry instrumentations for Java'
allprojects {
apply plugin: 'idea'
idea {
module {
downloadJavadoc = false
downloadSources = false
}
}
plugins.withId('net.ltgt.errorprone') {
dependencies {
errorprone "com.google.errorprone:error_prone_core"
}
tasks.withType(JavaCompile).configureEach {
options.errorprone {
enabled = rootProject.findProperty("disableErrorProne") != "true"
disableWarningsInGeneratedCode = true
allDisabledChecksAsWarnings = true
excludedPaths = ".*/build/generated/.*"
// Doesn't work well with Java 8
disable("FutureReturnValueIgnored")
// Require Guava
disable("AutoValueImmutableFields")
disable("StringSplitter")
disable("ImmutableMemberCollection")
// Don't currently use this (to indicate a local variable that's mutated) but could
// consider for future.
disable("Var")
// Don't support Android without desugar
disable("AndroidJdkLibsChecker")
disable("Java7ApiChecker")
disable("StaticOrDefaultInterfaceMethod")
// Great check, but for bytecode manipulation it's too common to separate over
// onEnter / onExit
// TODO(anuraaga): Only disable for auto instrumentation project.
disable("MustBeClosedChecker")
// Common to avoid an allocation. Revisit if it's worth opt-in suppressing instead of
// disabling entirely.
disable("MixedMutabilityReturnType")
// We end up using obsolete types if a library we're instrumenting uses them.
disable("JdkObsolete")
disable("JavaUtilDate")
// Limits API possibilities
disable("NoFunctionalReturnType")
// Storing into a variable in onEnter triggers this unfortunately.
// TODO(anuraaga): Only disable for auto instrumentation project.
disable("UnusedVariable")
// TODO(anuraaga): Remove this, we use this pattern in several tests and it will mean
// some moving.
disable("DefaultPackage")
// TODO(anuraaga): Remove this, all our advice classes miss constructors but probably should
// address this.
disable("PrivateConstructorForUtilityClass")
// TODO(anuraaga): Remove this, probably after instrumenter API migration instead of dealing
// with older APIs.
disable("InconsistentOverloads")
disable("TypeParameterNaming")
// We don't use tools that recognize.
disable("InlineMeSuggester")
disable("DoNotCallSuggester")
if (name.contains("Jmh") || name.contains("Test")) {
disable("HashCodeToString")
disable("MemberName")
}
}
}
}
plugins.withId('net.ltgt.nullaway') {
dependencies {
errorprone "com.uber.nullaway:nullaway"
}
nullaway {
annotatedPackages.addAll("io.opentelemetry", "com.linecorp.armeria,com.google.common")
}
tasks.withType(JavaCompile).configureEach {
if (!name.toLowerCase().contains("test")) {
options.errorprone {
nullaway {
severity = net.ltgt.gradle.errorprone.CheckSeverity.ERROR
}
}
}
}
}
}
apply plugin: 'com.diffplug.spotless'
spotless {
// this formatting is applied at the root level, as some of these files are not in a submodules
// and would be missed otherwise
format 'misc', {
target '.gitignore', '*.md', 'docs/**/*.md'
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
}
}