Skip to content

Commit 4c282cd

Browse files
traskCopilot
andauthored
Sync spotless configuration with OpenTelemetry Java Instrumentation (#4366)
Co-authored-by: Copilot <[email protected]>
1 parent 92c537e commit 4c282cd

File tree

4 files changed

+160
-122
lines changed

4 files changed

+160
-122
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The agent JAR is built in **3 critical steps** (see `agent/agent/build.gradle.kt
9090
abstract class HttpClientTest {
9191
@Environment(TOMCAT_8_JAVA_8)
9292
static class Tomcat8Java8Test extends HttpClientTest {}
93-
93+
9494
@Environment(TOMCAT_8_JAVA_11)
9595
static class Tomcat8Java11Test extends HttpClientTest {}
9696
}

agent/agent/build.gradle.kts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,18 @@ tasks {
162162
delete(rootProject.file("licenses"))
163163
}
164164

165+
val generateLicenseReportEnabled =
166+
gradle.startParameter.taskNames.any { it.equals("generateLicenseReport") }
165167
named("generateLicenseReport").configure {
166168
dependsOn(cleanLicenses)
169+
finalizedBy(":spotlessApply")
170+
// disable licence report generation unless this task is explicitly run
171+
// the files produced by this task are used by other tasks without declaring them as dependency
172+
// which gradle considers an error
173+
enabled = enabled && generateLicenseReportEnabled
174+
}
175+
if (generateLicenseReportEnabled) {
176+
project.parent?.parent?.tasks?.getByName("spotlessMisc")?.dependsOn(named("generateLicenseReport"))
167177
}
168178
}
169179

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,72 @@
1+
import com.diffplug.gradle.spotless.SpotlessExtension
2+
13
plugins {
24
id("com.diffplug.spotless")
35
}
46

57
spotless {
68
java {
79
googleJavaFormat()
8-
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|public|// Includes work from:)")
10+
licenseHeaderFile(
11+
rootProject.file("buildscripts/spotless.license.java"),
12+
"(package|import|public|// Includes work from:)"
13+
)
14+
toggleOffOn()
915
target("src/**/*.java")
1016
}
1117
kotlinGradle {
12-
ktlint().editorConfigOverride(mapOf(
13-
"indent_size" to "2",
14-
"continuation_indent_size" to "2",
15-
"max_line_length" to "160",
16-
"ktlint_standard_no-wildcard-imports" to "disabled",
17-
// ktlint does not break up long lines, it just fails on them
18-
"ktlint_standard_max-line-length" to "disabled",
19-
// ktlint makes it *very* hard to locate where this actually happened
20-
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
21-
// depends on ktlint_standard_wrapping
22-
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
23-
// also very hard to find out where this happens
24-
"ktlint_standard_wrapping" to "disabled"
25-
))
18+
// not sure why it's not using the indent settings from .editorconfig
19+
ktlint().editorConfigOverride(
20+
mapOf(
21+
"indent_size" to "2",
22+
"continuation_indent_size" to "2",
23+
"max_line_length" to "160",
24+
"ktlint_standard_no-wildcard-imports" to "disabled",
25+
// ktlint does not break up long lines, it just fails on them
26+
"ktlint_standard_max-line-length" to "disabled",
27+
// ktlint makes it *very* hard to locate where this actually happened
28+
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
29+
// depends on ktlint_standard_wrapping
30+
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
31+
// also very hard to find out where this happens
32+
"ktlint_standard_wrapping" to "disabled",
33+
// we use variable names like v1_10Deps
34+
"ktlint_standard_property-naming" to "disabled",
35+
// prevent moving comment to next line in latestDepTestLibrary("xxx") { // see xxx module
36+
"ktlint_standard_function-literal" to "disabled"
37+
)
38+
)
2639
}
27-
format("misc") {
28-
// not using "**/..." to help keep spotless fast
29-
target(
30-
".gitattributes",
31-
".gitconfig",
32-
".editorconfig",
33-
"*.md",
34-
"src/**/*.md",
35-
"docs/**/*.md",
36-
"*.sh",
37-
"src/**/*.properties")
38-
indentWithSpaces()
39-
trimTrailingWhitespace()
40-
endWithNewline()
40+
}
41+
42+
// Use root declared tool deps to avoid issues with high concurrency.
43+
// see https://github.com/diffplug/spotless/tree/main/plugin-gradle#dependency-resolution-modes
44+
if (project == rootProject) {
45+
spotless {
46+
format("misc") {
47+
target(
48+
".gitignore",
49+
".gitattributes",
50+
".gitconfig",
51+
".editorconfig",
52+
"**/*.md",
53+
"**/*.sh",
54+
"**/*.dockerfile",
55+
"**/gradle.properties"
56+
)
57+
leadingTabsToSpaces()
58+
trimTrailingWhitespace()
59+
endWithNewline()
60+
}
61+
predeclareDeps()
62+
}
63+
64+
with(extensions["spotlessPredeclare"] as SpotlessExtension) {
65+
java {
66+
googleJavaFormat()
67+
}
68+
kotlinGradle {
69+
ktlint()
70+
}
4171
}
4272
}

0 commit comments

Comments
 (0)