mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-11 02:31:38 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ed0ae4d06 |
No files matched your search
@@ -337,7 +337,7 @@ async fn start_inner(
|
||||
// what makes the setting take effect without reopening the project.
|
||||
if config.kind == "maven" {
|
||||
ide_sdk::apply::prepare_maven_run(&mut config, root, &settings);
|
||||
} else if matches!(config.kind.as_str(), "gradle" | "tomcat") {
|
||||
} else if matches!(config.kind.as_str(), "gradle" | "tomcat" | "junit") {
|
||||
ide_sdk::apply::apply_to_run_configs(std::slice::from_mut(&mut config), root, &settings);
|
||||
} else {
|
||||
ide_sdk::apply::resolve_run_command(&mut config, root, &settings);
|
||||
|
||||
@@ -1561,6 +1561,24 @@ pub fn apply_to_run_configs(configs: &mut [RunConfig], root: &Path, s: &Settings
|
||||
c.env.entry("JAVA_HOME".into()).or_insert_with(|| jdk.home.to_string_lossy().into_owned());
|
||||
}
|
||||
}
|
||||
// A JUnit configuration runs the module's own Maven or Gradle command line: it needs
|
||||
// that build's environment (its JDK), not another launcher or extra options.
|
||||
"junit" => {
|
||||
let name = Path::new(&c.command).file_name().map(|n| n.to_string_lossy().to_ascii_lowercase());
|
||||
match name.as_deref() {
|
||||
Some(n) if n.starts_with("mvn") => apply_maven_env(c, root, s),
|
||||
Some(n) if n.starts_with("gradle") => {
|
||||
let build_dir =
|
||||
c.cwd.as_ref().map(|p| root.join(p.as_ref())).unwrap_or_else(|| root.to_path_buf());
|
||||
let env = gradle_build_env(root, &build_dir, &c.command, s, None);
|
||||
apply_java_home(c, &env, java_home_is_derived(c));
|
||||
for (key, value) in env {
|
||||
c.env.entry(key).or_insert(value);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
"maven" => {
|
||||
apply_maven_env(c, root, s);
|
||||
if let Some(mvn) = &mvn
|
||||
|
||||
@@ -409,6 +409,19 @@ fn project_jdk_and_maven_settings() {
|
||||
);
|
||||
assert_eq!(configs[0].env["JAVA_HOME"], home);
|
||||
assert_eq!(configs[1].env["JAVA_HOME"], home);
|
||||
// JUnit runs the build's own command line: the build's JDK, its command and arguments unchanged.
|
||||
let mut junit = vec![
|
||||
run("junit", "./mvnw", &["test", "-Dtest=a.T"]),
|
||||
run("junit", "./gradlew", &[":api:test", "--tests", "a.T"]),
|
||||
];
|
||||
apply_to_run_configs(&mut junit, tmp.path(), &s);
|
||||
assert_eq!(
|
||||
(junit[0].command.as_str(), junit[0].args.as_slice()),
|
||||
("./mvnw", &["test".to_owned(), "-Dtest=a.T".to_owned()][..])
|
||||
);
|
||||
assert_eq!(junit[0].env["JAVA_HOME"], home);
|
||||
assert_eq!(junit[1].command, "./gradlew");
|
||||
assert_eq!(junit[1].env["JAVA_HOME"], home);
|
||||
apply_to_run_configs(&mut configs, tmp.path(), &s);
|
||||
assert_eq!(configs[0].args.len(), 6, "applied once");
|
||||
|
||||
|
||||
Reference in new issue
Block a user