Skip to content

Commit a619daf

Browse files
authored
Do not use objects container to retreive project name, compute it statically once instead (#57)
1 parent 8aa1533 commit a619daf

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/main/kotlin/ApiCompareCompareTask.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ open class ApiCompareCompareTask @Inject constructor(private val objects: Object
3939
@Optional
4040
val dummyOutputFile: File? = null
4141

42-
@get:Input
43-
internal val projectName = objects.property(String::class.java)
42+
private val projectName = project.name
4443

4544
private val rootDir = project.rootProject.rootDir
4645

@@ -52,7 +51,7 @@ open class ApiCompareCompareTask @Inject constructor(private val objects: Object
5251
"Please ensure that ':apiDump' was executed in order to get API dump to compare the build against")
5352
}
5453

55-
val subject = projectName.get()
54+
val subject = projectName
5655
val apiBuildDirFiles = mutableSetOf<RelativePath>()
5756
val expectedApiFiles = mutableSetOf<RelativePath>()
5857
objects.fileTree().from(apiBuildDir).visit { file ->

src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ private fun Project.configureKotlinCompilation(
9797
inputDependencies = files(provider<Any> { if (isEnabled) compilation.compileDependencyFiles else emptyList<Any>() })
9898
}
9999
outputApiDir = apiBuildDir
100-
this.projectName.set(project.name)
101100
}
102101
configureCheckTasks(apiBuildDir, apiBuild, extension)
103102
}
@@ -119,7 +118,6 @@ private fun Project.configureApiTasks(sourceSet: SourceSet, extension: ApiValida
119118
inputClassesDirs = files(provider<Any> { if (isEnabled) sourceSet.output.classesDirs else emptyList<Any>() })
120119
inputDependencies = files(provider<Any> { if (isEnabled) sourceSet.output.classesDirs else emptyList<Any>() })
121120
outputApiDir = apiBuildDir
122-
this.projectName.set(project.name)
123121
}
124122

125123
configureCheckTasks(apiBuildDir, apiBuild, extension)
@@ -143,7 +141,6 @@ private fun Project.configureCheckTasks(
143141
null
144142
}
145143
this.apiBuildDir = apiBuildDir
146-
this.projectName.set(project.name)
147144
dependsOn(apiBuild)
148145
}
149146

src/main/kotlin/KotlinApiBuildTask.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ open class KotlinApiBuildTask @Inject constructor(
3636
@get:Input
3737
val ignoredClasses : Set<String> get() = extension.ignoredClasses
3838

39-
@get:Input
40-
val projectName = project.objects.property(String::class.java)
39+
@get:Internal
40+
internal val projectName = project.name
4141

4242
@TaskAction
4343
fun generate() {
@@ -53,7 +53,7 @@ open class KotlinApiBuildTask @Inject constructor(
5353
.filterOutNonPublic(ignoredPackages, ignoredClasses)
5454
.filterOutAnnotated(nonPublicMarkers.map { it.replace(".", "/") }.toSet())
5555

56-
outputApiDir.resolve("${projectName.get()}.api").bufferedWriter().use { writer ->
56+
outputApiDir.resolve("$projectName.api").bufferedWriter().use { writer ->
5757
signatures
5858
.sortedBy { it.name }
5959
.forEach { api ->

0 commit comments

Comments
 (0)