snazy commented on code in PR #2908:
URL: https://github.com/apache/polaris/pull/2908#discussion_r2465350331
##########
build-logic/src/main/kotlin/publishing/MemoizedJarInfo.kt:
##########
@@ -24,46 +24,24 @@ import org.gradle.api.java.archives.Attributes
import org.gradle.kotlin.dsl.extra
/**
- * Container to memoize Git information retrieved via `git` command executions
across all Gradle
- * projects. Jar release artifacts get some attributes added to the jar
manifest, which can be quite
- * useful for released jars.
+ * Helper class to generate Jar manifest attributes including Git commit SHA,
Git describe, project
+ * version and Java specification version.
*/
-internal class MemoizedGitInfo {
+internal class MemoizedJarInfo {
companion object {
- private fun execProc(rootProject: Project, cmd: String, vararg args: Any):
String {
- var out =
- rootProject.providers
- .exec {
- executable = cmd
- args(args.toList())
- }
- .standardOutput
- .asText
- .get()
- return out.trim()
- }
-
- fun gitInfo(rootProject: Project, attribs: Attributes) {
- val props = gitInfo(rootProject)
+ fun applyJarManifestAttributes(rootProject: Project, attribs: Attributes) {
+ val props = jarManifestAttributes(rootProject)
attribs.putAll(props)
}
- fun gitInfo(rootProject: Project): Map<String, String> {
+ private fun jarManifestAttributes(rootProject: Project): Map<String,
String> {
return if (rootProject.extra.has("gitReleaseInfo")) {
@Suppress("UNCHECKED_CAST")
rootProject.extra["gitReleaseInfo"] as Map<String, String>
} else {
val isRelease =
rootProject.hasProperty("release") ||
rootProject.hasProperty("jarWithGitInfo")
- val gitHead = execProc(rootProject, "git", "rev-parse", "HEAD")
- val gitDescribe =
- if (isRelease)
- try {
- execProc(rootProject, "git", "describe", "--tags")
- } catch (_: Exception) {
- execProc(rootProject, "git", "describe", "--always", "--dirty")
- }
- else ""
+ val gi = GitInfo.memoized(rootProject)
Review Comment:
gi for git info ;)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]