From 4624584979c87dde9e90c8fc2275201601d4d798 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 8 Oct 2020 21:21:28 -0700 Subject: [PATCH] Update spotless config (#1349) * Apply spotless to buildSrc * Apply spotless * Update spotless version * Apply spotless * Another spotless update * Apply spotless --- build.gradle | 4 +- buildSrc/build.gradle | 52 +++++++++++++++++++ buildSrc/build.gradle.kts | 41 --------------- buildSrc/src/main/groovy/MuzzlePlugin.groovy | 5 ++ .../gradle/AutoInstrumentationPlugin.java | 13 +---- .../src/test/groovy/RangeQueryTest.groovy | 5 ++ gradle/spotless.gradle | 4 +- .../v4_0/CompletionStageFunction.java | 2 +- .../src/test/resources/log4j.properties | 2 +- .../TracerAutoConfiguration.java | 4 +- 10 files changed, 70 insertions(+), 62 deletions(-) create mode 100644 buildSrc/build.gradle delete mode 100644 buildSrc/build.gradle.kts diff --git a/build.gradle b/build.gradle index 026818ffb249..1de310a99959 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ plugins { id "com.github.johnrengelman.shadow" version "6.0.0" - id "com.diffplug.gradle.spotless" version "4.3.0" + id "com.diffplug.spotless" version "5.6.1" id "com.github.spotbugs" version "4.0.1" id "net.ltgt.errorprone" version "1.2.1" apply false @@ -62,7 +62,7 @@ allprojects { } } -apply plugin: 'com.diffplug.gradle.spotless' +apply plugin: 'com.diffplug.spotless' spotless { // this formatting is applied at the root level, as some of these files are not in a submodules diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 000000000000..ebf456d77a3e --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,52 @@ +plugins { + id 'groovy' + id 'java-gradle-plugin' + id "com.diffplug.spotless" version "5.6.1" +} + +spotless { + java { + googleJavaFormat() + licenseHeaderFile rootProject.file('../gradle/enforcement/spotless.license.java'), '(package|import|public)' + target 'src/**/*.java' + } + groovy { + licenseHeaderFile rootProject.file('../gradle/enforcement/spotless.license.java'), '(package|import|class)' + } +} + +gradlePlugin { + plugins { + create("muzzle-plugin") { + id = "muzzle" + implementationClass = "MuzzlePlugin" + } + create("auto-instrumentation-plugin") { + id = "io.opentelemetry.instrumentation.auto-instrumentation" + implementationClass = "io.opentelemetry.instrumentation.gradle.AutoInstrumentationPlugin" + } + } +} + +repositories { + mavenLocal() + jcenter() + mavenCentral() +} + +dependencies { + implementation(gradleApi()) + implementation(localGroovy()) + + implementation group: "org.eclipse.aether", name: "aether-connector-basic", version: "1.1.0" + implementation group: "org.eclipse.aether", name: "aether-transport-http", version: "1.1.0" + implementation group: "org.apache.maven", name: "maven-aether-provider", version: "3.3.9" + + implementation group: "com.google.guava", name: "guava", version: "20.0" + implementation group: "org.ow2.asm", name: "asm", version: "7.0-beta" + implementation group: "org.ow2.asm", name: "asm-tree", version: "7.0-beta" + implementation group: "org.apache.httpcomponents", name: "httpclient", version: "4.5.10" + + testImplementation group: "org.spockframework", name: "spock-core", version: "1.3-groovy-2.5" + testImplementation group: "org.codehaus.groovy", name: "groovy-all", version: "2.5.8" +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 6f0fa79e61b1..000000000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,41 +0,0 @@ -plugins { - groovy - `java-gradle-plugin` - id("com.diffplug.gradle.spotless") version "4.3.0" -} - -gradlePlugin { - plugins { - create("muzzle-plugin") { - id = "muzzle" - implementationClass = "MuzzlePlugin" - } - create("auto-instrumentation-plugin") { - id = "io.opentelemetry.instrumentation.auto-instrumentation" - implementationClass = "io.opentelemetry.instrumentation.gradle.AutoInstrumentationPlugin" - } - } -} - -repositories { - mavenLocal() - jcenter() - mavenCentral() -} - -dependencies { - implementation(gradleApi()) - implementation(localGroovy()) - - implementation("org.eclipse.aether", "aether-connector-basic", "1.1.0") - implementation("org.eclipse.aether", "aether-transport-http", "1.1.0") - implementation("org.apache.maven", "maven-aether-provider", "3.3.9") - - implementation("com.google.guava", "guava", "20.0") - implementation("org.ow2.asm", "asm", "7.0-beta") - implementation("org.ow2.asm", "asm-tree", "7.0-beta") - implementation("org.apache.httpcomponents:httpclient:4.5.10") - - testImplementation("org.spockframework", "spock-core", "1.3-groovy-2.5") - testImplementation("org.codehaus.groovy", "groovy-all", "2.5.8") -} diff --git a/buildSrc/src/main/groovy/MuzzlePlugin.groovy b/buildSrc/src/main/groovy/MuzzlePlugin.groovy index 7f9f016d123d..c9a4bcf20450 100644 --- a/buildSrc/src/main/groovy/MuzzlePlugin.groovy +++ b/buildSrc/src/main/groovy/MuzzlePlugin.groovy @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import java.lang.reflect.Method import java.security.SecureClassLoader import java.util.concurrent.atomic.AtomicReference diff --git a/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/AutoInstrumentationPlugin.java b/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/AutoInstrumentationPlugin.java index bde5cac37880..05c17a593441 100644 --- a/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/AutoInstrumentationPlugin.java +++ b/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/AutoInstrumentationPlugin.java @@ -1,17 +1,6 @@ /* * Copyright The 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. + * SPDX-License-Identifier: Apache-2.0 */ package io.opentelemetry.instrumentation.gradle; diff --git a/buildSrc/src/test/groovy/RangeQueryTest.groovy b/buildSrc/src/test/groovy/RangeQueryTest.groovy index 2576a23fe2b3..f3b30d5028ed 100644 --- a/buildSrc/src/test/groovy/RangeQueryTest.groovy +++ b/buildSrc/src/test/groovy/RangeQueryTest.groovy @@ -1,3 +1,8 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + import org.eclipse.aether.RepositorySystem import org.eclipse.aether.RepositorySystemSession import org.eclipse.aether.artifact.Artifact diff --git a/gradle/spotless.gradle b/gradle/spotless.gradle index 3e5e6879ab8f..ab659d44af2f 100644 --- a/gradle/spotless.gradle +++ b/gradle/spotless.gradle @@ -1,4 +1,4 @@ -apply plugin: 'com.diffplug.gradle.spotless' +apply plugin: 'com.diffplug.spotless' spotless { java { @@ -21,7 +21,7 @@ spotless { } format 'misc', { // not using '**/...' to help keep spotless fast - target '.gitignore', '*.md', 'src/**/.md', '*.sh' + target '.gitignore', '*.md', 'src/**/*.md', '*.sh', 'src/**/*.properties' indentWithSpaces() trimTrailingWhitespace() endWithNewline() diff --git a/instrumentation/cassandra/cassandra-4.0/src/main/java/io/opentelemetry/instrumentation/auto/cassandra/v4_0/CompletionStageFunction.java b/instrumentation/cassandra/cassandra-4.0/src/main/java/io/opentelemetry/instrumentation/auto/cassandra/v4_0/CompletionStageFunction.java index cc3e2bb4ed28..8c9eccb2c2b5 100644 --- a/instrumentation/cassandra/cassandra-4.0/src/main/java/io/opentelemetry/instrumentation/auto/cassandra/v4_0/CompletionStageFunction.java +++ b/instrumentation/cassandra/cassandra-4.0/src/main/java/io/opentelemetry/instrumentation/auto/cassandra/v4_0/CompletionStageFunction.java @@ -20,5 +20,5 @@ public Object apply(Object session) { return session; } return new TracingCqlSession((CqlSession) session); - }; + } } diff --git a/instrumentation/log4j/log4j-1.2/src/test/resources/log4j.properties b/instrumentation/log4j/log4j-1.2/src/test/resources/log4j.properties index e3a930a0b877..e7104aab698c 100644 --- a/instrumentation/log4j/log4j-1.2/src/test/resources/log4j.properties +++ b/instrumentation/log4j/log4j-1.2/src/test/resources/log4j.properties @@ -1,2 +1,2 @@ log4j.rootLogger=INFO, LIST -log4j.appender.LIST=ListAppender \ No newline at end of file +log4j.appender.LIST=ListAppender diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/TracerAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/TracerAutoConfiguration.java index ca6403bdc6dc..d3e4c551d3a7 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/TracerAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/TracerAutoConfiguration.java @@ -63,9 +63,7 @@ private void addSpanProcessors(List spanExporters) { private void setSampler(TracerProperties tracerProperties) { TraceConfig updatedTraceConfig = - OpenTelemetrySdk.getTracerManagement() - .getActiveTraceConfig() - .toBuilder() + OpenTelemetrySdk.getTracerManagement().getActiveTraceConfig().toBuilder() .setSampler(Samplers.traceIdRatioBased(tracerProperties.getSamplerProbability())) .build();