forked from oss-review-toolkit/ort
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(vcs): Enable to provide VCS-specific configuration options
While VCS implementations are already plugins, they are not yet configurable. VCS implementations require common configurations (e.g., `revision`, `recursive`) and should support also VCS-specific configurations if they are consumed via their API. This allows to add functionality to individual VCS implementations without the need to implement them for all of them. Fixes oss-review-toolkit#8556. Signed-off-by: Wolfgang Klenk <[email protected]>
- Loading branch information
Showing
21 changed files
with
427 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2024 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
|
||
package org.ossreviewtoolkit.downloader | ||
|
||
import org.ossreviewtoolkit.utils.common.Plugin | ||
import org.ossreviewtoolkit.utils.common.TypedConfigurablePluginFactory | ||
|
||
/** | ||
* An abstract class to be implemented by factories for [version contral systems][VersionControlSystem]. | ||
* The constructor parameter [type] denotes which VCS type is supported by this plugin. | ||
* The constructor parameter [priority] is used to determine the order in which the VCS plugins are used. | ||
*/ | ||
abstract class VersionControlSystemFactory<CONFIG>(override val type: String, val priority: Int) : | ||
TypedConfigurablePluginFactory<CONFIG, VersionControlSystem> { | ||
companion object { | ||
/** | ||
* All [version control system factories][VersionControlSystemFactory] available in the classpath, | ||
* associated by their names, sorted by priority. | ||
*/ | ||
val ALL by lazy { | ||
Plugin.getAll<VersionControlSystemFactory<*>>() | ||
.toList() | ||
.sortedByDescending { (_, vcsFactory) -> vcsFactory.priority } | ||
.toMap() | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* A base class for specific version control system configurations. | ||
*/ | ||
open class VersionControlSystemConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
model/src/main/kotlin/config/VersionControlSystemConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2024 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
|
||
package org.ossreviewtoolkit.model.config | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
|
||
import org.ossreviewtoolkit.utils.common.Options | ||
|
||
/** | ||
* The configuration for a Version Control System (VCS). | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
data class VersionControlSystemConfiguration( | ||
/** | ||
* Custom configuration options. See the documentation of the respective class for available options. | ||
*/ | ||
val options: Options = emptyMap() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.