Skip to content

Commit 27c462c

Browse files
authored
Upgrade to Spotless 7 (#628)
1 parent c2e40ee commit 27c462c

File tree

93 files changed

+1373
-590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1373
-590
lines changed

.github/workflows/apply_spotless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
java-version: '17'
4343

4444
- name: Run spotlessApply
45-
run: ./gradlew spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
45+
run: ./gradlew spotlessApply --stacktrace
4646

4747
- name: Auto-commit if spotlessApply has changes
4848
uses: stefanzweifel/git-auto-commit-action@v5

bluetoothle/src/main/AndroidManifest.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
217
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
318

419
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
@@ -24,4 +39,4 @@
2439

2540
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2641
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
27-
</manifest>
42+
</manifest>
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
217
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
318
xmlns:app="http://schemas.android.com/apk/res-auto"
419
xmlns:tools="http://schemas.android.com/tools"
520
android:layout_width="match_parent"
621
android:layout_height="match_parent"
722
tools:context=".java.MainActivity">
823

9-
</androidx.constraintlayout.widget.ConstraintLayout>
24+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
117
<resources></resources>

build.gradle.kts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,89 @@ plugins {
1313
alias(libs.plugins.kotlin.multiplatform) apply false
1414
alias(libs.plugins.android.kotlin.multiplatform.library) apply false
1515
alias(libs.plugins.android.lint) apply false
16+
alias(libs.plugins.spotless) apply false
17+
}
18+
19+
subprojects {
20+
apply(plugin = "com.diffplug.spotless")
21+
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
22+
kotlin {
23+
target("**/*.kt")
24+
targetExclude("**/build/**/*.kt")
25+
26+
val disabledRules = arrayOf(
27+
// These rules were introduced in ktlint 0.46.0 and should not be
28+
// enabled without further discussion. They are disabled for now.
29+
// See: https://github.com/pinterest/ktlint/releases/tag/0.46.0
30+
"filename",
31+
"annotation",
32+
"annotation-spacing",
33+
"argument-list-wrapping",
34+
"double-colon-spacing",
35+
"enum-entry-name-case",
36+
"multiline-if-else",
37+
"no-empty-first-line-in-method-block",
38+
"package-name",
39+
"trailing-comma",
40+
"spacing-around-angle-brackets",
41+
"spacing-between-declarations-with-annotations",
42+
"spacing-between-declarations-with-comments",
43+
"unary-op-spacing",
44+
"no-trailing-spaces",
45+
"max-line-length",
46+
// Disabled rules that were introduced or changed between 0.46.0 ~ 1.50.0
47+
"class-signature",
48+
"trailing-comma-on-call-site",
49+
"trailing-comma-on-declaration-site",
50+
"comment-wrapping",
51+
"function-literal",
52+
"function-signature",
53+
"function-expression-body",
54+
"function-start-of-body-spacing",
55+
"multiline-expression-wrapping",
56+
)
57+
58+
ktlint(libs.versions.ktlint.get()).editorConfigOverride(
59+
mapOf(
60+
"android" to "true",
61+
"ktlint_code_style" to "android_studio",
62+
"ij_kotlin_allow_trailing_comma" to "true",
63+
) + disabledRules.map { Pair("ktlint_standard_$it", "disabled") }
64+
)
65+
66+
// ktlint 7.0.0 introduces lints, which existing snippets do not satisfy
67+
val kotlinSuppressLints = arrayOf(
68+
"standard:function-naming",
69+
"standard:property-naming",
70+
"standard:class-naming",
71+
"standard:max-line-length",
72+
"standard:comment-wrapping",
73+
"standard:import-ordering",
74+
"standard:filename",
75+
"standard:backing-property-naming",
76+
)
77+
for (lint in kotlinSuppressLints) {
78+
suppressLintsFor {
79+
step = "ktlint"
80+
shortCode = lint
81+
}
82+
}
83+
84+
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
85+
}
86+
kotlinGradle {
87+
target("**/*.kts")
88+
targetExclude("**/build/**/*.kts")
89+
// Look for the first line that doesn't have a block comment (assumed to be the license)
90+
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
91+
}
92+
format("xml") {
93+
target("**/*.xml")
94+
targetExclude("**/build/**/*.xml")
95+
// Look for the root tag or a tag that is a snippet
96+
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[a-zA-Z])|(<!--\\s+(//\\s*)?\\[START)").skipLinesMatching(".*START.*")
97+
}
98+
}
1699
}
17100

18101
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle")

compose/recomposehighlighter/src/main/AndroidManifest.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
217
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
318

419
<application
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<!--
2-
Copyright 2018 Google Inc. All rights reserved.
3-
Licensed under the Apache License, Version 2.0 (the "License");
4-
you may not use this file except in compliance with the License.
5-
You may obtain a copy of the License at
6-
http://www.apache.org/licenses/LICENSE-2.0
7-
Unless required by applicable law or agreed to in writing, software
8-
distributed under the License is distributed on an "AS IS" BASIS,
9-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10-
See the License for the specific language governing permissions and
11-
limitations under the License.
12-
-->
3+
Copyright 2018 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
1317
<resources>
1418
<string name="app_name">RecomposeHighlighter</string>
1519
</resources>
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
117
<resources xmlns:tools="http://schemas.android.com/tools">
218
<style name="Theme.RecomposeHighlighter.NoActionBar" parent="android:Theme.Material.Light.NoActionBar">
319

420
</style>
5-
</resources>
21+
</resources>

compose/snippets/lint.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
217
<lint>
318
<issue id="all">
419
<ignore regexp="src/.*/ConstraintLayoutSnippets.kt" />
520
</issue>
6-
</lint>
21+
</lint>

compose/snippets/src/main/AndroidManifest.xml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright 2023 The Android Open Source Project
4-
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ http://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
16-
~
17-
-->
3+
Copyright 2023 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
1817
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
1918
<uses-permission android:name="android.permission.INTERNET" />
2019
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@@ -70,4 +69,4 @@
7069
<!-- [END android_compose_glance_declare] -->
7170
</application>
7271

73-
</manifest>
72+
</manifest>

0 commit comments

Comments
 (0)