Skip to content

Commit

Permalink
refactor(plugins-api)!: Make PluginDescriptor.id the first argument
Browse files Browse the repository at this point in the history
The unique `id` of a plugin is the most important property in the
`PluginDescriptor`, so move it to the first place.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
  • Loading branch information
mnonnenmacher committed Sep 2, 2024
1 parent d15eaa1 commit d782466
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion advisor/src/test/kotlin/AdvisorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private fun createPackage(index: Int): Package =

private fun mockkAdviceProvider(): AdviceProvider =
mockk<AdviceProvider>().apply {
every { descriptor } returns PluginDescriptor("provider", "Provider", "", emptyList())
every { descriptor } returns PluginDescriptor("Provider", "provider", "", emptyList())
}

private fun mockkAdvisorResult(): AdvisorResult =
Expand Down
8 changes: 4 additions & 4 deletions plugins/api/src/main/kotlin/PluginDescriptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ package org.ossreviewtoolkit.plugins.api
*/
data class PluginDescriptor(
/**
* The display name of the plugin.
* The name of the plugin class. Must be unique among all plugins for the same factory class.
*/
val displayName: String,
val id: String,

/**
* The name of the plugin class. Must be unique among all plugins for the same factory class.
* The display name of the plugin.
*/
val id: String,
val displayName: String,

/**
* The description of the plugin.
Expand Down
2 changes: 1 addition & 1 deletion plugins/compiler/src/main/kotlin/JsonSpecGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class JsonSpecGenerator(private val codeGenerator: CodeGenerator) {
fun generate(pluginSpec: PluginSpec) {
val jsonObject = buildJsonObject {
putJsonObject("descriptor") {
put("displayName", pluginSpec.descriptor.displayName)
put("id", pluginSpec.descriptor.id)
put("displayName", pluginSpec.descriptor.displayName)
put("description", pluginSpec.descriptor.description)

putJsonArray("options") {
Expand Down
4 changes: 2 additions & 2 deletions plugins/compiler/src/main/kotlin/PluginFactoryGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ class PluginFactoryGenerator(private val codeGenerator: CodeGenerator) {
add(
"""
PluginDescriptor(
displayName = %S,
id = %S,
displayName = %S,
description = %S,
options = listOf(
""".trimIndent(),
descriptor.displayName,
descriptor.id,
descriptor.displayName,
descriptor.description
)

Expand Down
2 changes: 1 addition & 1 deletion plugins/compiler/src/main/kotlin/PluginSpecFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class PluginSpecFactory {
return PluginSpec(
containingFile = pluginClass.containingFile,
descriptor = PluginDescriptor(
displayName = ortPlugin.name,
id = pluginClass.simpleName.asString(),
displayName = ortPlugin.name,
description = ortPlugin.description,
options = pluginOptions
),
Expand Down

0 comments on commit d782466

Please sign in to comment.