Skip to content

Commit cabec0c

Browse files
committed
Update sample app with script to fetch unpublished RCs
1 parent 75a3cf9 commit cabec0c

5 files changed

Lines changed: 196 additions & 2 deletions

File tree

examples/ExampleApp/app/src/main/kotlin/io/embrace/android/exampleapp/ui/AppBarColors.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ fun appBarColors() = TopAppBarColors(
1414
navigationIconContentColor = EmbraceBlack,
1515
titleContentColor = Color.White,
1616
actionIconContentColor = Color.White,
17+
subtitleContentColor = Color.Gray
1718
)

examples/ExampleApp/app/src/main/kotlin/io/embrace/android/exampleapp/ui/examples/TracingApiExample.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ fun TracingApiExample() {
2929
}
3030

3131
Button(onClick = {
32-
val span = Embrace.startSpan("my-span") ?: return@Button
33-
val childSpan = Embrace.startSpan("my-subspan", span) ?: return@Button
32+
val span = Embrace.startSpan("my-span")
33+
val childSpan = Embrace.startSpan("my-subspan", span)
3434

3535
// Do some work
3636
Thread.sleep(50)

examples/ExampleApp/app/src/main/kotlin/io/embrace/android/exampleapp/ui/examples/UserExample.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("DEPRECATION")
2+
13
package io.embrace.android.exampleapp.ui.examples
24

35
import androidx.compose.foundation.layout.Spacer
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
#!/usr/bin/env bash
2+
# Fetches a validated-but-unpublished Central Portal deployment into a local
3+
# Maven-layout directory, so Gradle can resolve from file:// instead of hitting
4+
# the Portal's flaky /download/ endpoint (which returns 500 for missing files
5+
# and disables the whole repo).
6+
#
7+
# Usage:
8+
# ./fetch-rc-bundle.sh <deployment-id> <version>
9+
#
10+
# The Portal auth header is read automatically from the `centralManualTestingAuthHeaderValue`
11+
# property in (in order):
12+
# 1. ~/.gradle/gradle.properties
13+
# 2. <script-dir>/gradle.properties (examples/ExampleApp/gradle.properties)
14+
# You can override with the TOKEN_VALUE env var.
15+
#
16+
# Modules are discovered dynamically from `embrace-*` directories in the SDK
17+
# repo root. Extensions are restricted to those actually produced by our
18+
# publish pipeline (pom / module / jar|aar plus checksums + .asc signatures).
19+
#
20+
# Output:
21+
# ./embrace-bundle-<version>-<deployment-id>/ (Maven layout)
22+
# Any existing directory with the same name is deleted first.
23+
#
24+
# Point Gradle at the resulting directory:
25+
# maven { url = uri("file:///.../embrace-bundle-<version>-<deployment-id>/") }
26+
27+
set -u
28+
29+
if [[ $# -ne 2 ]]; then
30+
echo "Usage: $0 <deployment-id> <version>"
31+
echo "Example: $0 abcdefgh-1234-ijkl-5678-abcdefghijkl 8.2.1"
32+
exit 2
33+
fi
34+
35+
DEPLOYMENT_ID="$1"
36+
VERSION="$2"
37+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
38+
SDK_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
39+
40+
read_gradle_prop() {
41+
local key="$1" file="$2"
42+
[[ -f "$file" ]] || return 1
43+
awk -F= -v k="$key" '
44+
$0 ~ "^[[:space:]]*"k"[[:space:]]*=" {
45+
sub("^[[:space:]]*"k"[[:space:]]*=[[:space:]]*", "")
46+
sub("[[:space:]]*$", "")
47+
print
48+
found = 1
49+
exit
50+
}
51+
END { exit !found }
52+
' "$file"
53+
}
54+
55+
TOKEN_SOURCE=""
56+
if [[ -n "${TOKEN_VALUE:-}" ]]; then
57+
TOKEN_SOURCE="\$TOKEN_VALUE env var"
58+
else
59+
for candidate in "$HOME/.gradle/gradle.properties" "$SCRIPT_DIR/gradle.properties"; do
60+
if value=$(read_gradle_prop "centralManualTestingAuthHeaderValue" "$candidate"); then
61+
TOKEN_VALUE="$value"
62+
TOKEN_SOURCE="$candidate"
63+
break
64+
fi
65+
done
66+
fi
67+
68+
if [[ -z "${TOKEN_VALUE:-}" ]]; then
69+
echo "ERROR: could not find 'centralManualTestingAuthHeaderValue' in:"
70+
echo " - \$TOKEN_VALUE env var"
71+
echo " - $HOME/.gradle/gradle.properties"
72+
echo " - $SCRIPT_DIR/gradle.properties"
73+
echo "Set it in one of those, e.g. in ~/.gradle/gradle.properties:"
74+
echo " centralManualTestingAuthHeaderValue=Bearer <base64(user:pass)>"
75+
exit 1
76+
fi
77+
78+
OUT="${SCRIPT_DIR}/embrace-bundle-${VERSION}-${DEPLOYMENT_ID}"
79+
BASE="https://central.sonatype.com/api/v1/publisher/deployment/${DEPLOYMENT_ID}/download"
80+
81+
# Discover all embrace-* module directories in the SDK root.
82+
MODULES=()
83+
while IFS= read -r name; do
84+
[[ -d "$SDK_ROOT/$name" ]] || continue
85+
MODULES+=("$name")
86+
done < <(ls "$SDK_ROOT" 2>/dev/null | grep "^embrace-" | sort)
87+
88+
if [[ ${#MODULES[@]} -eq 0 ]]; then
89+
echo "ERROR: no embrace-* modules found under $SDK_ROOT"
90+
exit 1
91+
fi
92+
93+
# Extensions actually produced by our publish pipeline (verified against a
94+
# previously fetched bundle). `aar` and `jar` are both tried per module; only
95+
# one will exist. No sources/javadoc classifiers are published.
96+
EXTENSIONS=(
97+
pom pom.asc pom.md5 pom.sha1 pom.sha256 pom.sha512
98+
module module.asc module.md5 module.sha1 module.sha256 module.sha512
99+
jar jar.asc jar.md5 jar.sha1 jar.sha256 jar.sha512
100+
aar aar.asc aar.md5 aar.sha1 aar.sha256 aar.sha512
101+
)
102+
103+
# Plugin marker is POM-only (packaging=pom).
104+
MARKER_EXTENSIONS=(pom pom.asc pom.md5 pom.sha1 pom.sha256 pom.sha512)
105+
106+
# Clean any prior bundle for this (version, deployment) so the new fetch is authoritative.
107+
if [[ -d "$OUT" ]]; then
108+
echo "Removing existing bundle: $OUT"
109+
rm -rf "$OUT"
110+
fi
111+
112+
ok=0
113+
missing=0
114+
fetch() {
115+
local path="$1"
116+
local target="${OUT}/${path}"
117+
mkdir -p "$(dirname "$target")"
118+
local code
119+
code=$(curl -sS -L -o "$target" -w "%{http_code}" \
120+
-H "Authorization: ${TOKEN_VALUE}" "${BASE}/${path}")
121+
if [[ "$code" == "200" ]]; then
122+
ok=$((ok + 1))
123+
echo " [200] ${path}"
124+
else
125+
rm -f "$target"
126+
missing=$((missing + 1))
127+
fi
128+
}
129+
130+
echo "Deployment: ${DEPLOYMENT_ID}"
131+
echo "Version: ${VERSION}"
132+
echo "Token from: ${TOKEN_SOURCE}"
133+
echo "Modules: ${#MODULES[@]} (from ${SDK_ROOT})"
134+
echo "Output: ${OUT}"
135+
echo
136+
137+
for m in "${MODULES[@]}"; do
138+
echo "-- io.embrace:${m}:${VERSION}"
139+
for ext in "${EXTENSIONS[@]}"; do
140+
fetch "io/embrace/${m}/${VERSION}/${m}-${VERSION}.${ext}"
141+
done
142+
done
143+
144+
echo
145+
echo "-- plugin marker io.embrace.gradle:io.embrace.gradle.gradle.plugin:${VERSION}"
146+
for ext in "${MARKER_EXTENSIONS[@]}"; do
147+
fetch "io/embrace/gradle/io.embrace.gradle.gradle.plugin/${VERSION}/io.embrace.gradle.gradle.plugin-${VERSION}.${ext}"
148+
done
149+
150+
echo
151+
echo "Done. Downloaded: ${ok}. Skipped (missing/error): ${missing}."
152+
153+
# Patch settings.gradle.kts so Gradle picks up the new bundle. Replaces either
154+
# the literal <path-to-bundle> placeholder or a previously-written bundle path.
155+
SETTINGS="${SCRIPT_DIR}/settings.gradle.kts"
156+
if [[ $ok -eq 0 ]]; then
157+
echo "Skipping settings.gradle.kts update (no artifacts downloaded)."
158+
elif [[ ! -f "$SETTINGS" ]]; then
159+
echo "WARNING: $SETTINGS not found — skipping settings update."
160+
else
161+
# BSD + GNU sed compatible: -i.bak then remove the backup.
162+
sed -i.bak \
163+
-e "s|<path-to-bundle>|${OUT}|g" \
164+
-e "s|file://[^\"]*embrace-bundle-[^\"]*|file://${OUT}|g" \
165+
"$SETTINGS"
166+
rm -f "${SETTINGS}.bak"
167+
if grep -q "file://${OUT}" "$SETTINGS"; then
168+
echo "Updated ${SETTINGS} → file://${OUT}"
169+
else
170+
echo "WARNING: no <path-to-bundle> or prior bundle URL found in ${SETTINGS}."
171+
echo " Add url = uri(\"file://<path-to-bundle>/\") to centralManualTesting"
172+
echo " and rerun, or point Gradle manually at: file://${OUT}/"
173+
fi
174+
fi

examples/ExampleApp/settings.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ pluginManagement {
88
}
99
}
1010
mavenCentral()
11+
maven {
12+
name = "centralManualTesting"
13+
url = uri("<path-to-bundle>")
14+
content {
15+
includeGroup("io.embrace")
16+
includeGroup("io.embrace.gradle")
17+
}
18+
}
19+
1120
mavenLocal()
1221
gradlePluginPortal()
1322
}
@@ -17,6 +26,14 @@ dependencyResolutionManagement {
1726
repositories {
1827
google()
1928
mavenCentral()
29+
maven {
30+
name = "centralManualTesting"
31+
url = uri("<path-to-bundle>")
32+
content {
33+
includeGroup("io.embrace")
34+
includeGroup("io.embrace.gradle")
35+
}
36+
}
2037
mavenLocal()
2138
}
2239
}

0 commit comments

Comments
 (0)