Skip to content

Commit 981dd6c

Browse files
committed
- add ability to provide a tag on library information, which can be used to potentially organize libraries better in custom UIs
- FIX #715
1 parent 981d754 commit 981dd6c

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

aboutlibraries-core/src/androidMain/kotlin/com/mikepenz/aboutlibraries/util/AndroidParser.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ actual fun parseData(json: String): Result {
4343
organization,
4444
scm,
4545
libLicenses,
46-
funding
46+
funding,
47+
optString("tag")
4748
)
4849
}
4950
return Result(libraries, licenses)
5051
} catch (t: Throwable) {
51-
Log.e("aboutlibraries", "Failed to parse aboutlibraries.json: $t")
52+
Log.e("AboutLibraries", "Failed to parse the meta data *.json file: $t")
5253
}
5354
return Result(emptyList(), emptyList())
5455
}

aboutlibraries-core/src/commonMain/kotlin/com/mikepenz/aboutlibraries/entity/Library.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ data class Library(
2424
val organization: Organization?,
2525
val scm: Scm?,
2626
val licenses: Set<License> = emptySet(),
27-
val funding: Set<Funding> = emptySet()
27+
val funding: Set<Funding> = emptySet(),
28+
val tag: String? = null,
2829
) {
2930
/**
3031
* defines the [uniqueId]:[artifactVersion] combined

aboutlibraries-core/src/multiplatformMain/kotlin/com/mikepenz/aboutlibraries/util/MultiplatformParser.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ actual fun parseData(json: String): Result {
4444
organization,
4545
scm,
4646
libLicenses,
47-
funding
47+
funding,
48+
optString("tag")
4849
)
4950
}
5051
return Result(libraries, licenses)
5152
} catch (t: Throwable) {
52-
println("Failed to parse aboutlibraries.json: $t")
53+
println("Failed to parse the meta data *.json file: $t")
5354
}
5455
return Result(emptyList(), emptyList())
5556
}

config/libraries/lib_first.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"artifactVersion": "42.0",
55
"description": "",
66
"name": "ABC Custom Jetpack library",
7+
"tag": "custom",
78
"licenses": [
89
"asdkl"
910
]

plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/mapping/Library.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ data class Library(
1616
var scm: Scm?,
1717
var licenses: Set<String> = emptySet(),
1818
var funding: Set<Funding> = emptySet(),
19-
var artifactFolder: File? = null
19+
var tag: String? = null,
20+
var artifactFolder: File? = null,
2021
) {
2122
val artifactId: String
2223
get() = "${uniqueId}:${artifactVersion ?: ""}"

plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/util/LibrariesProcessor.kt

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class LibrariesProcessor(
240240
scm,
241241
licenses.map { it.hash }.toSet(),
242242
funding,
243+
null,
243244
artifactFile.parentFile?.parentFile // artifactFile references the pom directly
244245
)
245246

plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/util/LibraryUtil.kt

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fun Library.merge(with: Library) {
5858
with.name?.takeIf { it.isNotBlank() }?.also { orgLib.name = it }
5959
with.description?.takeIf { it.isNotBlank() }?.also { orgLib.description = it }
6060
with.website?.takeIf { it.isNotBlank() }?.also { orgLib.website = it }
61+
with.tag?.takeIf { it.isNotBlank() }?.also { orgLib.tag = it }
6162

6263
// merge custom data with original data
6364
val origOrganization = orgLib.organization

plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/util/parser/LibraryReader.kt

+2-12
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,15 @@ object LibraryReader {
5555
organization,
5656
scm,
5757
licenses,
58-
funding
58+
funding,
59+
c["tag"] as? String
5960
)
6061
} catch (t: Throwable) {
6162
LOGGER.error("Could not read the license ($name)", t)
6263
null
6364
}
6465
}
6566

66-
/**
67-
"uniqueId": "androidx.jetpack.library:custom",
68-
"developers": [],
69-
"artifactVersion": "42.0",
70-
"description": "",
71-
"name": "ABC Custom Jetpack library",
72-
"licenses": [
73-
"asdkl"
74-
]
75-
*/
76-
7767
private val LOGGER = LoggerFactory.getLogger(LibraryReader::class.java)!!
7868
private const val LIBRARIES_DIR = "libraries"
7969
}

0 commit comments

Comments
 (0)