Skip to content

Commit

Permalink
Fix MavenSettingsInitializerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
fabapp2 committed Dec 15, 2023
1 parent 073dbe1 commit 9c784e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public MavenSettingsInitializer(ExecutionContext executionContext, ProjectMetada
}

public void initializeMavenSettings() {
Path userHome = Path.of(System.getProperty("user.home"));
Path userHome = Path.of(System.getProperty("user.home")).toAbsolutePath().normalize();
String m2RepoPath = userHome.resolve(".m2/repository").toAbsolutePath().normalize() + "/";
String unifiedM2RepoPath = LinuxWindowsPathUnifier.unifiedPathString(m2RepoPath);
String repo = "file://" + unifiedM2RepoPath;
Expand All @@ -64,7 +64,7 @@ public void initializeMavenSettings() {
MavenSettings.@Nullable ActiveProfiles activeProfiles = new MavenSettings.ActiveProfiles(List.of("default"));
MavenSettings.@Nullable Mirrors mirrors = new MavenSettings.Mirrors();
MavenSettings.Servers servers = new MavenSettings.Servers();
MavenSettings mavenSettings = new MavenSettings(m2RepoPath, mavenRepository, profiles, activeProfiles, mirrors,
MavenSettings mavenSettings = new MavenSettings(repo, mavenRepository, profiles, activeProfiles, mirrors,
servers);

// TODO: Add support for global Maven settings (${maven.home}/conf/settings.xml).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.sonatype.plexus.components.cipher.PlexusCipherException;
import org.springframework.rewrite.parsers.RewriteExecutionContext;
import org.springframework.rewrite.scopes.ProjectMetadata;
import org.springframework.rewrite.utils.LinuxWindowsPathUnifier;

import java.net.URISyntaxException;
import java.nio.file.Path;
Expand Down Expand Up @@ -57,13 +58,9 @@ void mavenParserMustAdhereToSettingsXmlTest() throws URISyntaxException, PlexusC
MavenRepository localRepository = mavenExecutionContextView.getLocalRepository();
assertThat(localRepository.getSnapshots()).isNull();

String tmpDir = removeTrailingSlash(System.getProperty("java.io.tmpdir"));
String customLocalRepository = "file://" + Path.of(System.getProperty("user.home"))
.resolve(".m2/repository")
.toAbsolutePath()
.normalize()
.toString();// new URI("file://" + tmpDir).toString();
assertThat(removeTrailingSlash(localRepository.getUri())).isEqualTo(customLocalRepository);
String expectedCustomLocalRepository = "file://" + LinuxWindowsPathUnifier.unifiedPathString(Path.of(System.getProperty("user.home")).resolve(".m2/repository").toAbsolutePath().normalize());

assertThat(removeTrailingSlash(localRepository.getUri())).isEqualTo(expectedCustomLocalRepository);
assertThat(localRepository.getSnapshots()).isNull();
assertThat(localRepository.isKnownToExist()).isTrue();
assertThat(localRepository.getUsername()).isNull();
Expand Down

0 comments on commit 9c784e8

Please sign in to comment.