GoogleArchitectureSamples
59 строк · 2.2 Кб
1/*
2* Copyright 2022 The Android Open Source Project
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* https://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16
17// The init script is used to run Spotless in a gradle configuration cache compliant manner as
18// Spotless itself is not gradle configuration cache compliant.
19// Note that the init script needs to be run with the configuration cache turned off.
20
21val ktlintVersion = "0.44.0"
22
23initscript {
24val spotlessVersion = "6.13.0"
25
26repositories {
27mavenCentral()
28}
29
30dependencies {
31classpath("com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion")
32}
33}
34
35rootProject {
36subprojects {
37apply<com.diffplug.gradle.spotless.SpotlessPlugin>()
38extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
39kotlin {
40target("**/*.kt")
41targetExclude("**/build/**/*.kt")
42ktlint(ktlintVersion).userData(mapOf("android" to "true"))
43licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
44}
45format("kts") {
46target("**/*.kts")
47targetExclude("**/build/**/*.kts")
48// Look for the first line that doesn't have a block comment (assumed to be the license)
49licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
50}
51format("xml") {
52target("**/*.xml")
53targetExclude("**/build/**/*.xml")
54// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
55licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
56}
57}
58}
59}