From e62be0b66a92e07709cea8a13d77ccfd6b99bc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Wed, 15 Jan 2025 10:36:38 +0200 Subject: [PATCH] Fix launch -configuration param to always be proper URI 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. --- .../EclipseApplicationLaunchConfiguration.java | 2 +- .../pde/launching/EquinoxLaunchConfiguration.java | 2 +- .../launching/JUnitLaunchConfigurationDelegate.java | 2 +- .../pde/ui/tests/launcher/PluginBasedLaunchTest.java | 11 ++--------- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java index bf4c5fbd6e..8f5e8e40c2 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java @@ -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$ diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EquinoxLaunchConfiguration.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EquinoxLaunchConfiguration.java index d0cff40d50..1dad870dc6 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EquinoxLaunchConfiguration.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EquinoxLaunchConfiguration.java @@ -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); diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java index a8408a5dc5..944b5208bf 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java @@ -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$ diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java index 9385f331d1..97c7cd0b2a 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java @@ -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; @@ -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) {