Skip to content

Commit

Permalink
fix(QTDI-763) issue to enable Tacokit (#945)
Browse files Browse the repository at this point in the history
* fix(QTDI-835) issue to enable Tacokit


---------

Co-authored-by: Emmanuel GALLOIS <egallois@talend.com>
  • Loading branch information
yyin-talend and undx authored Dec 5, 2024
1 parent 9e720c9 commit c30452a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.talend.sdk.component.runtime.manager.service;

import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -79,7 +80,14 @@ private Path fromStudioConfiguration() {
// check if we are in the studio process if so just grab the studio config
final String m2Repo = System.getProperty(STUDIO_MVN_REPOSITORY);
if (!"global".equals(m2Repo)) {
return handler.get(Paths.get(System.getProperty("osgi.configuration.area", ""), M2_REPOSITORY).toString());
final String osgi = System.getProperty("osgi.configuration.area", "");
try {
return osgi != null && osgi.startsWith("file") ? handler.get(Paths.get(new URI(osgi)).toString())
: handler.get(Paths.get(osgi, M2_REPOSITORY).toString());
} catch (java.net.URISyntaxException e) {
log.debug("[fromStudioConfiguration] Could not get m2 from studio config." + e.getMessage());
return null;
}
}
log.debug("[fromStudioConfiguration] Could not get m2 from studio config.");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,40 @@ void discoverFromSettingsWindowsPath() {
System.clearProperty(TALEND_COMPONENT_MANAGER_M2_SETTINGS);
}

@Test
void discoverFromWindowsPathWithFile() {
System.setProperty("osgi.configuration.area", "file:/C:/Users/Talend-Studio-CICD_TEST/configuration/");
System.setProperty(STUDIO_MVN_REPOSITORY, "studio");
final Path m2 = resolver.discover();
assertNotNull(m2);
System.clearProperty("osgi.configuration.area");
System.clearProperty(STUDIO_MVN_REPOSITORY);
}

@Test
void discoverFromWindowsPathWithoutFile() {
System.setProperty("osgi.configuration.area", "C:/Users/Talend-Studio-CICD_TEST/configuration/");
final Path m3 = resolver.discover();
assertNotNull(m3);
System.clearProperty("osgi.configuration.area");
}

@Test
void discoverFromWindowsPathWrongURI() {
System.setProperty("osgi.configuration.area", "file://example .com");
final Path m4 = resolver.discover();
assertNotNull(m4);
System.clearProperty("osgi.configuration.area");
}

@Test
void discoverFromWindowsPathGlobal() {
System.setProperty(STUDIO_MVN_REPOSITORY, "global");
final Path m5 = resolver.discover();
assertNotNull(m5);
System.clearProperty(STUDIO_MVN_REPOSITORY);
}

@Test
void discoverFromSettingsTildePath() {
setSettingsProperty("settings/settings-tilde.xml");
Expand Down

0 comments on commit c30452a

Please sign in to comment.