You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by dc...@apache.org on 2021/09/01 15:48:16 UTC

[datasketches-memory] 07/10: Add git properties to JAR Manifest.MF

This is an automated email from the ASF dual-hosted git repository.

dcromberge pushed a commit to branch single-build-script
in repository https://gitbox.apache.org/repos/asf/datasketches-memory.git

commit 36a8bc547c9cad3375b467e52dc8771433d9be3b
Author: David Cromberge <dc...@apache.org>
AuthorDate: Thu Aug 26 15:20:55 2021 +0100

    Add git properties to JAR Manifest.MF
---
 tools/scripts/compile-package-jar.sh | 18 ++++++++--
 tools/scripts/getGitProperties.sh    | 70 ++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/tools/scripts/compile-package-jar.sh b/tools/scripts/compile-package-jar.sh
index 5c1548f..5cb4940 100755
--- a/tools/scripts/compile-package-jar.sh
+++ b/tools/scripts/compile-package-jar.sh
@@ -23,7 +23,7 @@
 # who do not wish to install several versions of the JDK on their
 # machine.
 # The script does not assume a POM file and does not use Maven.
-# It does use git, SVN, and uses the script getGitProperties.sh
+# It does use git and also uses the script getGitProperties.sh.
 
 #  Required Input Parameters:
 #  \$1 = absolute path of JDK home directory
@@ -43,8 +43,9 @@ JDKHome=$1
 GitTag=$2
 
 # Setup absolute directory references
-ScriptsDir=$(pwd)
 ProjectBaseDir=$3 #this must be an absolute path
+ScriptsDir=${ProjectBaseDir}/tools/scripts/
+ProjectArtifactId="memory"
 
 ####Move to project directory####
 cd ${ProjectBaseDir}
@@ -86,7 +87,8 @@ OutputJar=${OutputDir}/org.apache.datasketches.memory-${GitTag}.jar
 PackageDir=${OutputDir}/package
 PackageSrc=${PackageDir}/src
 PackageContents=${PackageDir}/contents
-PackageMeta=${PackageDir}/META-INF
+PackageMeta=${PackageContents}/META-INF
+PackageManifest=${PackageMeta}/MANIFEST.MF
 
 MemoryJava8Src=datasketches-memory-java8/src/main/java
 MemoryJava9Src=datasketches-memory-java9/src/main/java
@@ -103,6 +105,16 @@ mkdir -p $PackageMeta
 cp LICENSE $PackageMeta
 cp NOTICE $PackageMeta
 
+#### Generate MANIFEST.MF ####
+cat >> ${PackageManifest}<< EOF
+Manifest-Version: 1.0
+Created-By: Apache Datasketches Memory compile-package-jar.sh
+Multi-Release: false
+EOF
+
+#### Generate git.properties file ####
+echo "$($ScriptsDir/getGitProperties.sh $ProjectBaseDir $ProjectArtifactId $GitTag)" >> $PackageManifest
+
 #### Copy base tree to target/src
 rsync -a $MemoryJava8Src $PackageSrc
 
diff --git a/tools/scripts/getGitProperties.sh b/tools/scripts/getGitProperties.sh
new file mode 100755
index 0000000..d75e0b3
--- /dev/null
+++ b/tools/scripts/getGitProperties.sh
@@ -0,0 +1,70 @@
+#!/bin/bash -e
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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
+#
+#   http://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.
+
+MyBase=$(pwd)
+ProjectBaseDir=$1 #this must be an absolute path
+ArtId=$2
+Tag=$3
+
+####Move to project directory####
+cd ${ProjectBaseDir}
+
+CR=$'\n'
+
+#Add Implementation Vendor
+prop=$prop'Implementation-Vendor: '
+tmp='The Apache Software Foundataion'$CR
+prop=$prop$tmp
+
+#Add GroupId : ArtifactId
+prop=$prop'GroupId-ArtifactId: '
+tmp='org.apache.datasketches:'$ArtId$CR
+prop=$prop$tmp
+
+# Add Branch
+prop=$prop'git.branch: '
+tmp=''$(git rev-parse --abbrev-ref HEAD)''$CR
+prop=$prop$tmp
+
+#Add commit-id
+prop=$prop'git.commit.id.full: '
+ID=$(git rev-parse HEAD)
+tmp=''$ID''$CR
+prop=$prop$tmp
+
+#Add timestamp
+prop=$prop'git.commit.time: '
+tmp=''$(git show --no-patch --no-notes --pretty='%cI' $ID)''$CR
+prop=$prop$tmp
+
+#Add user email
+prop=$prop'git-commit-user-email: '
+tmp=''$(git show --no-patch --no-notes --pretty='%ce' $ID)''$CR
+prop=$prop$tmp
+
+#Add Tag
+prop=$prop'git.commit.tag: '
+tmp=''$Tag''$CR
+prop=$prop$tmp
+
+echo "$prop"
+
+
+
+

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org