Skip to content

Commit 9976152

Browse files
committed
convert suffixes and exclusions to SetProperty
1 parent 6a6e0e9 commit 9976152

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package datadog.gradle.plugin.naming
22

3-
import org.gradle.api.provider.ListProperty
43
import org.gradle.api.provider.Property
4+
import org.gradle.api.provider.SetProperty
55

66
/**
77
* Extension for configuring instrumentation naming convention checks.
@@ -10,8 +10,8 @@ import org.gradle.api.provider.Property
1010
* ```
1111
* instrumentationNaming {
1212
* instrumentationsDir.set(file("dd-java-agent/instrumentation"))
13-
* exclusions.set(listOf("http-url-connection", "sslsocket"))
14-
* suffixes.set(listOf("-common", "-stubs""))
13+
* exclusions.set(setOf("http-url-connection", "sslsocket"))
14+
* suffixes.set(setOf("-common", "-stubs"))
1515
* }
1616
* ```
1717
*/
@@ -23,21 +23,21 @@ abstract class InstrumentationNamingExtension {
2323
abstract val instrumentationsDir: Property<String>
2424

2525
/**
26-
* List of module names to exclude from naming convention checks.
26+
* Set of module names to exclude from naming convention checks.
2727
* These modules will not be validated against the naming rules.
2828
*/
29-
abstract val exclusions: ListProperty<String>
29+
abstract val exclusions: SetProperty<String>
3030

3131
/**
32-
* List of allowed suffixes for module names (e.g., "-common", "-stubs").
32+
* Set of allowed suffixes for module names (e.g., "-common", "-stubs").
3333
* Module names must end with either one of these suffixes or a version number.
3434
* Defaults to ["-common", "-stubs"].
3535
*/
36-
abstract val suffixes: ListProperty<String>
36+
abstract val suffixes: SetProperty<String>
3737

3838
init {
3939
instrumentationsDir.convention("dd-java-agent/instrumentation")
40-
exclusions.convention(emptyList())
41-
suffixes.convention(listOf("-common", "-stubs"))
40+
exclusions.convention(emptySet())
41+
suffixes.convention(setOf("-common", "-stubs"))
4242
}
4343
}

buildSrc/src/main/kotlin/datadog/gradle/plugin/naming/InstrumentationNamingPlugin.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class InstrumentationNamingPlugin : Plugin<Project> {
3333

3434
doLast {
3535
val instrumentationsDir = target.rootProject.file(extension.instrumentationsDir)
36-
val exclusions = extension.exclusions.get().toSet()
36+
val exclusions = extension.exclusions.get()
3737
val suffixes = extension.suffixes.get()
3838

3939
if (!instrumentationsDir.exists() || !instrumentationsDir.isDirectory) {
@@ -62,8 +62,8 @@ class InstrumentationNamingPlugin : Plugin<Project> {
6262
6363
To exclude specific modules or customize suffixes, configure the plugin:
6464
instrumentationNaming {
65-
exclusions.set(listOf("module-name"))
66-
suffixes.set(listOf("-common", "-stubs"))
65+
exclusions.set(setOf("module-name"))
66+
suffixes.set(setOf("-common", "-stubs"))
6767
}
6868
""".trimIndent())
6969
}
@@ -78,7 +78,7 @@ class InstrumentationNamingPlugin : Plugin<Project> {
7878
private fun validateInstrumentations(
7979
instrumentationsDir: File,
8080
exclusions: Set<String>,
81-
suffixes: List<String>
81+
suffixes: Set<String>
8282
): List<NamingViolation> {
8383
val violations = mutableListOf<NamingViolation>()
8484

@@ -123,7 +123,7 @@ class InstrumentationNamingPlugin : Plugin<Project> {
123123
moduleName: String,
124124
parentName: String,
125125
relativePath: String,
126-
suffixes: List<String>
126+
suffixes: Set<String>
127127
): List<NamingViolation> {
128128
// Rule 1: Module name must end with version pattern or one of the configured suffixes
129129
validateVersionOrSuffix(moduleName, relativePath, suffixes)?.let { return listOf(it) }
@@ -146,7 +146,7 @@ class InstrumentationNamingPlugin : Plugin<Project> {
146146
private fun validateLeafModuleName(
147147
moduleName: String,
148148
relativePath: String,
149-
suffixes: List<String>
149+
suffixes: Set<String>
150150
): NamingViolation? {
151151
return validateVersionOrSuffix(moduleName, relativePath, suffixes)
152152
}
@@ -157,7 +157,7 @@ class InstrumentationNamingPlugin : Plugin<Project> {
157157
private fun validateVersionOrSuffix(
158158
moduleName: String,
159159
relativePath: String,
160-
suffixes: List<String>
160+
suffixes: Set<String>
161161
): NamingViolation? {
162162
val endsWithSuffix = suffixes.any { moduleName.endsWith(it) }
163163
val endsWithVersion = versionPattern.containsMatchIn(moduleName)

0 commit comments

Comments
 (0)