-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cargo): Migrate from toml4j to tomlkt
tomlkt [1] brings TOML support to kotlinx-serialization. It is more feature complete than ktoml [2], which was also considered to be used. [1]: https://github.com/Peanuuutz/tomlkt [2]: https://github.com/akuleshov7/ktoml Signed-off-by: Sebastian Schuberth <[email protected]>
- Loading branch information
1 parent
8de8460
commit 44523e4
Showing
5 changed files
with
120 additions
and
25 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
49 changes: 49 additions & 0 deletions
49
plugins/package-managers/cargo/src/main/kotlin/CargoLockFile.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,49 @@ | ||
/* | ||
* Copyright (C) 2023 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.plugins.packagemanagers.cargo | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* See https://docs.rs/cargo-lock/latest/cargo_lock/struct.Lockfile.html. | ||
*/ | ||
@Serializable | ||
internal data class CargoLockFile( | ||
val version: Int = 1, | ||
|
||
@SerialName("package") | ||
val packages: List<Package>, | ||
|
||
val metadata: Map<String, String> | ||
) { | ||
/** | ||
* See https://docs.rs/cargo-lock/latest/cargo_lock/package/struct.Package.html. | ||
*/ | ||
@Serializable | ||
data class Package( | ||
val name: String, | ||
val version: String, | ||
val source: String? = null, | ||
val checksum: String? = null, | ||
val dependencies: List<String> = emptyList(), | ||
val replace: String? = null | ||
) | ||
} |
43 changes: 43 additions & 0 deletions
43
plugins/package-managers/cargo/src/main/kotlin/CargoManifest.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,43 @@ | ||
/* | ||
* Copyright (C) 2023 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.plugins.packagemanagers.cargo | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* See https://doc.rust-lang.org/cargo/reference/manifest.html. | ||
*/ | ||
@Serializable | ||
internal data class CargoManifest( | ||
@SerialName("package") | ||
val pkg: Package | ||
) { | ||
/** | ||
* See https://doc.rust-lang.org/cargo/reference/manifest.html#the-package-section. | ||
*/ | ||
@Serializable | ||
data class Package( | ||
val name: String, | ||
val version: String, | ||
val authors: List<String> = emptyList(), | ||
val homepage: String? = null | ||
) | ||
} |