Skip to content

Commit

Permalink
install jdk with mise
Browse files Browse the repository at this point in the history
install jdk with mise

install jdk with mise
  • Loading branch information
tsirysndr committed Aug 20, 2024
1 parent 40d7a0f commit 75f2e31
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 42 deletions.
2 changes: 1 addition & 1 deletion example/.fluentci/plugin/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn setup_android_sdk() -> Result<(), Error> {

dag()
.pkgx()?
.with_packages(vec!["curl", "wget", "unzip", "openjdk.org"])?
.with_packages(vec!["curl", "wget", "unzip"])?
.with_exec(vec![
&format!("mkdir -p $ANDROID_HOME && wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-{}-{}_latest.zip", os, android_sdk_tools_version)])?
.with_exec(vec!["cd $ANDROID_HOME && rm -rf cmdline-tools && unzip -d cmdline-tools cmdline-tools.zip && mv cmdline-tools/cmdline-tools cmdline-tools/latest
Expand Down
7 changes: 1 addition & 6 deletions example/.fluentci/plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ pub fn assemble_release(args: String) -> FnResult<String> {

let stdout = dag()
.mise()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew assembleRelease"#,
&args,
])?
.with_exec(vec!["./gradlew assembleRelease", &args])?
.stdout()?;
Ok(stdout)
}
Expand Down
109 changes: 95 additions & 14 deletions example/.fluentci/src/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
* @description This module provides a set of functions for building Android applications.
*/

import { dag, type Directory, type File, type Container } from "../deps.ts";
import {
dag,
type Directory,
type File,
type Container,
env,
} from "../deps.ts";
import { getDirectory } from "./helpers.ts";

export enum Job {
Expand Down Expand Up @@ -35,11 +41,25 @@ export async function lintDebug(
src: string | Directory | undefined = "."
): Promise<string> {
const context = await getDirectory(src);
const JAVA_VERSION = env.get("JAVA_VERSION") || "zulu-17.46.19";

const ctr = dag
.pipeline(Job.lintDebug)
.container()
.from("ghcr.io/fluentci-io/android:latest")
.withEnvVariable("JAVA_VERSION", JAVA_VERSION)
.withEnvVariable("PATH", "$HOME/.local/share/mise/shims/:$PATH", {
expand: true,
})
.withWorkdir("/tmp")
.withExec(["sh", "-c", "curl -fsSL https://cli.fluentci.io | bash"])
.withExec(["sh", "-c", "fluentci run --wasm java setup $JAVA_VERSION"])
.withEnvVariable(
"JAVA_HOME",
"$HOME/.local/share/mise/installs/java/$JAVA_VERSION",
{ expand: true }
)

.withMountedCache("/app/.gradle", dag.cacheVolume("android-gradle"))
.withMountedCache("/root/.gradle", dag.cacheVolume("android-gradle-cache"))
.withMountedCache("/app/build", dag.cacheVolume("android-build"))
Expand All @@ -61,12 +81,12 @@ export async function lintDebug(
.withWorkdir("/app")
.withExec(["sh", "-c", "yes | sdkmanager --licenses"])
.withExec(["chmod", "+x", "./gradlew"])
.withExec(["sh", "-c", "ls -ltr /nix"])
.withExec(["nix", "--version"])
.withExec([
"sh",
"-c",
"devbox run -- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint",
"./gradlew",
"-Pci",
"--console=plain",
":app:lintDebug",
"-PbuildDir=lint",
]);

return ctr.stdout();
Expand All @@ -84,11 +104,24 @@ export async function assembleDebug(
src: string | Directory | undefined = "."
): Promise<File | string> {
const context = await getDirectory(src);
const JAVA_VERSION = env.get("JAVA_VERSION") || "zulu-17.46.19";

const ctr = dag
.pipeline(Job.assembleDebug)
.container()
.from("ghcr.io/fluentci-io/android:latest")
.withEnvVariable("JAVA_VERSION", JAVA_VERSION)
.withEnvVariable("PATH", "$HOME/.local/share/mise/shims/:$PATH", {
expand: true,
})
.withWorkdir("/tmp")
.withExec(["sh", "-c", "curl -fsSL https://cli.fluentci.io | bash"])
.withExec(["sh", "-c", "fluentci run --wasm java setup $JAVA_VERSION"])
.withEnvVariable(
"JAVA_HOME",
"$HOME/.local/share/mise/installs/java/$JAVA_VERSION",
{ expand: true }
)
.withMountedCache("/app/.gradle", dag.cacheVolume("android-gradle"))
.withMountedCache("/root/.gradle", dag.cacheVolume("android-gradle-cache"))
.withMountedCache("/app/build", dag.cacheVolume("android-build"))
Expand All @@ -110,7 +143,7 @@ export async function assembleDebug(
.withWorkdir("/app")
.withExec(["sh", "-c", "yes | sdkmanager --licenses"])
.withExec(["chmod", "+x", "./gradlew"])
.withExec(["sh", "-c", "devbox run -- ./gradlew assembleDebug"]);
.withExec(["./gradlew", "assembleDebug"]);

await ctr.stdout();
return ctr.file("/app/app/build/outputs/apk/debug/app-debug.apk").id();
Expand All @@ -130,11 +163,24 @@ export async function assembleRelease(
signed = false
): Promise<File | string> {
const context = await getDirectory(src);
const JAVA_VERSION = env.get("JAVA_VERSION") || "zulu-17.46.19";

const ctr = dag
.pipeline(Job.assembleRelease)
.container()
.from("ghcr.io/fluentci-io/android:latest")
.withEnvVariable("JAVA_VERSION", JAVA_VERSION)
.withEnvVariable("PATH", "$HOME/.local/share/mise/shims/:$PATH", {
expand: true,
})
.withWorkdir("/tmp")
.withExec(["sh", "-c", "curl -fsSL https://cli.fluentci.io | bash"])
.withExec(["sh", "-c", "fluentci run --wasm java setup $JAVA_VERSION"])
.withEnvVariable(
"JAVA_HOME",
"$HOME/.local/share/mise/installs/java/$JAVA_VERSION",
{ expand: true }
)
.withMountedCache("/app/.gradle", dag.cacheVolume("android-gradle"))
.withMountedCache("/root/.gradle", dag.cacheVolume("android-gradle-cache"))
.withMountedCache("/app/build", dag.cacheVolume("android-build"))
Expand All @@ -156,7 +202,7 @@ export async function assembleRelease(
.withWorkdir("/app")
.withExec(["sh", "-c", "yes | sdkmanager --licenses"])
.withExec(["chmod", "+x", "./gradlew"])
.withExec(["sh", "-c", "devbox run -- ./gradlew assembleRelease"]);
.withExec(["./gradlew", "assembleRelease"]);

await ctr.stdout();
return ctr
Expand All @@ -180,11 +226,24 @@ export async function bundleRelease(
src: string | Directory | undefined = "."
): Promise<File | string> {
const context = await getDirectory(src);
const JAVA_VERSION = env.get("JAVA_VERSION") || "zulu-17.46.19";

const ctr = dag
.pipeline(Job.bundleRelease)
.container()
.from("ghcr.io/fluentci-io/android:latest")
.withEnvVariable("JAVA_VERSION", JAVA_VERSION)
.withEnvVariable("PATH", "$HOME/.local/share/mise/shims/:$PATH", {
expand: true,
})
.withWorkdir("/tmp")
.withExec(["sh", "-c", "curl -fsSL https://cli.fluentci.io | bash"])
.withExec(["sh", "-c", "fluentci run --wasm java setup $JAVA_VERSION"])
.withEnvVariable(
"JAVA_HOME",
"$HOME/.local/share/mise/installs/java/$JAVA_VERSION",
{ expand: true }
)
.withMountedCache("/app/.gradle", dag.cacheVolume("android-gradle"))
.withMountedCache("/root/.gradle", dag.cacheVolume("android-gradle-cache"))
.withMountedCache("/app/build", dag.cacheVolume("android-build"))
Expand All @@ -206,7 +265,7 @@ export async function bundleRelease(
.withWorkdir("/app")
.withExec(["sh", "-c", "yes | sdkmanager --licenses"])
.withExec(["chmod", "+x", "./gradlew"])
.withExec(["sh", "-c", "devbox run -- ./gradlew bundleRelease"]);
.withExec(["./gradlew", "bundleRelease"]);
await ctr.stdout();
return ctr.file("/app/app/build/outputs/bundle/release/app-release.aab").id();
}
Expand All @@ -223,11 +282,24 @@ export async function debugTests(
src: string | Directory | undefined = "."
): Promise<string> {
const context = await getDirectory(src);
const JAVA_VERSION = env.get("JAVA_VERSION") || "zulu-17.46.19";

const ctr = dag
.pipeline(Job.debugTests)
.container()
.from("ghcr.io/fluentci-io/android:latest")
.withEnvVariable("JAVA_VERSION", JAVA_VERSION)
.withEnvVariable("PATH", "$HOME/.local/share/mise/shims/:$PATH", {
expand: true,
})
.withWorkdir("/tmp")
.withExec(["sh", "-c", "curl -fsSL https://cli.fluentci.io | bash"])
.withExec(["sh", "-c", "fluentci run --wasm java setup $JAVA_VERSION"])
.withEnvVariable(
"JAVA_HOME",
"$HOME/.local/share/mise/installs/java/$JAVA_VERSION",
{ expand: true }
)
.withMountedCache("/app/.gradle", dag.cacheVolume("android-gradle"))
.withMountedCache("/root/.gradle", dag.cacheVolume("android-gradle-cache"))
.withMountedCache("/app/build", dag.cacheVolume("android-build"))
Expand All @@ -249,11 +321,7 @@ export async function debugTests(
.withWorkdir("/app")
.withExec(["sh", "-c", "yes | sdkmanager --licenses"])
.withExec(["chmod", "+x", "./gradlew"])
.withExec([
"sh",
"-c",
"devbox run -- ./gradlew -Pci --console=plain :app:testDebug",
]);
.withExec(["./gradlew", "-Pci", "--console=plain :app:testDebug"]);

return ctr.stdout();
}
Expand All @@ -270,11 +338,24 @@ export async function dev(
src: string | Directory | undefined = "."
): Promise<Container | string> {
const context = await getDirectory(src);
const JAVA_VERSION = env.get("JAVA_VERSION") || "zulu-17.46.19";

const ctr = dag
.pipeline(Job.bundleRelease)
.container()
.from("ghcr.io/fluentci-io/android:latest")
.withEnvVariable("JAVA_VERSION", JAVA_VERSION)
.withEnvVariable("PATH", "$HOME/.local/share/mise/shims/:$PATH", {
expand: true,
})
.withWorkdir("/tmp")
.withExec(["sh", "-c", "curl -fsSL https://cli.fluentci.io | bash"])
.withExec(["sh", "-c", "fluentci run --wasm java setup $JAVA_VERSION"])
.withEnvVariable(
"JAVA_HOME",
"$HOME/.local/share/mise/installs/java/$JAVA_VERSION",
{ expand: true }
)
.withMountedCache("/app/.gradle", dag.cacheVolume("android-gradle"))
.withMountedCache("/root/.gradle", dag.cacheVolume("android-gradle-cache"))
.withMountedCache("/app/build", dag.cacheVolume("android-build"))
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn setup_android_sdk() -> Result<(), Error> {

dag()
.pkgx()?
.with_packages(vec!["curl", "wget", "unzip", "openjdk.org"])?
.with_packages(vec!["curl", "wget", "unzip"])?
.with_exec(vec![
&format!("mkdir -p $ANDROID_HOME && wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-{}-{}_latest.zip", os, android_sdk_tools_version)])?
.with_exec(vec!["cd $ANDROID_HOME && rm -rf cmdline-tools && unzip -d cmdline-tools cmdline-tools.zip && mv cmdline-tools/cmdline-tools cmdline-tools/latest
Expand Down
7 changes: 1 addition & 6 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ pub fn assemble_release(args: String) -> FnResult<String> {

let stdout = dag()
.mise()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew assembleRelease"#,
&args,
])?
.with_exec(vec!["./gradlew assembleRelease", &args])?
.stdout()?;
Ok(stdout)
}
Expand Down
Loading

0 comments on commit 75f2e31

Please sign in to comment.