-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·69 lines (62 loc) · 2.32 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·69 lines (62 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
# install.sh — Install Kotlin tooling inside the project-local extended image
#
# Purpose: Runs during `docker build` of the consumer's `Dockerfile.devrail`.
# Downloads ktlint, detekt-cli, and Gradle into /usr/local/. The JDK
# itself is COPY'd from the eclipse-temurin:21-jdk builder stage by
# the manifest's container.copy_from_builder block.
#
# Usage: bash install.sh
#
# Self-contained: NO dependency on dev-toolchain's lib/log.sh — plugin install
# scripts run during the docker build step before any DevRail libs are
# available in the image. Status messages go to stderr via plain printf.
set -euo pipefail
log() {
printf '[install-kotlin] %s\n' "$*" >&2
}
# --- ktlint ---
if command -v ktlint >/dev/null 2>&1; then
log "ktlint already installed; skipping"
else
KTLINT_VERSION="1.5.0"
log "installing ktlint ${KTLINT_VERSION}"
curl -fsSL "https://github.com/pinterest/ktlint/releases/download/${KTLINT_VERSION}/ktlint" \
-o /usr/local/bin/ktlint
chmod +x /usr/local/bin/ktlint
fi
# --- detekt-cli ---
if [[ -f /usr/local/lib/detekt-cli.jar ]]; then
log "detekt-cli already installed; skipping"
else
DETEKT_VERSION="1.23.7"
log "installing detekt-cli ${DETEKT_VERSION}"
mkdir -p /usr/local/lib
curl -fsSL "https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/detekt-cli-${DETEKT_VERSION}-all.jar" \
-o /usr/local/lib/detekt-cli.jar
cat >/usr/local/bin/detekt-cli <<'WRAPPER'
#!/usr/bin/env bash
exec java -jar /usr/local/lib/detekt-cli.jar "$@"
WRAPPER
chmod +x /usr/local/bin/detekt-cli
fi
# --- Gradle ---
if command -v gradle >/dev/null 2>&1; then
log "gradle already installed; skipping"
else
GRADLE_VERSION="8.12"
log "installing gradle ${GRADLE_VERSION}"
TMPDIR_INSTALL="$(mktemp -d)"
trap 'rm -rf "${TMPDIR_INSTALL}"' EXIT
curl -fsSL "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
-o "${TMPDIR_INSTALL}/gradle.zip"
unzip -q "${TMPDIR_INSTALL}/gradle.zip" -d /opt
ln -sf "/opt/gradle-${GRADLE_VERSION}/bin/gradle" /usr/local/bin/gradle
fi
# --- Verify ---
log "verifying installation"
java -version 2>&1 | head -1 >&2
ktlint --version 2>&1 | head -1 >&2
detekt-cli --version 2>&1 | head -1 >&2
gradle --version 2>&1 | grep '^Gradle' | head -1 >&2
log "kotlin plugin tools installed successfully"