Skip to content

Commit

Permalink
Fix launch -configuration param to always be proper URI
Browse files Browse the repository at this point in the history
Ensures that the parameter can always we be converted back to URI.
It's been already done for -dev param value.
Fixed PluginBasedLaunchTest to no longer try to "workaround"
-configuration values that can't be converted to URI.
  • Loading branch information
akurtakov committed Jan 15, 2025
1 parent aaaa0c0 commit e62be0b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public String[] getProgramArguments(ILaunchConfiguration configuration) throws C
boolean showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$
TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigDir(configuration));
programArgs.add("-configuration"); //$NON-NLS-1$
programArgs.add("file:" + IPath.fromOSString(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
programArgs.add(IPath.fromOSString(getConfigDir(configuration).getPath()).addTrailingSeparator().toPath().toUri().toString());

// add the output folder names
programArgs.add("-dev"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public String[] getProgramArguments(ILaunchConfiguration configuration) throws C

saveConfigurationFile(configuration);
programArgs.add("-configuration"); //$NON-NLS-1$
programArgs.add("file:" + IPath.fromOSString(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
programArgs.add(IPath.fromOSString(getConfigDir(configuration).getPath()).addTrailingSeparator().toPath().toUri().toString());

String[] args = super.getProgramArguments(configuration);
Collections.addAll(programArgs, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected void collectExecutionArguments(ILaunchConfiguration configuration, Lis
TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigurationDirectory(configuration));

programArgs.add("-configuration"); //$NON-NLS-1$
programArgs.add("file:" + IPath.fromOSString(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
programArgs.add(IPath.fromOSString(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toPath().toUri().toString());

// Specify the output folder names
programArgs.add("-dev"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@

import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
Expand Down Expand Up @@ -1052,18 +1050,13 @@ private static ILaunchConfigurationWorkingCopy createPluginLaunchConfig(String n
private static final Pattern WHITESPACE = Pattern.compile("\\s+");

private Path getConfigurationFolder(ILaunchConfigurationWorkingCopy launchConfig)
throws CoreException, MalformedURLException {
throws CoreException {
ILaunch launch = new Launch(launchConfig, ILaunchManager.RUN_MODE, null);
var config = new EclipseApplicationLaunchConfiguration();
String commandLine = config.showCommandLine(launchConfig, ILaunchManager.RUN_MODE, launch, null);
String configURL = WHITESPACE.splitAsStream(commandLine) //
.dropWhile(t -> !"-configuration".equals(t)).skip(1).findFirst().get();
// The configURL is not properly build, therefore this hack is necessary
try {
return Path.of(URI.create(configURL));
} catch (IllegalArgumentException e) {
return Path.of(new URL(configURL).getPath());
}
return Path.of(URI.create(configURL));
}

private static String getInstallLocation(IPluginModelBase plugin) {
Expand Down

0 comments on commit e62be0b

Please sign in to comment.