Skip to content

Commit

Permalink
fix jdk setup
Browse files Browse the repository at this point in the history
fix jdk setup
  • Loading branch information
tsirysndr committed Aug 20, 2024
1 parent 95d2dbe commit 40d7a0f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 76 deletions.
2 changes: 1 addition & 1 deletion example/.fluentci/plugin/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/.fluentci/plugin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "android"
version = "0.11.0"
version = "0.11.1"

[lib]
crate-type = ["cdylib"]
Expand Down
26 changes: 15 additions & 11 deletions example/.fluentci/plugin/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ use anyhow::Error;
use fluentci_pdk::dag;

pub fn setup_jdk() -> Result<(), Error> {
let mut jdk_version = dag().get_env("JDK_VERSION").unwrap_or("17.0.7+7".into());
let mut jdk_version = dag()
.get_env("JDK_VERSION")
.unwrap_or("zulu-17.46.19".into());
if jdk_version.is_empty() {
jdk_version = "17.0.7+7".into();
jdk_version = "zulu-17.46.19".into();
}

dag()
.devbox()?
.with_exec(vec![
"devbox",
"global",
"add",
&format!("jdk@{}", jdk_version),
])?
.stdout()?;
dag().call(
"https://pkg.fluentci.io/java@v0.1.2?wasm=1",
"setup",
vec![&jdk_version],
)?;

let home = dag().get_env("HOME")?;
dag().set_envs(vec![(
"JAVA_HOME".into(),
format!("{}/.local/share/mise/installs/java/{}", home, jdk_version),
)])?;

Ok(())
}
Expand Down
35 changes: 9 additions & 26 deletions example/.fluentci/plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn assemble_release(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.mise()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
Expand All @@ -36,13 +36,8 @@ pub fn assemble_debug(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew assembleDebug"#,
&args,
])?
.mise()?
.with_exec(vec!["./gradlew assembleDebug", &args])?
.stdout()?;
Ok(stdout)
}
Expand All @@ -53,11 +48,9 @@ pub fn lint_debug(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.mise()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint"#,
"./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint",
&args,
])?
.stdout()?;
Expand All @@ -70,13 +63,8 @@ pub fn debug_tests(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew -Pci --console=plain :app:testDebug"#,
&args,
])?
.mise()?
.with_exec(vec!["./gradlew -Pci --console=plain :app:testDebug", &args])?
.stdout()?;
Ok(stdout)
}
Expand All @@ -87,13 +75,8 @@ pub fn bundle_release(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew bundleRelease"#,
&args,
])?
.mise()?
.with_exec(vec!["./gradlew bundleRelease", &args])?
.stdout()?;
Ok(stdout)
}
26 changes: 15 additions & 11 deletions plugin/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ use anyhow::Error;
use fluentci_pdk::dag;

pub fn setup_jdk() -> Result<(), Error> {
let mut jdk_version = dag().get_env("JDK_VERSION").unwrap_or("17.0.7+7".into());
let mut jdk_version = dag()
.get_env("JDK_VERSION")
.unwrap_or("zulu-17.46.19".into());
if jdk_version.is_empty() {
jdk_version = "17.0.7+7".into();
jdk_version = "zulu-17.46.19".into();
}

dag()
.devbox()?
.with_exec(vec![
"devbox",
"global",
"add",
&format!("jdk@{}", jdk_version),
])?
.stdout()?;
dag().call(
"https://pkg.fluentci.io/java@v0.1.2?wasm=1",
"setup",
vec![&jdk_version],
)?;

let home = dag().get_env("HOME")?;
dag().set_envs(vec![(
"JAVA_HOME".into(),
format!("{}/.local/share/mise/installs/java/{}", home, jdk_version),
)])?;

Ok(())
}
Expand Down
35 changes: 9 additions & 26 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn assemble_release(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.mise()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
Expand All @@ -36,13 +36,8 @@ pub fn assemble_debug(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew assembleDebug"#,
&args,
])?
.mise()?
.with_exec(vec!["./gradlew assembleDebug", &args])?
.stdout()?;
Ok(stdout)
}
Expand All @@ -53,11 +48,9 @@ pub fn lint_debug(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.mise()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint"#,
"./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint",
&args,
])?
.stdout()?;
Expand All @@ -70,13 +63,8 @@ pub fn debug_tests(args: String) -> FnResult<String> {
setup_android_sdk()?;

let stdout = dag()
.devbox()?
.with_exec(vec![
r#"
eval "$(devbox global shellenv --recompute)"
./gradlew -Pci --console=plain :app:testDebug"#,
&args,
])?
.mise()?
.with_exec(vec!["./gradlew -Pci --console=plain :app:testDebug", &args])?
.stdout()?;
Ok(stdout)
}
Expand All @@ -87,13 +75,8 @@ pub fn bundle_release(args: String) -> FnResult<String> {
setup_android_sdk()?;

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

0 comments on commit 40d7a0f

Please sign in to comment.