Skip to content

Commit 09a71ee

Browse files
Merge branch 'autonomousapps:main' into simplify-kotlin-compile-configuration
2 parents baf9e58 + c9b15ef commit 09a71ee

File tree

29 files changed

+394
-64
lines changed

29 files changed

+394
-64
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
Dependency Analysis Plugin Changelog
22

3+
# Version 2.7.0 (unreleased)
4+
* [Feat]: can set severity and filter duplicate class warnings.
5+
6+
New DSL option for configuring duplicate class warnings:
7+
```groovy
8+
// root build.gradle[.kts]
9+
dependencyAnalysis {
10+
issues {
11+
all {
12+
onDuplicateClassWarnings {
13+
severity(<"fail"|"warn"|"ignore">)
14+
// Fully-qualified class reference to exclude, slash- or dot-delimited
15+
exclude("org/jetbrains/annotations/NotNull", "org.jetbrains.annotations.Nullable")
16+
}
17+
}
18+
}
19+
}
20+
```
21+
22+
# Version 2.6.1
23+
* [Fix]: `superClassName` can be null (Object has no superclass).
24+
325
# Version 2.6.0
426
* [Feat]: improvements relating to generating project graphs.
527
* [Fix]: use stable kotlin-metadata 2.0.21.

README.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ behaviors, but they may be interesting for some advanced users.
1818
In addition to the dependency-related advice (see above), DAGP provides other advice to help maintain your "build health." This includes the detection of:
1919

2020
1. Unnecessary plugins (currently only `kapt`).
21-
2. Subprojects ("modules") that unnecessarily use the Android plugin, and could instead by "normal" JVM libraries.
21+
2. Subprojects ("modules") that unnecessarily use the Android plugin, and could instead be "normal" JVM libraries.
2222

2323
== Compatibilities
2424

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Release procedure for dependency-analysis-android-gradle-plugin
66
_with_ the `-SNAPSHOT` suffix (we publish a snapshot first for smoke testing).
77
1. Publish the snapshot to Maven Central: `./gradlew :publishEverywhere`
88
1. Remove the `-SNAPSHOT` suffix from the version name.
9-
1. `git commit -am "Prepare for release x.y.z."`
9+
1. `git commit -am "chore: prepare for release x.y.z."`
1010
1. Publish again: `./gradlew :publishEverywhere -x :functionalTest`
1111
(this will automatically run the smoke tests, and won't publish if they fail)
1212
1. `git tag -a vx.y.z -m "Version x.y.z."`
1313
1. Update version number in `gradle.properties` to next snapshot version (x.y.z-SNAPSHOT)
14-
1. `git commit -am "Prepare next development version."`
14+
1. `git commit -am "chore: prepare next development version."`
1515
1. `git push && git push --tags`
1616
1. (Optional) Follow instructions in console output to release from Maven Central's staging repo.
1717
This step is now automated via the `:promote` task, and should only be necessary if that task

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ org.gradle.parallel=true
99
org.gradle.configuration-cache=true
1010
org.gradle.configuration-cache.parallel=true
1111

12-
VERSION=2.6.1-SNAPSHOT
12+
VERSION=2.6.2-SNAPSHOT
1313

1414
dependency.analysis.print.build.health=true
1515

settings.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ pluginManagement {
2828
}
2929
}
3030
plugins {
31-
id("com.github.johnrengelman.shadow") version "8.1.1"
31+
id("com.gradleup.shadow") version "8.3.0"
3232
id("com.gradle.develocity") version "3.18.2"
3333
id("com.gradle.plugin-publish") version "1.1.0"
3434
}
3535
}
3636

3737
plugins {
3838
id("com.gradle.develocity")
39-
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
39+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
4040
}
4141

4242
// Yes, this is also in pluginManagement above. This is required for normal dependencies.

shadowed/antlr/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
plugins {
66
`java-library`
77
antlr
8-
id("com.github.johnrengelman.shadow")
8+
id("com.gradleup.shadow")
99
groovy
1010
id("convention")
1111
// This project doesn't need Kotlin, but it is now applied thanks to `convention`. problem?

shadowed/asm-relocated/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
plugins {
44
`java-library`
5-
id("com.github.johnrengelman.shadow")
5+
id("com.gradleup.shadow")
66
id("convention")
77
// This project doesn't need Kotlin, but it is now applied thanks to `convention`. problem?
88
}

shadowed/kotlin-editor-relocated/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id("convention")
3-
id("com.github.johnrengelman.shadow")
3+
id("com.gradleup.shadow")
44
}
55

66
version = "${libs.versions.kotlineditor.core.get()}.1-SNAPSHOT"

src/functionalTest/groovy/com/autonomousapps/jvm/DuplicateClasspathSpec.groovy

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ final class DuplicateClasspathSpec extends AbstractJvmSpec {
2727
2828
then:
2929
assertThat(result.task(':consumer:compileJava').outcome).isEqualTo(TaskOutcome.FAILED)
30-
// assertThat(gradleProject.rootDir.toPath().resolve('consumer/build.gradle').text).contains(
31-
// '''\
32-
// dependencies {
33-
// implementation project(':producer-2')
34-
// }'''.stripIndent()
35-
// )
30+
// assertThat(gradleProject.rootDir.toPath().resolve('consumer/build.gradle').text).contains(
31+
// '''\
32+
// dependencies {
33+
// implementation project(':producer-2')
34+
// }'''.stripIndent()
35+
// )
3636
3737
where:
3838
gradleVersion << [GRADLE_LATEST]
@@ -71,6 +71,57 @@ final class DuplicateClasspathSpec extends AbstractJvmSpec {
7171
gradleVersion << [GRADLE_LATEST]
7272
}
7373
74+
def "buildHealth reports filters duplicates (#gradleVersion)"() {
75+
given:
76+
def project = new DuplicateClasspathProject('com/example/producer/Producer$Inner')
77+
gradleProject = project.gradleProject
78+
79+
when:
80+
def result = buildAndFail(gradleVersion, gradleProject.rootDir, 'buildHealth')
81+
82+
then:
83+
assertThat(result.output).contains(
84+
'''\
85+
Warnings
86+
Some of your classpaths have duplicate classes, which means the compile and runtime behavior can be sensitive to the classpath order.
87+
88+
Source set: main
89+
\\--- compile classpath
90+
\\--- com/example/producer/Producer is provided by multiple dependencies: [:producer-1, :producer-2]
91+
\\--- runtime classpath
92+
\\--- com/example/producer/Producer is provided by multiple dependencies: [:producer-1, :producer-2]'''
93+
.stripIndent()
94+
)
95+
96+
and:
97+
assertAbout(buildHealth())
98+
.that(project.actualProjectAdvice())
99+
.isEquivalentIgnoringModuleAdviceAndWarnings(project.expectedProjectAdvice)
100+
101+
where:
102+
gradleVersion << [GRADLE_LATEST]
103+
}
104+
105+
def "buildHealth reports ignores duplicates (#gradleVersion)"() {
106+
given:
107+
def project = new DuplicateClasspathProject(null, 'ignore')
108+
gradleProject = project.gradleProject
109+
110+
when:
111+
def result = buildAndFail(gradleVersion, gradleProject.rootDir, 'buildHealth')
112+
113+
then:
114+
assertThat(result.output).doesNotContain('Warnings')
115+
116+
and:
117+
assertAbout(buildHealth())
118+
.that(project.actualProjectAdvice())
119+
.isEquivalentIgnoringModuleAdviceAndWarnings(project.expectedProjectAdvice)
120+
121+
where:
122+
gradleVersion << [GRADLE_LATEST]
123+
}
124+
74125
@PendingFeature(reason = "This feature was reverted")
75126
def "can report on which of the duplicates is needed for binary compatibility (#gradleVersion)"() {
76127
given:

src/functionalTest/groovy/com/autonomousapps/jvm/projects/DuplicateClasspathProject.groovy

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,17 @@ final class DuplicateClasspathProject extends AbstractProject {
1313

1414
final GradleProject gradleProject
1515

16-
DuplicateClasspathProject() {
17-
this.gradleProject = build()
16+
DuplicateClasspathProject(String filter = null, String severity = null) {
17+
this.gradleProject = build(filter, severity)
1818
}
1919

20-
private GradleProject build() {
20+
private GradleProject build(String filter, String severity) {
21+
def configuration = new DagpConfiguration(filter, severity).toString()
22+
2123
return newGradleProjectBuilder()
2224
.withRootProject { r ->
2325
r.withBuildScript { bs ->
24-
bs.withGroovy(
25-
'''\
26-
dependencyAnalysis {
27-
issues {
28-
all {
29-
onAny {
30-
severity 'fail'
31-
}
32-
}
33-
}
34-
}'''.stripIndent()
35-
)
26+
bs.withGroovy(configuration)
3627
}
3728
}
3829
// :consumer uses the Producer class.
@@ -187,4 +178,43 @@ final class DuplicateClasspathProject extends AbstractProject {
187178
emptyProjectAdviceFor(':producer-1'),
188179
emptyProjectAdviceFor(':producer-2'),
189180
]
181+
182+
static class DagpConfiguration {
183+
184+
private final String filter
185+
private final String severity
186+
187+
DagpConfiguration(String filter, String severity) {
188+
this.filter = filter
189+
this.severity = severity
190+
}
191+
192+
@Override
193+
String toString() {
194+
def builder = new StringBuilder()
195+
builder.append('dependencyAnalysis {\n')
196+
builder.append(' issues {\n')
197+
builder.append(' all {\n')
198+
builder.append(' onAny {\n')
199+
builder.append(' severity \'fail\'\n')
200+
builder.append(' }\n')
201+
202+
if (filter || severity) {
203+
builder.append(' onDuplicateClassWarnings {\n')
204+
if (severity) {
205+
builder.append(" severity \'$severity\'\n")
206+
}
207+
if (filter) {
208+
builder.append(" exclude \'$filter\'\n")
209+
}
210+
builder.append(' }\n')
211+
}
212+
213+
builder.append(' }\n')
214+
builder.append(' }\n')
215+
builder.append('}')
216+
217+
return builder.toString()
218+
}
219+
}
190220
}

0 commit comments

Comments
 (0)