Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class EclipseApp {
* such as `org.eclipse.ant.core.antRunner` or `org.eclipse.equinox.p2.director`
*/
public EclipseApp(String application) {
addArg("-launcher.suppressErrors");
addArg("application", application);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
*/
package com.diffplug.gradle.eclipserunner;

import static java.util.stream.Collectors.toList;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.SortedSet;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

import org.eclipse.core.runtime.adaptor.EclipseStarter;
import org.osgi.framework.BundleContext;
Expand Down Expand Up @@ -107,7 +110,12 @@ private File getPluginRequireSingle(String name) {

/** Sets the application arguments which will be passed to the runtime. */
public EquinoxLauncher setArgs(List<String> args) {
this.args = ImmutableList.copyOf(args);
// Filter arguments that where meant for the original launcher (eclipsec.exe)
List<String> filteredArgs = args.stream()
.filter(Objects::nonNull)
.filter(arg -> !arg.startsWith("--launcher"))
.collect(toList());
this.args = ImmutableList.copyOf(filteredArgs);
return this;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this filter for? If I pass --launcher.someFlag, it will be silently discarded, which will be quite hard to debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed that for the P2BootstrapInstallationTest to pass, since unknown arguments will lead to an error (See log output at the end of this post). As i understood it, EquinoxLauncher is an alternate way to startup equinox, without having to use the native Eclipse launchers? The "--launcher" arguments are usually meant for the eclipse.exe or eclipsec.exe launchers and not passed further to Equinox. Please correct me, if my understanding is wrong. I would be glad for any better solution.

Installation failed.
!SESSION 2018-02-02 20:24:20.472 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_112
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=de_DE
Framework arguments: --launcher.suppressErrors -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/eclipse/updates/4.5/R-4.5.2-201602121500/ -installIU org.eclipse.core.runtime -profile profile -destination file:///var/folders/4d/z5fm5n5x5gsdzwswfrfd7b100000gn/T/junit191409443383839977/installed
Command-line arguments: --launcher.suppressErrors -application org.eclipse.equinox.p2.director -clean -consolelog -repository http://download.eclipse.org/eclipse/updates/4.5/R-4.5.2-201602121500/ -installIU org.eclipse.core.runtime -profile profile -destination file:///var/folders/4d/z5fm5n5x5gsdzwswfrfd7b100000gn/T/junit191409443383839977/installed

!ENTRY org.eclipse.equinox.p2.core 4 0 2018-02-02 20:24:20.474
!MESSAGE Unknown option --launcher.suppressErrors. Use -help for a list of known options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh, I see. You are correct about EqunoxLauncher.

I think a safer bet here would be to filter --launcher.suppressErrors only. There are quite a few --launcher flags, and it may be that some of them are supported by EquinoxLauncher.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allright. I changed that

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public void test() {
app.addArg("prop", "a");
app.addArg("prop", "b");
app.addArg("flag");
Assert.assertEquals("-application diffplug -prop a,b -flag", Joiner.on(" ").join(app.toArgList()));
Assert.assertEquals("-application diffplug\n-prop a,b\n-flag\n", app.toString());
Assert.assertEquals("--launcher.suppressErrors -application diffplug -prop a,b -flag", Joiner.on(" ").join(app.toArgList()));
Assert.assertEquals("--launcher.suppressErrors\n-application diffplug\n-prop a,b\n-flag\n", app.toString());
}

@Test
Expand All @@ -41,7 +41,7 @@ public void testDoubleAdd() {
app.addArg("flag");
app.addArg("flag");
app.addArg("flag");
Assert.assertEquals("-application diffplug -flag", Joiner.on(" ").join(app.toArgList()));
Assert.assertEquals("--launcher.suppressErrors -application diffplug -flag", Joiner.on(" ").join(app.toArgList()));
}

@SuppressWarnings("unchecked")
Expand All @@ -53,13 +53,14 @@ public void testAnt() {
task.attributes().put("prop", "propvalue");
ant.setTask(task);

Assert.assertEquals("-application org.eclipse.ant.core.antRunner -Dkey=value", Joiner.on(" ").join(ant.toArgList()));
Assert.assertEquals("--launcher.suppressErrors -application org.eclipse.ant.core.antRunner -Dkey=value", Joiner.on(" ").join(ant.toArgList()));
Assert.assertEquals(StringPrinter.buildStringFromLines(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><project>",
" <anttask prop=\"propvalue\"/>",
"</project>"), ant.buildXml());
Assert.assertEquals(StringPrinter.buildStringFromLines(
"### ARGS ###",
"--launcher.suppressErrors",
"-application org.eclipse.ant.core.antRunner",
"-Dkey=value",
"",
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/diffplug/gradle/p2/P2ModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void testDirectorArgs() {
File dest = new File("dest");
String actual = testData().directorApp(dest, "profile").completeState();
String expected = StringPrinter.buildStringFromLines(
"--launcher.suppressErrors",
"-application org.eclipse.equinox.p2.director",
"-clean",
"-consolelog",
Expand All @@ -57,6 +58,7 @@ public void testMirrorAntFile() {
String actual = testData().mirrorApp(dest).completeState();
String expected = StringPrinter.buildStringFromLines(
"### ARGS ###",
"--launcher.suppressErrors",
"-application org.eclipse.ant.core.antRunner",
"",
"### BUILD.XML ###",
Expand Down Expand Up @@ -85,6 +87,7 @@ public void testMirrorAntFileWithSlicingOptions() {
String actual = p2.mirrorApp(dest).completeState();
String expected = StringPrinter.buildStringFromLines(
"### ARGS ###",
"--launcher.suppressErrors",
"-application org.eclipse.ant.core.antRunner",
"",
"### BUILD.XML ###",
Expand Down Expand Up @@ -112,6 +115,7 @@ public void testMirrorAntFileWithAppend() {
String actual = p2.mirrorApp(dest).completeState();
String expected = StringPrinter.buildStringFromLines(
"### ARGS ###",
"--launcher.suppressErrors",
"-application org.eclipse.ant.core.antRunner",
"",
"### BUILD.XML ###",
Expand All @@ -137,6 +141,7 @@ public void testMirrorAntFileWithAppendDefault() {
String actual = p2.mirrorApp(dest).completeState();
String expected = StringPrinter.buildStringFromLines(
"### ARGS ###",
"--launcher.suppressErrors",
"-application org.eclipse.ant.core.antRunner",
"",
"### BUILD.XML ###",
Expand Down