diff --git a/conventions/build.gradle.kts b/conventions/build.gradle.kts index ed04f7d365..3fd74bd2d2 100644 --- a/conventions/build.gradle.kts +++ b/conventions/build.gradle.kts @@ -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") -} \ No newline at end of file +} diff --git a/conventions/settings.gradle.kts b/conventions/settings.gradle.kts index 1daf1e5fbc..151a960ded 100644 --- a/conventions/settings.gradle.kts +++ b/conventions/settings.gradle.kts @@ -2,4 +2,4 @@ includeBuild("../gradle-plugins") { dependencySubstitution { substitute(module("io.opentelemetry.instrumentation:gradle-plugins")).using(project(":")) } -} \ No newline at end of file +} diff --git a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts index 8567fce413..49861645cb 100644 --- a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts +++ b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-testing.gradle.kts @@ -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 diff --git a/conventions/src/main/kotlin/otel.animalsniffer-conventions.gradle.kts b/conventions/src/main/kotlin/otel.animalsniffer-conventions.gradle.kts index 07550a28ba..87d055055b 100644 --- a/conventions/src/main/kotlin/otel.animalsniffer-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.animalsniffer-conventions.gradle.kts @@ -16,4 +16,4 @@ animalsniffer { tasks.withType { // always having declared output makes this task properly participate in tasks up-to-date checks reports.text.required.set(true) -} \ No newline at end of file +} diff --git a/conventions/src/main/kotlin/otel.jacoco-conventions.gradle.kts b/conventions/src/main/kotlin/otel.jacoco-conventions.gradle.kts index 887a658312..b43d25043b 100644 --- a/conventions/src/main/kotlin/otel.jacoco-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.jacoco-conventions.gradle.kts @@ -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/")) } } } diff --git a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts index 3f43bc0b82..4f60c29efd 100644 --- a/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts @@ -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").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") } } - diff --git a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts index 3f8b9454f7..e5de9dbdd8 100644 --- a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts @@ -213,7 +213,7 @@ tasks.withType().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 = 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().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)) + } + ) } } diff --git a/conventions/src/main/kotlin/otel.javaagent-instrumentation.gradle.kts b/conventions/src/main/kotlin/otel.javaagent-instrumentation.gradle.kts index a13b156f8a..24542bc5e3 100644 --- a/conventions/src/main/kotlin/otel.javaagent-instrumentation.gradle.kts +++ b/conventions/src/main/kotlin/otel.javaagent-instrumentation.gradle.kts @@ -21,4 +21,4 @@ configurations { named("muzzleBootstrap") { extendsFrom(bootstrap) } -} \ No newline at end of file +} diff --git a/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts b/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts index d8d1200b72..96823e1c91 100644 --- a/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.jmh-conventions.gradle.kts @@ -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 { diff --git a/conventions/src/main/kotlin/otel.library-instrumentation.gradle.kts b/conventions/src/main/kotlin/otel.library-instrumentation.gradle.kts index 8dad1d1cbc..92e1cbfc5c 100644 --- a/conventions/src/main/kotlin/otel.library-instrumentation.gradle.kts +++ b/conventions/src/main/kotlin/otel.library-instrumentation.gradle.kts @@ -8,4 +8,4 @@ plugins { extra["mavenGroupId"] = "io.opentelemetry.instrumentation" -base.archivesName.set(projectDir.parentFile.name) \ No newline at end of file +base.archivesName.set(projectDir.parentFile.name) diff --git a/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts b/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts index e8542821bc..6555f4a224 100644 --- a/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.publish-conventions.gradle.kts @@ -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 { diff --git a/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts b/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts index b5cf10d6ac..d97533ee35 100644 --- a/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.spotless-conventions.gradle.kts @@ -42,7 +42,8 @@ spotless { "src/**/*.md", "docs/**/*.md", "*.sh", - "src/**/*.properties") + "src/**/*.properties" + ) indentWithSpaces() trimTrailingWhitespace() endWithNewline()