Skip to content

Commit

Permalink
Merge pull request liferay#101 from gamerson/pr-91
Browse files Browse the repository at this point in the history
INTELLIJ-41 remove unnecessary variable and rename
  • Loading branch information
gamerson authored Jan 24, 2019
2 parents 3277ea4 + ea2ba2f commit b43146d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ protected JavaParameters createJavaParameters() throws ExecutionException {

ParametersList vmParametersList = javaParameters.getVMParametersList();

String[] runtimeStartVMArgs = portalBundle.getRuntimeStartVMArgs();
String[] runtimeStartVMArgs = portalBundle.getRuntimeStartVMArgs(
JavaParametersUtil.createProjectJdk(liferayServerConfiguration.getProject(), jrePath));

Stream.of(
runtimeStartVMArgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.liferay.ide.idea.server.portal;

import com.intellij.openapi.projectRoots.Sdk;

import java.nio.file.Path;

/**
Expand All @@ -29,7 +31,7 @@ public interface PortalBundle {

public String[] getRuntimeStartProgArgs();

public String[] getRuntimeStartVMArgs();
public String[] getRuntimeStartVMArgs(Sdk sdk);

public String getType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@

package com.liferay.ide.idea.server.portal;

import com.intellij.openapi.projectRoots.JdkUtil;
import com.intellij.openapi.projectRoots.Sdk;

import com.liferay.ide.idea.util.CoreUtil;
import com.liferay.ide.idea.util.FileUtil;

import java.nio.file.Path;

import java.util.ArrayList;
import java.util.List;
import java.util.jar.Attributes;

import org.osgi.framework.Version;

/**
* @author Simon Jiang
Expand Down Expand Up @@ -70,24 +77,39 @@ public String[] getRuntimeStartProgArgs() {
}

@Override
public String[] getRuntimeStartVMArgs() {
return _getRuntimeVMArgs();
public String[] getRuntimeStartVMArgs(Sdk sdk) {
return _getRuntimeVMArgs(sdk);
}

@Override
public String getType() {
return "tomcat";
}

private String[] _getRuntimeVMArgs() {
private String[] _getRuntimeVMArgs(Sdk sdk) {
List<String> args = new ArrayList<>();
Path tempPath = FileUtil.pathAppend(bundlePath, "temp");
Path endorsedPath = FileUtil.pathAppend(bundlePath, "endorsed");

args.add("-Dcatalina.base=" + bundlePath);
args.add("-Dcatalina.home=" + bundlePath);
args.add("-Dfile.encoding=UTF8");
args.add("-Djava.endorsed.dirs=" + endorsedPath);

String jdkVersionString = JdkUtil.getJdkMainAttribute(sdk, Attributes.Name.SPECIFICATION_VERSION);

if (!CoreUtil.isNullOrEmpty(jdkVersionString)) {
Version jdkVersion = Version.parseVersion(jdkVersionString);

Version jdk8Version = Version.parseVersion("1.8");

if (jdkVersion.compareTo(jdk8Version) <= 0) {
args.add("-Djava.endorsed.dirs=" + endorsedPath);
}
}
else {
args.add("-Djava.endorsed.dirs=" + endorsedPath);
}

args.add("-Djava.io.tmpdir=" + tempPath);
args.add("-Djava.net.preferIPv4Stack=true");
args.add("-Djava.util.logging.config.file=" + FileUtil.pathAppend(bundlePath, "conf/logging.properties"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.liferay.ide.idea.server.portal;

import com.intellij.openapi.projectRoots.Sdk;

import com.liferay.ide.idea.util.FileUtil;
import com.liferay.ide.idea.util.ListUtil;

Expand Down Expand Up @@ -86,7 +88,7 @@ public String[] getRuntimeStartProgArgs() {
}

@Override
public String[] getRuntimeStartVMArgs() {
public String[] getRuntimeStartVMArgs(Sdk sdk) {
List<String> args = new ArrayList<>();

args.add("-Dorg.jboss.resolver.warning=true");
Expand Down

0 comments on commit b43146d

Please sign in to comment.