Apply spotless to conventions scripts (#5082)

* Apply spotless to conventions scripts

* Apply spotless
This commit is contained in:
Anuraag Agrawal 2022-01-12 17:42:50 +09:00 committed by GitHub
parent 39d20b5fbc
commit 3804968898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 42 additions and 32 deletions

View File

@ -10,6 +10,10 @@ spotless {
licenseHeaderFile(rootProject.file("../buildscripts/spotless.license.java"), "(package|import|public)")
target("src/**/*.java")
}
kotlinGradle {
ktlint().userData(mapOf("indent_size" to "2", "continuation_indent_size" to "2", "disabled_rules" to "no-wildcard-imports"))
target("**/*.gradle.kts")
}
}
repositories {
@ -56,4 +60,4 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.assertj:assertj-core:3.21.0")
}
}

View File

@ -2,4 +2,4 @@ includeBuild("../gradle-plugins") {
dependencySubstitution {
substitute(module("io.opentelemetry.instrumentation:gradle-plugins")).using(project(":"))
}
}
}

View File

@ -17,7 +17,6 @@ dependencies {
add("codegen", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
}
dependencies {
// Integration tests may need to define custom instrumentation modules so we include the standard
// instrumentation infrastructure for testing too.
@ -82,7 +81,7 @@ class JavaagentTestArgumentsProvider(
// in smoke tests instead.
"-Dotel.javaagent.add-thread-details=false",
"-Dotel.metrics.exporter=otlp",
//suppress a couple of verbose ClassNotFoundException stack traces logged at debug level
// suppress a couple of verbose ClassNotFoundException stack traces logged at debug level
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ServerImplBuilder=INFO",
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ManagedChannelImplBuilder=INFO",
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.perfmark.PerfMark=INFO",
@ -106,7 +105,7 @@ afterEvaluate {
// We do fine-grained filtering of the classpath of this codebase's sources since Gradle's
// configurations will include transitive dependencies as well, which tests do often need.
classpath = classpath.filter {
if (file("${buildDir}/resources/main").equals(it) || file("${buildDir}/classes/java/main").equals(it)) {
if (file("$buildDir/resources/main").equals(it) || file("$buildDir/classes/java/main").equals(it)) {
// The sources are packaged into the testing jar, so we need to exclude them from the test
// classpath, which automatically inherits them, to ensure our shaded versions are used.
return@filter false

View File

@ -16,4 +16,4 @@ animalsniffer {
tasks.withType<AnimalSniffer> {
// always having declared output makes this task properly participate in tasks up-to-date checks
reports.text.required.set(true)
}
}

View File

@ -13,7 +13,7 @@ tasks {
reports {
xml.required.set(true)
csv.required.set(false)
html.outputLocation.set(file("${buildDir}/reports/jacoco/"))
html.outputLocation.set(file("$buildDir/reports/jacoco/"))
}
}
}

View File

@ -13,7 +13,7 @@ val latestReleasedVersion: String by lazy {
// hack to find the current released version of the project
val temp: Configuration = configurations.create("tempConfig")
// pick the agent, since it's always there.
dependencies.add(temp.name,"io.opentelemetry.javaagent:opentelemetry-javaagent:latest.release")
dependencies.add(temp.name, "io.opentelemetry.javaagent:opentelemetry-javaagent:latest.release")
val moduleVersion = configurations["tempConfig"].resolvedConfiguration.firstLevelModuleDependencies.elementAt(0).moduleVersion
configurations.remove(temp)
@ -31,7 +31,7 @@ fun findArtifact(version: String): File {
// Temporarily change the group name because we want to fetch an artifact with the same
// Maven coordinates as the project, which Gradle would not allow otherwise.
group = "virtual_group"
val depJar = "${base.archivesName.get()}-${version}.jar"
val depJar = "${base.archivesName.get()}-$version.jar"
val configuration: Configuration = configurations.detachedConfiguration(
dependencies.create(depModule)
)
@ -53,7 +53,7 @@ tasks {
?: file(getByName<Jar>("jar").archiveFile)
newClasspath = files(newArtifact)
//only output changes, not everything
// only output changes, not everything
isOnlyModified = true
// the japicmp "old" version is either the user-specified one, or the latest release.
@ -62,18 +62,17 @@ tasks {
oldClasspath = try {
files(findArtifact(baselineVersion))
} catch (e: Exception) {
//if we can't find the baseline artifact, this is probably one that's never been published before,
//so publish the whole API. We do that by flipping this flag, and comparing the current against nothing.
// if we can't find the baseline artifact, this is probably one that's never been published before,
// so publish the whole API. We do that by flipping this flag, and comparing the current against nothing.
isOnlyModified = false
files()
}
//this is needed so that we only consider the current artifact, and not dependencies
// this is needed so that we only consider the current artifact, and not dependencies
isIgnoreMissingClasses = true
packageExcludes = listOf("*.internal", "*.internal.*")
val baseVersionString = if (apiBaseVersion == null) "latest" else baselineVersion
val newVersionString = if (apiNewVersion == null) "current" else apiNewVersion
txtOutputFile = file("$rootDir/docs/apidiffs/${newVersionString}_vs_${baseVersionString}/${base.archivesName.get()}.txt")
txtOutputFile = file("$rootDir/docs/apidiffs/${newVersionString}_vs_$baseVersionString/${base.archivesName.get()}.txt")
}
}

View File

@ -213,7 +213,7 @@ tasks.withType<Test>().configureEach {
jvmArgs("-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=${rootProject.findProperty("enableStrictContext") ?: true}")
// Disable default resource providers since they cause lots of output we don't need.
jvmArgs("-Dotel.java.disabled.resource.providers=${resourceClassesCsv}")
jvmArgs("-Dotel.java.disabled.resource.providers=$resourceClassesCsv")
val trustStore = project(":testing-common").file("src/misc/testing-keystore.p12")
// Work around payara not working when this is set for some reason.
@ -247,7 +247,8 @@ class KeystoreArgumentsProvider(
) : CommandLineArgumentProvider {
override fun asArguments(): Iterable<String> = listOf(
"-Djavax.net.ssl.trustStore=${trustStore.absolutePath}",
"-Djavax.net.ssl.trustStorePassword=testing")
"-Djavax.net.ssl.trustStorePassword=testing"
)
}
afterEvaluate {
@ -256,19 +257,23 @@ afterEvaluate {
?: false
tasks.withType<Test>().configureEach {
if (testJavaVersion != null) {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(testJavaVersion.majorVersion))
implementation.set(if (useJ9) JvmImplementation.J9 else JvmImplementation.VENDOR_SPECIFIC)
})
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(testJavaVersion.majorVersion))
implementation.set(if (useJ9) JvmImplementation.J9 else JvmImplementation.VENDOR_SPECIFIC)
}
)
isEnabled = isEnabled && isJavaVersionAllowed(testJavaVersion)
} else {
// We default to testing with Java 11 for most tests, but some tests don't support it, where we change
// the default test task's version so commands like `./gradlew check` can test all projects regardless
// of Java version.
if (!isJavaVersionAllowed(DEFAULT_JAVA_VERSION) && otelJava.maxJavaVersionForTests.isPresent) {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(otelJava.maxJavaVersionForTests.get().majorVersion))
})
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(otelJava.maxJavaVersionForTests.get().majorVersion))
}
)
}
}

View File

@ -21,4 +21,4 @@ configurations {
named("muzzleBootstrap") {
extendsFrom(bootstrap)
}
}
}

View File

@ -25,8 +25,8 @@ jmh {
}
jmhReport {
jmhResultPath = file("${buildDir}/results/jmh/results.json").absolutePath
jmhReportOutput = file("${buildDir}/results/jmh").absolutePath
jmhResultPath = file("$buildDir/results/jmh/results.json").absolutePath
jmhReportOutput = file("$buildDir/results/jmh").absolutePath
}
tasks {

View File

@ -8,4 +8,4 @@ plugins {
extra["mavenGroupId"] = "io.opentelemetry.instrumentation"
base.archivesName.set(projectDir.parentFile.name)
base.archivesName.set(projectDir.parentFile.name)

View File

@ -9,7 +9,7 @@ publishing {
plugins.withId("java-platform") {
from(components["javaPlatform"])
}
if(project.path != ":javaagent"){
if (project.path != ":javaagent") {
plugins.withId("java-library") {
from(components["java"])
}
@ -32,8 +32,10 @@ publishing {
throw GradleException("groupId is not set for this project or its parent ${project.parent}")
}
pom.description.set(project.description
?: "Instrumentation of Java libraries using OpenTelemetry.")
pom.description.set(
project.description
?: "Instrumentation of Java libraries using OpenTelemetry."
)
}
pom {

View File

@ -42,7 +42,8 @@ spotless {
"src/**/*.md",
"docs/**/*.md",
"*.sh",
"src/**/*.properties")
"src/**/*.properties"
)
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()