Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-7326 Eclipse support Payara Server running on WSL #68

Merged
merged 2 commits into from
Jun 27, 2023
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 @@ -60,7 +60,7 @@ public void createControl(Composite parent) {
createUI(composite);
validate();
createAdvancedSettings(composite, new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
resolverConfigurationComponent.setModifyListener(e -> validate());
// resolverConfigurationComponent.setModifyListener(e -> validate());
setControl(composite);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public final class PayaraServer extends ServerDelegate implements IURLProvider {
public static final String DEFAULT_HOT_DEPLOY = "false";
public static final String DEFAULT_TYPE = "";
public static final String DOCKER_TYPE = "Docker";
public static final String WSL_TYPE = "WSL";
protected static final String PROP_INSTANCE_TYPE = "instance.type";
protected static final String PROP_HOST_PATH = "host.path";
protected static final String PROP_CONTAINER_PATH = "container.path";
Expand Down Expand Up @@ -238,16 +239,14 @@ private static String lastSegment(String path) {

public boolean isRemote() {
return getServer().getServerType().supportsRemoteHosts()
&& (DOCKER_TYPE.equals(getInstanceType()) || !isLocalhost(getServer().getHost()));
&& (DOCKER_TYPE.equals(getInstanceType()) || WSL_TYPE.equals(getInstanceType()) || !isLocalhost(getServer().getHost()));
}

public String getDebugOptions(int debugPort) {
public String getDebugOptions(int debugPort) {
Version version = getVersion();

if (version.matches("[4")) {
return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + debugPort;
}

return "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + debugPort;
}

Expand Down Expand Up @@ -559,6 +558,10 @@ public boolean isDockerInstance() {
return DOCKER_TYPE.equals(getAttribute(PROP_INSTANCE_TYPE, (String) null));
}

public boolean isWSLInstance() {
return WSL_TYPE.equals(getAttribute(PROP_INSTANCE_TYPE, (String) null));
}

public String getInstanceType() {
return this.getAttribute(PROP_INSTANCE_TYPE, (String) null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,10 @@ private void publishModuleForPayara(int kind, int deltaKind, IModule[] module, I

boolean isRemote = getPayaraServerDelegate().isRemote();
boolean isDockerInstance = getPayaraServerDelegate().isDockerInstance();
boolean isWSLInstance = getPayaraServerDelegate().isWSLInstance();
boolean isJarDeploy = getPayaraServerDelegate().getJarDeploy();

if ((!isRemote && !isJarDeploy) || isDockerInstance) {
if ((!isRemote && !isJarDeploy) || isDockerInstance || isWSLInstance) {
publishDeployedDirectory(kind, deltaKind, publishProperties, module, monitor);
} else {
publishJarFile(kind, deltaKind, publishProperties, module, monitor);
Expand Down Expand Up @@ -612,6 +613,7 @@ private void publishDeployedDirectory(int kind, int deltaKind, Properties publis
// the deployed apps
// so that the move operation Eclipse is doing sometimes can work.
boolean dockerInstance = getPayaraServerDelegate().isDockerInstance();
boolean wslInstance = getPayaraServerDelegate().isWSLInstance();
String hostPath = getPayaraServerDelegate().getHostPath();
String containerPath = getPayaraServerDelegate().getContainerPath();

Expand Down Expand Up @@ -680,7 +682,7 @@ private void publishDeployedDirectory(int kind, int deltaKind, Properties publis
CommandTarget command = null;
if (deltaKind == ADDED) {
command = new CommandDeploy(name, null, new File("" + path), contextRoot, properties, new File[0],
dockerInstance, hostPath, containerPath, hotDeploy);
dockerInstance, wslInstance, hostPath, containerPath, hotDeploy);
} else {
command = new CommandRedeploy(name, null, contextRoot, properties, new File[0], keepSession,
hotDeploy, metadataChanged, sourcesChanged);
Expand Down Expand Up @@ -724,6 +726,7 @@ private void publishJarFile(int kind, int deltaKind, Properties p, IModule[] mod
String contextRoot = null;

boolean dockerInstance = getPayaraServerDelegate().isDockerInstance();
boolean wslInstance = getPayaraServerDelegate().isWSLInstance();
String hostPath = getPayaraServerDelegate().getHostPath();
String containerPath = getPayaraServerDelegate().getContainerPath();

Expand All @@ -738,7 +741,7 @@ private void publishJarFile(int kind, int deltaKind, Properties p, IModule[] mod
try {
ServerAdmin.executeOn(getPayaraServerDelegate())
.command(new CommandDeploy(name, null, archivePath, contextRoot, getDeploymentProperties(),
new File[0], dockerInstance, hostPath, containerPath, hotDeploy))
new File[0], dockerInstance, wslInstance, hostPath, containerPath, hotDeploy))
.timeout(520).onNotCompleted(result -> {
logMessage("deploy is failing=" + result.getValue());
throw new IllegalStateException("deploy is failing=" + result.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static ResultString deploy(PayaraServer server, File application, TaskSta
throws PayaraIdeException {
try {
return ServerAdmin.<ResultString>exec(server, new CommandDeploy(null, null, application, null, null, null,
server.isDockerInstance(), server.getHostPath(), server.getContainerPath(), false), listener).get();
server.isDockerInstance(), server.isWSLInstance(), server.getHostPath(), server.getContainerPath(), false), listener).get();
} catch (InterruptedException | ExecutionException | CancellationException ie) {
throw new PayaraIdeException(ERROR_MESSAGE, ie);
}
Expand Down Expand Up @@ -100,6 +100,9 @@ public static ResultString deploy(PayaraServer server, File application, TaskSta
/** Docker Instance. */
final boolean dockerInstance;

/** WSL Instance. */
final boolean wslInstance;

/** Host Path. */
final String hostPath;

Expand All @@ -122,10 +125,13 @@ public static ResultString deploy(PayaraServer server, File application, TaskSta
* @param properties Deployment properties.
* @param libraries Not used in actual deploy command.
* @param dockerInstance Docker Instance.
* @param wslInstance WSL Instance
* @param hostPath
* @param containerPath
* @param hotDeploy Hot Deploy.
*/
public CommandDeploy(String name, String target, File path, String contextRoot, Map<String, String> properties,
File[] libraries, final boolean dockerInstance, final String hostPath, final String containerPath,
File[] libraries, final boolean dockerInstance, final boolean wslInstance, final String hostPath, final String containerPath,
final boolean hotDeploy) {
super(COMMAND, name, target);

Expand All @@ -135,9 +141,10 @@ public CommandDeploy(String name, String target, File path, String contextRoot,
this.libraries = libraries;
this.dirDeploy = path.isDirectory();
this.dockerInstance = dockerInstance;
this.wslInstance = wslInstance;
this.hostPath = hostPath;
this.containerPath = containerPath;
this.hotDeploy = hotDeploy;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ private static String query(final Command command) {
throw new CommandException(CommandException.DOCKER_HOST_APPLICATION_PATH);
}
}
if (deploy.wslInstance) {
// Replace backslashes with forward slashes
path = path.replace("\\", "/");
// Add "mnt" prefix and drive letter
path = "/mnt/" + path.substring(0, 1).toLowerCase() + path.substring(2);
}
// Calculate StringBuilder initial length to avoid resizing
StringBuilder sb = new StringBuilder(DEFAULT_PARAM.length() + 1 + path.length() + 1 + FORCE_PARAM.length() + 1
+ force.length() + queryPropertiesLength(deploy.properties, PROPERTIES_PARAM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ protected void handleSend(HttpURLConnection hconn) throws IOException {
throw new CommandException(CommandException.DOCKER_HOST_APPLICATION_PATH);
}
}
if (command.wslInstance) {
// Replace backslashes with forward slashes
path = path.replace("\\", "/");
// Add "mnt" prefix and drive letter
path = "/mnt/" + path.substring(0, 1).toLowerCase() + path.substring(2);
}
OutputStreamWriter wr = new OutputStreamWriter(hconn.getOutputStream());
if (!command.dirDeploy) {
writeParam(wr, "path", path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class NewPayaraServerWizardFragment extends WizardFragment {

private Combo instanceTypeCombo;

private String[] instanceTypes = { PayaraServer.DEFAULT_TYPE, PayaraServer.DOCKER_TYPE };
private String[] instanceTypes = { PayaraServer.DEFAULT_TYPE, PayaraServer.DOCKER_TYPE, PayaraServer.WSL_TYPE };

private Label hostLocationLabel;

Expand Down