xref: /aosp_15_r20/external/conscrypt/scripts/publishLocalUber.sh (revision cd0cc2e34ba52cdf454361820a14d744e4bd531d)
1#! /bin/bash
2#
3#  Copyright (C) 2024 The Android Open Source Project
4#
5#  Licensed under the Apache License, Version 2.0 (the "License");
6#  you may not use this file except in compliance with the License.
7#  You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#  Unless required by applicable law or agreed to in writing, software
12#  distributed under the License is distributed on an "AS IS" BASIS,
13#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#  See the License for the specific language governing permissions and
15#  limitations under the License.
16
17# Builds and locally publishes an uber jar for local architectures.
18#
19# Normally an uber jar contains JNI binaries for all supported
20# platforms, but that requires those binaries to be built somewhere.
21# This script infers the binary types that can be built locally and
22# adds only those to the jar.  This allows end to end testing of the
23# build process as well as testing of the uberjar against multiple
24# Java versions (see testLocalUber.sh)
25
26
27CONSCRYPT_HOME="${CONSCRYPT_HOME:-$HOME/src/conscrypt}"
28BUILD="$CONSCRYPT_HOME/build.gradle"
29M2_REPO="${M2_REPO:-$HOME/.m2/repository}"
30PUBLISH_DIR="${M2_REPO}/org/conscrypt"
31
32die() {
33	echo "*** " $@
34	exit 1
35}
36
37case $(uname -s) in
38	Darwin)
39		CLASSIFIERS="osx-x86_64,osx-aarch_64"
40		;;
41	Linux)
42		CLASSIFIERS="linux-x86_64"
43		;;
44	*)
45		die "TODO: Finish this switch statement"
46		;;
47esac
48
49test -f "$BUILD" || die "Conscrypt build file not found.  Check CONSCRYPT_HOME."
50
51VERSION=$(sed -nE 's/^ *version *= *"(.*)"/\1/p' $BUILD)
52test "$VERSION" || die "Unable to figure out Conscrypt version."
53echo "Conscrypt version ${VERSION}."
54
55UBERJAR="$PUBLISH_DIR/conscrypt-openjdk-uber/$VERSION/conscrypt-openjdk-uber-${VERSION}.jar"
56
57cd "$CONSCRYPT_HOME"
58./gradlew :conscrypt-openjdk:publishToMavenLocal \
59		  --console=plain
60./gradlew :conscrypt-openjdk-uber:publishToMavenLocal \
61		  -Dorg.conscrypt.openjdk.uberJarClassifiers="$CLASSIFIERS" \
62		  -Dorg.conscrypt.openjdk.buildUberJar=true \
63		  --console=plain
64
65test -f "$UBERJAR" || die "Uber jar not published."
66ls -l "$UBERJAR"
67