Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JDK overlay directory, add tests #763

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions buildpacks/jvm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- JDK overlays are now properly sourced from the `.jdk-overlay` directory instead of `.jdk_overlay`. ([#763](https://github.com/heroku/buildpacks-jvm/pull/763))

## [6.0.4] - 2024-12-05

### Added
Expand Down
2 changes: 1 addition & 1 deletion buildpacks/jvm/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub(crate) const JAVA_TOOL_OPTIONS_ENV_VAR_DELIMITER: &str = " ";
pub(crate) const JAVA_TOOL_OPTIONS_ENV_VAR_NAME: &str = "JAVA_TOOL_OPTIONS";
pub(crate) const JDK_OVERLAY_DIR_NAME: &str = ".jdk_overlay";
pub(crate) const JDK_OVERLAY_DIR_NAME: &str = ".jdk-overlay";
pub(crate) const OPENJDK_LATEST_LTS_VERSION: u32 = 21;
1 change: 1 addition & 0 deletions buildpacks/jvm/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use libcnb_test::BuildConfig;
use std::path::Path;

mod overlay;
mod versions;

fn default_build_config(fixture_path: impl AsRef<Path>) -> BuildConfig {
Expand Down
42 changes: 42 additions & 0 deletions buildpacks/jvm/tests/integration/overlay.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::default_build_config;
use libcnb_test::{assert_contains, TestRunner};
use std::path::PathBuf;

#[test]
#[ignore = "integration test"]
fn overlay() {
const ADDITIONAL_PATH: &str = "earth.txt";
const ADDITIONAL_CONTENTS: &str = "Un diminuto punto azul";

const CACERTS_PATH: &str = "lib/security/cacerts";
const CACERTS_CONTENTS: &str = "overwritten";

TestRunner::default().build(
default_build_config("test-apps/java-21-app").app_dir_preprocessor(|app_dir| {
let overlay_path = app_dir.join(".jdk-overlay");
std::fs::create_dir_all(&overlay_path).unwrap();
std::fs::write(overlay_path.join(ADDITIONAL_PATH), ADDITIONAL_CONTENTS).unwrap();

let cacerts_path = overlay_path.join(PathBuf::from(CACERTS_PATH));
std::fs::create_dir_all(cacerts_path.parent().unwrap()).unwrap();
std::fs::write(&cacerts_path, CACERTS_CONTENTS).unwrap();
}),
|context| {
// Validate that adding a new file works
assert_contains!(
context
.run_shell_command(format!("cat $JAVA_HOME/{ADDITIONAL_PATH}"))
.stdout,
ADDITIONAL_CONTENTS
);

// Validate that overwriting a file works
assert_contains!(
context
.run_shell_command(format!("cat $JAVA_HOME/{CACERTS_PATH}"))
.stdout,
CACERTS_CONTENTS
);
},
);
}