Skip to content
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
10 changes: 10 additions & 0 deletions macos/Sources/Lithe/Views/Run/MavenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct MavenView: View {
@State private var customGoal = ""
@State private var customProfile = ""
@State private var settingsPath = ""
@State private var localRepositoryPath = ""
@State private var mavenExecutablePath = ""
@State private var javaHomePath = ""

Expand Down Expand Up @@ -621,6 +622,13 @@ struct MavenView: View {
model.platformUI.chooseFile(title: "Choose Maven settings.xml", prompt: "Choose")
}
)
settingsPathRow(
title: "Local Repository",
value: $localRepositoryPath,
choose: {
model.platformUI.chooseDirectory(title: "Choose Maven Local Repository", prompt: "Choose")
}
)
settingsPathRow(
title: "Maven Home or Executable",
value: $mavenExecutablePath,
Expand Down Expand Up @@ -722,6 +730,7 @@ struct MavenView: View {

private func presentSettings() {
settingsPath = feature.settingsPath ?? ""
localRepositoryPath = feature.localRepositoryPath ?? ""
mavenExecutablePath = feature.mavenExecutablePath ?? ""
javaHomePath = feature.javaHomePath ?? ""
isSettingsSheetPresented = true
Expand All @@ -730,6 +739,7 @@ struct MavenView: View {
private func saveSettings() {
feature.updateLocalConfiguration(
settingsPath: settingsPath,
localRepositoryPath: localRepositoryPath,
mavenExecutablePath: mavenExecutablePath,
javaHomePath: javaHomePath
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,20 @@ package struct MavenLocalConfiguration: Codable, Equatable, Sendable {

package var version: Int
package var settingsPath: String?
package var localRepositoryPath: String?
package var mavenExecutablePath: String?
package var javaHomePath: String?

package init(
version: Int = currentVersion,
settingsPath: String? = nil,
localRepositoryPath: String? = nil,
mavenExecutablePath: String? = nil,
javaHomePath: String? = nil
) {
self.version = version
self.settingsPath = settingsPath
self.localRepositoryPath = localRepositoryPath
self.mavenExecutablePath = mavenExecutablePath
self.javaHomePath = javaHomePath
}
Expand All @@ -255,6 +258,7 @@ package struct MavenLaunchContext: Codable, Equatable, Sendable {
package let reactorPath: String
package let profiles: [String]
package let settingsPath: String?
package let localRepositoryPath: String?
package let skipTests: Bool
package let mavenExecutablePath: String?
package let javaHomePath: String?
Expand All @@ -264,6 +268,7 @@ package struct MavenLaunchContext: Codable, Equatable, Sendable {
reactorPath: String,
profiles: [String],
settingsPath: String?,
localRepositoryPath: String? = nil,
skipTests: Bool,
mavenExecutablePath: String?,
javaHomePath: String?
Expand All @@ -272,6 +277,7 @@ package struct MavenLaunchContext: Codable, Equatable, Sendable {
self.reactorPath = reactorPath
self.profiles = profiles
self.settingsPath = settingsPath
self.localRepositoryPath = localRepositoryPath
self.skipTests = skipTests
self.mavenExecutablePath = mavenExecutablePath
self.javaHomePath = javaHomePath
Expand Down Expand Up @@ -316,6 +322,9 @@ package func redactedMavenArgumentsForDisplay(_ arguments: [String]) -> [String]
} else if argument.hasPrefix("--settings=") || argument.hasPrefix("-s=") {
result.append(String(argument.prefix { $0 != "=" }) + "=<settings.xml>")
index += 1
} else if argument.hasPrefix("-Dmaven.repo.local=") {
result.append("-Dmaven.repo.local=<localRepository>")
index += 1
} else {
result.append(argument)
index += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package final class MavenFeatureModel: ObservableObject {
package var selectedProfiles: Set<String> { service.selectedProfiles }
package var skipTests: Bool { service.skipTests }
package var settingsPath: String? { service.settingsPath }
package var localRepositoryPath: String? { service.localRepositoryPath }
package var mavenExecutablePath: String? { service.mavenExecutablePath }
package var javaHomePath: String? { service.javaHomePath }
package var configurationSaveError: String? { service.configurationSaveError }
Expand Down Expand Up @@ -67,11 +68,13 @@ package final class MavenFeatureModel: ObservableObject {

package func updateLocalConfiguration(
settingsPath: String?,
localRepositoryPath: String?,
mavenExecutablePath: String?,
javaHomePath: String?
) {
service.updateLocalConfiguration(
settingsPath: settingsPath,
localRepositoryPath: localRepositoryPath,
mavenExecutablePath: mavenExecutablePath,
javaHomePath: javaHomePath
)
Expand Down
10 changes: 10 additions & 0 deletions macos/Sources/LitheExecutionModule/Services/MavenService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package final class MavenService: ObservableObject {
@Published package private(set) var customProfiles: [String] = []
@Published package private(set) var skipTests = false
@Published package private(set) var settingsPath: String?
@Published package private(set) var localRepositoryPath: String?
@Published package private(set) var mavenExecutablePath: String?
@Published package private(set) var javaHomePath: String?
@Published package private(set) var configurationSaveError: String?
Expand Down Expand Up @@ -48,6 +49,7 @@ package final class MavenService: ObservableObject {
reactorPath: reactorPath,
profiles: selectedProfiles.sorted(),
settingsPath: settingsPath,
localRepositoryPath: localRepositoryPath,
skipTests: skipTests,
mavenExecutablePath: mavenExecutablePath,
javaHomePath: javaHomePath
Expand Down Expand Up @@ -209,16 +211,20 @@ package final class MavenService: ObservableObject {

package func updateLocalConfiguration(
settingsPath: String?,
localRepositoryPath: String?,
mavenExecutablePath: String?,
javaHomePath: String?
) {
let settings = normalizedLocalPath(settingsPath)
let localRepository = normalizedLocalPath(localRepositoryPath)
let executable = normalizedLocalPath(mavenExecutablePath)
let javaHome = normalizedLocalPath(javaHomePath)
guard settings != self.settingsPath
|| localRepository != self.localRepositoryPath
|| executable != self.mavenExecutablePath
|| javaHome != self.javaHomePath else { return }
self.settingsPath = settings
self.localRepositoryPath = localRepository
self.mavenExecutablePath = executable
self.javaHomePath = javaHome
configurationDidChange()
Expand Down Expand Up @@ -263,6 +269,7 @@ package final class MavenService: ObservableObject {
customProfiles = []
skipTests = false
settingsPath = nil
localRepositoryPath = nil
mavenExecutablePath = nil
javaHomePath = nil
configurationFingerprint = nil
Expand Down Expand Up @@ -292,6 +299,7 @@ package final class MavenService: ObservableObject {
reactorPath: reactorPath,
profiles: selectedProfiles.sorted(),
settingsPath: settingsPath,
localRepositoryPath: localRepositoryPath,
skipTests: skipTests,
mavenExecutablePath: mavenExecutablePath,
javaHomePath: javaHomePath
Expand Down Expand Up @@ -426,6 +434,7 @@ package final class MavenService: ObservableObject {
customProfiles = normalizedProfiles(portable?.customProfiles ?? [])
skipTests = portable?.skipTests ?? false
settingsPath = normalizedLocalPath(stored?.local?.settingsPath)
localRepositoryPath = normalizedLocalPath(stored?.local?.localRepositoryPath)
mavenExecutablePath = normalizedLocalPath(stored?.local?.mavenExecutablePath)
javaHomePath = normalizedLocalPath(stored?.local?.javaHomePath)
}
Expand Down Expand Up @@ -482,6 +491,7 @@ package final class MavenService: ObservableObject {
),
local: MavenLocalConfiguration(
settingsPath: settingsPath,
localRepositoryPath: localRepositoryPath,
mavenExecutablePath: mavenExecutablePath,
javaHomePath: javaHomePath
)
Expand Down
16 changes: 10 additions & 6 deletions rust/lithe-core/src/execution/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,10 @@ fn detect_requirements(
if maven_root.join("mvnw").exists() {
maven.wrapper = Some("./mvnw".to_string());
}
maven.version = maven_wrapper_version(maven_root);
// Wrapper distribution is a floor for system Maven, not an exact pin. A
// newer installed Maven (for example 3.9.x against a 3.6.x wrapper URL)
// remains valid for launch planning and run diagnostics.
maven.minimum_version = maven_wrapper_version(maven_root);
let mut toolchains = BTreeMap::new();
let consumes = |toolchain: &str| {
configurations.iter().any(|configuration| {
Expand Down Expand Up @@ -2485,11 +2488,12 @@ fn toolchain_diagnostics(
.as_deref()
.or(requirement.version.as_deref());
if let Some(required) = required_version {
if !version_satisfies(
&candidate.version,
required,
requirement.minimum_version.is_some(),
) {
// Maven wrapper properties historically landed in `version`. Treat
// that field as a minimum for Maven so already-written requirement
// documents do not block newer system Maven installs.
let treat_as_minimum = requirement.minimum_version.is_some()
|| (requirement.kind == "maven" && requirement.version.is_some());
if !version_satisfies(&candidate.version, required, treat_as_minimum) {
append_toolchain_diagnostics(
&mut diagnostics,
&consumer_ids,
Expand Down
1 change: 1 addition & 0 deletions rust/lithe-core/src/lsp/interface/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3560,6 +3560,7 @@ mod tests {
"enterprise".to_string(),
],
settings_path: Some("/local/settings.xml".to_string()),
local_repository_path: None,
skip_tests: true,
maven_executable_path: Some("/local/maven/bin/mvn".to_string()),
java_home_path: Some("/local/jdk".to_string()),
Expand Down
15 changes: 15 additions & 0 deletions rust/lithe-core/src/project/maven.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub struct MavenLaunchContextRequest {
#[serde(default)]
pub settings_path: Option<String>,
#[serde(default)]
pub local_repository_path: Option<String>,
#[serde(default)]
pub skip_tests: bool,
#[serde(default)]
pub maven_executable_path: Option<String>,
Expand Down Expand Up @@ -82,6 +84,7 @@ struct ValidatedMavenContext {
canonical_reactor: PathBuf,
profiles: Vec<String>,
settings_path: Option<String>,
local_repository_path: Option<String>,
skip_tests: bool,
maven_executable_path: Option<String>,
java_home_path: Option<String>,
Expand Down Expand Up @@ -134,6 +137,7 @@ pub(crate) fn launch_plan_with_arguments(
let arguments = maven_arguments(
&validated.profiles,
validated.settings_path.as_deref(),
validated.local_repository_path.as_deref(),
module.as_deref(),
also_make,
validated.skip_tests,
Expand All @@ -143,6 +147,7 @@ pub(crate) fn launch_plan_with_arguments(
&validated.reactor_path,
&validated.profiles,
validated.settings_path.as_deref(),
validated.local_repository_path.as_deref(),
validated.skip_tests,
validated.maven_executable_path.as_deref(),
validated.java_home_path.as_deref(),
Expand Down Expand Up @@ -240,6 +245,10 @@ fn validated_maven_context(
canonical_reactor,
profiles: normalized_profiles(context.profiles)?,
settings_path: normalized_local_path(context.settings_path, "Maven settings")?,
local_repository_path: normalized_local_path(
context.local_repository_path,
"Maven local repository",
)?,
skip_tests: context.skip_tests,
maven_executable_path: normalized_local_path(
context.maven_executable_path,
Expand All @@ -253,6 +262,7 @@ fn validated_maven_context(
pub(crate) fn maven_arguments(
profiles: &[String],
settings_path: Option<&str>,
local_repository_path: Option<&str>,
module: Option<&str>,
also_make: bool,
skip_tests: bool,
Expand All @@ -265,6 +275,9 @@ pub(crate) fn maven_arguments(
if let Some(settings_path) = settings_path {
arguments.extend(["-s".to_string(), settings_path.to_string()]);
}
if let Some(local_repository_path) = local_repository_path {
arguments.push(format!("-Dmaven.repo.local={local_repository_path}"));
}
if let Some(module) = module.filter(|value| *value != ".") {
arguments.extend(["-pl".to_string(), module.to_string()]);
if also_make {
Expand Down Expand Up @@ -359,6 +372,7 @@ fn maven_context_fingerprint(
reactor_path: &str,
profiles: &[String],
settings_path: Option<&str>,
local_repository_path: Option<&str>,
skip_tests: bool,
maven_executable_path: Option<&str>,
java_home_path: Option<&str>,
Expand All @@ -369,6 +383,7 @@ fn maven_context_fingerprint(
reactor_path.to_string(),
profiles.join(","),
settings_path.unwrap_or_default().to_string(),
local_repository_path.unwrap_or_default().to_string(),
skip_tests.to_string(),
maven_executable_path.unwrap_or_default().to_string(),
java_home_path.unwrap_or_default().to_string(),
Expand Down
1 change: 1 addition & 0 deletions rust/lithe-core/src/tests/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ fn maven_jdt_configuration_includes_module_java_source_paths() {
reactor_path: ".".to_string(),
profiles: Vec::new(),
settings_path: None,
local_repository_path: None,
skip_tests: false,
maven_executable_path: None,
java_home_path: None,
Expand Down
Loading
Loading