Skip to content

Commit 2cae500

Browse files
authored
Add AndroidX Gradle plugin lints (#1033)
1 parent 09cf965 commit 2cae500

File tree

3 files changed

+256
-0
lines changed

3 files changed

+256
-0
lines changed

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77
id("shadow.convention.publish")
88
id("shadow.convention.deploy")
99
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.16.3"
10+
id("com.android.lint") version "8.7.2"
1011
id("com.diffplug.spotless") version "7.0.0.BETA4"
1112
}
1213

@@ -27,6 +28,10 @@ kotlin {
2728
}
2829
}
2930

31+
lint {
32+
baseline = file("lint-baseline.xml")
33+
}
34+
3035
spotless {
3136
kotlin {
3237
ktlint()
@@ -58,6 +63,8 @@ dependencies {
5863
testImplementation(platform("org.junit:junit-bom:5.11.3"))
5964
testImplementation("org.junit.jupiter:junit-jupiter")
6065
testImplementation("org.junit.platform:junit-platform-suite-engine")
66+
67+
lintChecks("androidx.lint:lint-gradle:1.0.0-alpha02")
6168
}
6269

6370
val isCI = providers.environmentVariable("CI").isPresent

lint-baseline.xml

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<issues format="6" by="lint 8.7.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.2)" variant="all" version="8.7.2">
3+
4+
<issue
5+
id="SimpleDateFormat"
6+
message="To get local formatting use `getDateInstance()`, `getDateTimeInstance()`, or `getTimeInstance()`, or use `new SimpleDateFormat(String template, Locale locale)` with for example `Locale.US` for ASCII dates."
7+
errorLine1=" val year = SimpleDateFormat(&quot;yyyy&quot;).format(Date()).let {"
8+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
9+
<location
10+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformer.kt"
11+
line="75"
12+
column="18"/>
13+
</issue>
14+
15+
<issue
16+
id="EagerGradleConfiguration"
17+
message="Avoid using method get"
18+
errorLine1=" project.file(&quot;${install.get().destinationDir.path}/lib/${shadowJar.get().archiveFile.get().asFile.name}&quot;)"
19+
errorLine2=" ~~~">
20+
<location
21+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.kt"
22+
line="54"
23+
column="35"/>
24+
</issue>
25+
26+
<issue
27+
id="EagerGradleConfiguration"
28+
message="Avoid using method get"
29+
errorLine1=" project.file(&quot;${install.get().destinationDir.path}/lib/${shadowJar.get().archiveFile.get().asFile.name}&quot;)"
30+
errorLine2=" ~~~">
31+
<location
32+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.kt"
33+
line="54"
34+
column="78"/>
35+
</issue>
36+
37+
<issue
38+
id="EagerGradleConfiguration"
39+
message="Avoid using method get"
40+
errorLine1=" shadow.manifest.inheritFrom(jarTask.get().manifest)"
41+
errorLine2=" ~~~">
42+
<location
43+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt"
44+
line="81"
45+
column="43"/>
46+
</issue>
47+
48+
<issue
49+
id="InternalGradleApiUsage"
50+
message="Avoid using internal Gradle APIs"
51+
errorLine1="import org.gradle.api.internal.file.FileResolver"
52+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
53+
<location
54+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/DefaultInheritManifest.kt"
55+
line="4"
56+
column="1"/>
57+
</issue>
58+
59+
<issue
60+
id="InternalGradleApiUsage"
61+
message="Avoid using internal Gradle APIs"
62+
errorLine1="import org.gradle.api.java.archives.internal.DefaultManifest"
63+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
64+
<location
65+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/DefaultInheritManifest.kt"
66+
line="6"
67+
column="1"/>
68+
</issue>
69+
70+
<issue
71+
id="InternalGradleApiUsage"
72+
message="Avoid using internal Gradle APIs"
73+
errorLine1="import org.gradle.api.java.archives.internal.DefaultManifestMergeSpec"
74+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
75+
<location
76+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/DefaultInheritManifest.kt"
77+
line="7"
78+
column="1"/>
79+
</issue>
80+
81+
<issue
82+
id="InternalGradleApiUsage"
83+
message="Avoid using internal Gradle APIs"
84+
errorLine1="import org.gradle.api.internal.DocumentationRegistry"
85+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
86+
<location
87+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt"
88+
line="25"
89+
column="1"/>
90+
</issue>
91+
92+
<issue
93+
id="InternalGradleApiUsage"
94+
message="Avoid using internal Gradle APIs"
95+
errorLine1="import org.gradle.api.internal.file.CopyActionProcessingStreamAction"
96+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
97+
<location
98+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt"
99+
line="26"
100+
column="1"/>
101+
</issue>
102+
103+
<issue
104+
id="InternalGradleApiUsage"
105+
message="Avoid using internal Gradle APIs"
106+
errorLine1="import org.gradle.api.internal.file.DefaultFilePermissions"
107+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
108+
<location
109+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt"
110+
line="27"
111+
column="1"/>
112+
</issue>
113+
114+
<issue
115+
id="InternalGradleApiUsage"
116+
message="Avoid using internal Gradle APIs"
117+
errorLine1="import org.gradle.api.internal.file.DefaultFileTreeElement"
118+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
119+
<location
120+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt"
121+
line="28"
122+
column="1"/>
123+
</issue>
124+
125+
<issue
126+
id="InternalGradleApiUsage"
127+
message="Avoid using internal Gradle APIs"
128+
errorLine1="import org.gradle.api.internal.file.copy.CopyAction"
129+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
130+
<location
131+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt"
132+
line="29"
133+
column="1"/>
134+
</issue>
135+
136+
<issue
137+
id="InternalGradleApiUsage"
138+
message="Avoid using internal Gradle APIs"
139+
errorLine1="import org.gradle.api.internal.file.copy.CopyActionProcessingStream"
140+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
141+
<location
142+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt"
143+
line="30"
144+
column="1"/>
145+
</issue>
146+
147+
<issue
148+
id="InternalGradleApiUsage"
149+
message="Avoid using internal Gradle APIs"
150+
errorLine1="import org.gradle.api.internal.file.copy.FileCopyDetailsInternal"
151+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
152+
<location
153+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt"
154+
line="31"
155+
column="1"/>
156+
</issue>
157+
158+
<issue
159+
id="InternalGradleApiUsage"
160+
message="Avoid using internal Gradle APIs"
161+
errorLine1="import org.gradle.api.internal.DocumentationRegistry"
162+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
163+
<location
164+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt"
165+
line="24"
166+
column="1"/>
167+
</issue>
168+
169+
<issue
170+
id="InternalGradleApiUsage"
171+
message="Avoid using internal Gradle APIs"
172+
errorLine1="import org.gradle.api.internal.file.FileResolver"
173+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
174+
<location
175+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt"
176+
line="25"
177+
column="1"/>
178+
</issue>
179+
180+
<issue
181+
id="InternalGradleApiUsage"
182+
message="Avoid using internal Gradle APIs"
183+
errorLine1="import org.gradle.api.internal.file.copy.CopyAction"
184+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
185+
<location
186+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt"
187+
line="26"
188+
column="1"/>
189+
</issue>
190+
191+
<issue
192+
id="InternalGradleApiUsage"
193+
message="Avoid using internal Gradle APIs"
194+
errorLine1="import org.gradle.api.internal.file.copy.DefaultCopySpec"
195+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
196+
<location
197+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt"
198+
line="27"
199+
column="1"/>
200+
</issue>
201+
202+
<issue
203+
id="InternalGradleApiUsage"
204+
message="Avoid using internal Gradle APIs"
205+
errorLine1="import org.gradle.api.internal.file.archive.compression.ArchiveOutputStreamFactory"
206+
errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
207+
<location
208+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ZipCompressor.kt"
209+
line="3"
210+
column="1"/>
211+
</issue>
212+
213+
<issue
214+
id="WithTypeWithoutConfigureEach"
215+
message="Avoid passing a closure to withType, use withType().configureEach instead"
216+
errorLine1=" plugins.withType(JavaPlugin::class.java) {"
217+
errorLine2=" ~~~~~~~~">
218+
<location
219+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.kt"
220+
line="14"
221+
column="15"/>
222+
</issue>
223+
224+
<issue
225+
id="WithTypeWithoutConfigureEach"
226+
message="Avoid passing a closure to withType, use withType().configureEach instead"
227+
errorLine1=" plugins.withType(ApplicationPlugin::class.java) {"
228+
errorLine2=" ~~~~~~~~">
229+
<location
230+
file="src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.kt"
231+
line="17"
232+
column="15"/>
233+
</issue>
234+
235+
</issues>

settings.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
pluginManagement {
22
repositories {
33
mavenCentral()
4+
google {
5+
mavenContent {
6+
includeGroupAndSubgroups("androidx")
7+
includeGroupAndSubgroups("com.android")
8+
includeGroupAndSubgroups("com.google")
9+
}
10+
}
411
gradlePluginPortal()
512
}
613

@@ -24,6 +31,13 @@ develocity {
2431
dependencyResolutionManagement {
2532
repositories {
2633
mavenCentral()
34+
google {
35+
mavenContent {
36+
includeGroupAndSubgroups("androidx")
37+
includeGroupAndSubgroups("com.android")
38+
includeGroupAndSubgroups("com.google")
39+
}
40+
}
2741
}
2842
}
2943

0 commit comments

Comments
 (0)