Skip to content

Commit 8681a40

Browse files
Laimiuxclaude
andcommitted
refactor: rename regexPatterns to excludedRegexPatterns for consistency
Improves API clarity by making the property name match the excludePackages and excludeTypes pattern. Also removes unnecessary dependsOn from computeAdviceTask - the type usage task should only run when explicitly invoked, not as part of buildHealth. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 67a0f99 commit 8681a40

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025. Tony Robalik.
1+
// Copyright (c) 2026. Tony Robalik.
22
// SPDX-License-Identifier: Apache-2.0
33
package com.autonomousapps.jvm
44

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025. Tony Robalik.
1+
// Copyright (c) 2026. Tony Robalik.
22
// SPDX-License-Identifier: Apache-2.0
33
package com.autonomousapps.jvm.projects
44

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025. Tony Robalik.
1+
// Copyright (c) 2026. Tony Robalik.
22
// SPDX-License-Identifier: Apache-2.0
33
package com.autonomousapps.jvm.projects
44

src/main/kotlin/com/autonomousapps/extension/TypeUsageHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public abstract class TypeUsageHandler @Inject constructor(
4545
))
4646

4747
// Regex patterns for flexible matching
48-
internal val regexPatterns: ListProperty<String> = objects.listProperty(String::class.java)
48+
internal val excludedRegexPatterns: ListProperty<String> = objects.listProperty(String::class.java)
4949
.convention(listOf(
5050
"^anvil\\.hint\\..*",
5151
".*_Factory$",
@@ -89,6 +89,6 @@ public abstract class TypeUsageHandler @Inject constructor(
8989
public fun excludeRegex(
9090
@org.intellij.lang.annotations.Language("RegExp") vararg patterns: String
9191
) {
92-
regexPatterns.addAll(patterns.toList())
92+
excludedRegexPatterns.addAll(patterns.toList())
9393
}
9494
}

src/main/kotlin/com/autonomousapps/subplugin/ProjectPlugin.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,6 @@ internal class ProjectPlugin(private val project: Project) {
10701070
t.checkSuperClasses.set(dagpExtension.usageHandler.analysisHandler.checkSuperClasses)
10711071
// Currently only modeling this via Gradle property. May hoist it to the DSL if it's necessary.
10721072
t.checkBinaryCompat.set(checkBinaryCompat())
1073-
10741073
t.graph.set(graphViewTask.flatMap { it.output })
10751074
t.declarations.set(findDeclarationsTask.flatMap { it.output })
10761075
t.dependencies.set(synthesizeDependenciesTask.flatMap { it.outputDir })
@@ -1090,7 +1089,7 @@ internal class ProjectPlugin(private val project: Project) {
10901089
// Configuration from extension
10911090
t.excludedPackages.set(dagpExtension.typeUsageHandler.excludedPackages)
10921091
t.excludedTypes.set(dagpExtension.typeUsageHandler.excludedTypes)
1093-
t.regexPatterns.set(dagpExtension.typeUsageHandler.regexPatterns)
1092+
t.excludedRegexPatterns.set(dagpExtension.typeUsageHandler.excludedRegexPatterns)
10941093

10951094
t.output.set(outputPaths.typeUsagePath)
10961095
}

src/main/kotlin/com/autonomousapps/tasks/ComputeTypeUsageTask.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public abstract class ComputeTypeUsageTask @Inject constructor(
5252
public abstract val excludedTypes: SetProperty<String>
5353

5454
@get:Input
55-
public abstract val regexPatterns: ListProperty<String>
55+
public abstract val excludedRegexPatterns: ListProperty<String>
5656

5757
@get:OutputFile
5858
public abstract val output: RegularFileProperty
@@ -65,7 +65,7 @@ public abstract class ComputeTypeUsageTask @Inject constructor(
6565
it.explodedJars.set(explodedJars)
6666
it.excludedPackages.set(excludedPackages)
6767
it.excludedTypes.set(excludedTypes)
68-
it.regexPatterns.set(regexPatterns)
68+
it.excludedRegexPatterns.set(excludedRegexPatterns)
6969
it.output.set(output)
7070
}
7171
}
@@ -76,7 +76,7 @@ public abstract class ComputeTypeUsageTask @Inject constructor(
7676
public val explodedJars: RegularFileProperty
7777
public val excludedPackages: SetProperty<String>
7878
public val excludedTypes: SetProperty<String>
79-
public val regexPatterns: ListProperty<String>
79+
public val excludedRegexPatterns: ListProperty<String>
8080
public val output: RegularFileProperty
8181
}
8282

@@ -93,7 +93,7 @@ public abstract class ComputeTypeUsageTask @Inject constructor(
9393
val filter = TypeFilter(
9494
excludedPackages = parameters.excludedPackages.get(),
9595
excludedTypes = parameters.excludedTypes.get(),
96-
regexPatterns = parameters.regexPatterns.get()
96+
excludedRegexPatterns = parameters.excludedRegexPatterns.get()
9797
)
9898

9999
// 3. Analyze usage
@@ -130,9 +130,9 @@ public abstract class ComputeTypeUsageTask @Inject constructor(
130130
private class TypeFilter(
131131
val excludedPackages: Set<String>,
132132
val excludedTypes: Set<String>,
133-
regexPatterns: List<String>
133+
excludedRegexPatterns: List<String>
134134
) {
135-
private val compiledPatterns = regexPatterns.map { it.toRegex() }
135+
private val compiledPatterns = excludedRegexPatterns.map { it.toRegex() }
136136

137137
fun shouldExclude(className: String): Boolean {
138138
if (excludedTypes.contains(className)) return true

0 commit comments

Comments
 (0)