Skip to content

Commit 286f0b0

Browse files
committed
USe absolute paths
1 parent c495c9e commit 286f0b0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

sbm-support-rewrite/src/test/java/org/springframework/sbm/PrivateArtifactRepositoryTest.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,18 @@ public class PrivateArtifactRepositoryTest {
102102
.withEnv("REPOSILITE_OPTS", "--token user:secret --shared-config shared.configuration.json");
103103

104104
public static final String DEPENDENCY_CLASS_FQNAME = "com.example.dependency.DependencyClass";
105-
private static final File LOCAL_MAVEN_REPOSITORY = Path.of(TESTCODE_DIR + "/user.home/.m2/repository").toFile();
106-
private static final Path DEPENDENCY_PATH_IN_LOCAL_MAVEN_REPO = Path.of(TESTCODE_DIR + "/user.home/.m2/repository/com/example/dependency/dependency-project");
105+
private static final String NEW_USER_HOME = Path.of(".").resolve(TESTCODE_DIR + "/user.home").toAbsolutePath().normalize().toString();
106+
private static final Path DEPENDENCY_PATH_IN_LOCAL_MAVEN_REPO = Path.of(NEW_USER_HOME + "/.m2/repository/com/example/dependency/dependency-project").toAbsolutePath().normalize();
107+
private static final File LOCAL_MAVEN_REPOSITORY = Path.of(NEW_USER_HOME + "/.m2/repository").toFile();
107108
private static MavenRepository originalMavenRepository;
108109
private static String originalUserHome;
109-
private static String newUserHome;
110110
@Autowired
111111
private RewriteProjectParser parser;
112112

113113
@BeforeAll
114114
static void beforeAll(@TempDir Path tempDir) {
115115
originalUserHome = System.getProperty("user.home");
116-
newUserHome = Path.of(".").resolve(TESTCODE_DIR + "/user.home").toAbsolutePath().normalize().toString();
117-
System.setProperty("user.home", newUserHome);
116+
System.setProperty("user.home", NEW_USER_HOME);
118117
originalMavenRepository = MavenRepository.MAVEN_LOCAL_DEFAULT;
119118
// overwrites MavenRepository.MAVEN_LOCAL_DEFAULT which is statically initialized and used previous value of
120119
// 'user.home'. This constant is used elsewhere to retrieve the default local Maven repo URI.
@@ -200,8 +199,8 @@ private static void renderTemplates(Integer port) throws IOException {
200199
Path dependentPomPath = renderPomXml(port, dependentPomTmplPath);
201200

202201
// adjust path in settings.xml
203-
Path settingsXmlTmplPath = Path.of("./").resolve(newUserHome + "/.m2/settings.xml.template").toAbsolutePath().normalize();
204-
renderSettingsXml(newUserHome, settingsXmlTmplPath);
202+
Path settingsXmlTmplPath = Path.of("./").resolve(NEW_USER_HOME + "/.m2/settings.xml.template").toAbsolutePath().normalize();
203+
renderSettingsXml(NEW_USER_HOME, settingsXmlTmplPath);
205204
}
206205

207206
private static Path renderSettingsXml(String testcodeDir, Path settingsXmlTmplPath) throws IOException {

0 commit comments

Comments
 (0)