Skip to content

Commit

Permalink
- add ability to provide a tag on library information, which can be…
Browse files Browse the repository at this point in the history
… used to potentially organize libraries better in custom UIs

  - FIX #715
  • Loading branch information
mikepenz committed Jan 29, 2022
1 parent 981d754 commit 981dd6c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ actual fun parseData(json: String): Result {
organization,
scm,
libLicenses,
funding
funding,
optString("tag")
)
}
return Result(libraries, licenses)
} catch (t: Throwable) {
Log.e("aboutlibraries", "Failed to parse aboutlibraries.json: $t")
Log.e("AboutLibraries", "Failed to parse the meta data *.json file: $t")
}
return Result(emptyList(), emptyList())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ data class Library(
val organization: Organization?,
val scm: Scm?,
val licenses: Set<License> = emptySet(),
val funding: Set<Funding> = emptySet()
val funding: Set<Funding> = emptySet(),
val tag: String? = null,
) {
/**
* defines the [uniqueId]:[artifactVersion] combined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ actual fun parseData(json: String): Result {
organization,
scm,
libLicenses,
funding
funding,
optString("tag")
)
}
return Result(libraries, licenses)
} catch (t: Throwable) {
println("Failed to parse aboutlibraries.json: $t")
println("Failed to parse the meta data *.json file: $t")
}
return Result(emptyList(), emptyList())
}
Expand Down
1 change: 1 addition & 0 deletions config/libraries/lib_first.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"artifactVersion": "42.0",
"description": "",
"name": "ABC Custom Jetpack library",
"tag": "custom",
"licenses": [
"asdkl"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ data class Library(
var scm: Scm?,
var licenses: Set<String> = emptySet(),
var funding: Set<Funding> = emptySet(),
var artifactFolder: File? = null
var tag: String? = null,
var artifactFolder: File? = null,
) {
val artifactId: String
get() = "${uniqueId}:${artifactVersion ?: ""}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class LibrariesProcessor(
scm,
licenses.map { it.hash }.toSet(),
funding,
null,
artifactFile.parentFile?.parentFile // artifactFile references the pom directly
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fun Library.merge(with: Library) {
with.name?.takeIf { it.isNotBlank() }?.also { orgLib.name = it }
with.description?.takeIf { it.isNotBlank() }?.also { orgLib.description = it }
with.website?.takeIf { it.isNotBlank() }?.also { orgLib.website = it }
with.tag?.takeIf { it.isNotBlank() }?.also { orgLib.tag = it }

// merge custom data with original data
val origOrganization = orgLib.organization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,15 @@ object LibraryReader {
organization,
scm,
licenses,
funding
funding,
c["tag"] as? String
)
} catch (t: Throwable) {
LOGGER.error("Could not read the license ($name)", t)
null
}
}

/**
"uniqueId": "androidx.jetpack.library:custom",
"developers": [],
"artifactVersion": "42.0",
"description": "",
"name": "ABC Custom Jetpack library",
"licenses": [
"asdkl"
]
*/

private val LOGGER = LoggerFactory.getLogger(LibraryReader::class.java)!!
private const val LIBRARIES_DIR = "libraries"
}

0 comments on commit 981dd6c

Please sign in to comment.