generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
> [!NOTE] | ||
> It's fine if we let `version` run out of date since it's rarely updated. | ||
> (version from "Command line tools only" section @ https://developer.android.com/studio?hl=en) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "Android SDK (via Google CDN)", | ||
"id": "android-sdk", | ||
"version": "1.0.0", | ||
"description": "A feature that installs the Android command line tools and SDK", | ||
"keywords": ["android", "mobile", "mobile-development"], | ||
"options": { | ||
"version": { | ||
"type": "string", | ||
"proposals": [ | ||
"11076708" | ||
], | ||
"default": "11076708", | ||
"description": "Select the Android command line tools version ('latest' is not supported)" | ||
}, | ||
|
||
"installMavenRepos": { | ||
"type": "boolean", | ||
"default": true, | ||
"description": "Whether or not to install the Android and Google Maven repos" | ||
}, | ||
|
||
"installPlayServices": { | ||
"type": "boolean", | ||
"default": true, | ||
"description": "Whether or not to install Play Services" | ||
}, | ||
|
||
"installEmulator": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Whether or not to install the Android Emulator (NOTE: you still have to install the images yourself using sdkmanager)" | ||
} | ||
}, | ||
|
||
"containerEnv": { | ||
"ANDROID_HOME": "/usr/local/android-sdk", | ||
"ANDROID_CMDLINE_TOOLS_HOME": "${ANDROID_HOME}/cmdline-tools", | ||
"PATH": "${PATH}:${ANDROID_HOME}:${ANDROID_CMDLINE_TOOLS_HOME}/latest/bin:${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools" | ||
}, | ||
|
||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
], | ||
|
||
"dependsOn": { | ||
"ghcr.io/phorcys420/devcontainer-features/lib-common:1": {}, | ||
|
||
"ghcr.io/devcontainers/features/java:1": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
FEATURE_NAME="android-sdk" | ||
echo "Activating feature '$FEATURE_NAME'" | ||
|
||
# Source lib-common feature (DEVCONTAINER_LIBRARIES_HOME is defined by lib-common) | ||
source "$DEVCONTAINER_LIBRARIES_HOME/common/1/main.sh" | ||
|
||
# Load options | ||
VERSION=${VERSION:-11076708} | ||
|
||
INSTALL_MAVEN_REPOS=${INSTALL_MAVEN_REPOS:-"true"} | ||
INSTALL_PLAY_SERVICES=${INSTALL_PLAY_SERVICES:-"true"} | ||
INSTALL_EMULATOR=${INSTALL_EMULATOR:-"false"} | ||
|
||
# ANDROID_HOME and ANDROID_CMDLINE_TOOLS_HOME are defined in the containerEnv value of the feature's manifest | ||
ANDROID_HOME=${ANDROID_HOME:-/usr/local/android-sdk} | ||
ANDROID_CMDLINE_TOOLS_HOME=${ANDROID_CMDLINE_TOOLS_HOME:-${ANDROID_HOME}/cmdline-tools} | ||
|
||
# Check for dependencies | ||
checkPackages curl ca-certificates unzip | ||
|
||
TMP=$(mktemp -d) | ||
DESTINATION_FILE="$TMP/android-sdk.zip" | ||
|
||
echo "[$FEATURE_NAME] [+] Downloading version $VERSION of Android command line tools" | ||
|
||
curl --get --location --silent --show-error --fail \ | ||
--output "$DESTINATION_FILE" \ | ||
"https://dl.google.com/android/repository/commandlinetools-linux-${VERSION}_latest.zip" | ||
|
||
mkdir -p "$ANDROID_CMDLINE_TOOLS_HOME" | ||
|
||
echo "[$FEATURE_NAME] [+] Extracting Android command line tools" | ||
unzip "$TMP/android-sdk.zip" -d "$ANDROID_CMDLINE_TOOLS_HOME" | ||
mv "$ANDROID_CMDLINE_TOOLS_HOME/cmdline-tools" "$ANDROID_CMDLINE_TOOLS_HOME/latest" | ||
|
||
echo "[$FEATURE_NAME] [+] Accepting sdkmanager's licenses" | ||
(yes || true) | sdkmanager --licenses | ||
|
||
|
||
TOOLS=("tools" "platform-tools" "build-tools;34.0.0") | ||
|
||
if [ "$INSTALL_MAVEN_REPOS" = "true" ]; then | ||
echo "[$FEATURE_NAME] [+] Adding Android and Google's Maven repositories to the list of tools" | ||
TOOLS+=("extras;android;m2repository" "extras;google;m2repository") | ||
fi | ||
|
||
if [ "$INSTALL_PLAY_SERVICES" = "true" ]; then | ||
echo "[$FEATURE_NAME] [+] Adding play services to the list of tools" | ||
TOOLS+=("extras;google;google_play_services") | ||
fi | ||
|
||
if [ "$INSTALL_EMULATOR" = "true" ]; then | ||
echo "[$FEATURE_NAME] [+] Adding the emulator to the list of tools" | ||
TOOLS+=("emulator") | ||
fi | ||
|
||
echo "[$FEATURE_NAME] [+] Installing SDK tools" | ||
sdkmanager --install "${TOOLS[@]}" | ||
|
||
rm -rf "$TMP" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
source dev-container-features-test-lib | ||
|
||
check "Android SDK folder exists" test -d "$ANDROID_HOME" | ||
|
||
BINARY_LIST=("sdkmanager" "adb") | ||
|
||
for binary in "${BINARY_LIST[@]}"; do | ||
check "Android SDK binary '$binary' is in the PATH" which "$binary" | ||
done | ||
|
||
# Report results | ||
# If any of the checks above exited with a non-zero exit code, the test will fail. | ||
reportResults |