From 4ae2b594e20857292bf784004dd52862979de49f Mon Sep 17 00:00:00 2001 From: "simon.jiang" Date: Thu, 24 Jan 2019 10:53:46 +0800 Subject: [PATCH 1/2] INTELLIJ-41 fix tomcat bundle start issue with jdk 11 --- .../server/LiferayServerCommandLineState.java | 3 +- .../ide/idea/server/portal/PortalBundle.java | 4 ++- .../server/portal/PortalTomcatBundle.java | 30 ++++++++++++++++--- .../server/portal/PortalWildFlyBundle.java | 4 ++- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java b/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java index 96939b472..936864f19 100644 --- a/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java +++ b/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java @@ -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 diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java index b5e0287a4..a1b3f6422 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java @@ -14,6 +14,8 @@ package com.liferay.ide.idea.server.portal; +import com.intellij.openapi.projectRoots.Sdk; + import java.nio.file.Path; /** @@ -29,7 +31,7 @@ public interface PortalBundle { public String[] getRuntimeStartProgArgs(); - public String[] getRuntimeStartVMArgs(); + public String[] getRuntimeStartVMArgs(Sdk javaJdk); public String getType(); diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java index 64b50feb5..f05d84302 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java @@ -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 @@ -70,8 +77,8 @@ public String[] getRuntimeStartProgArgs() { } @Override - public String[] getRuntimeStartVMArgs() { - return _getRuntimeVMArgs(); + public String[] getRuntimeStartVMArgs(Sdk javaJdk) { + return _getRuntimeVMArgs(javaJdk); } @Override @@ -79,7 +86,7 @@ public String getType() { return "tomcat"; } - private String[] _getRuntimeVMArgs() { + private String[] _getRuntimeVMArgs(Sdk javaJdk) { List args = new ArrayList<>(); Path tempPath = FileUtil.pathAppend(bundlePath, "temp"); Path endorsedPath = FileUtil.pathAppend(bundlePath, "endorsed"); @@ -87,7 +94,20 @@ private String[] _getRuntimeVMArgs() { 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(javaJdk, Attributes.Name.SPECIFICATION_VERSION); + + if (!CoreUtil.isNullOrEmpty(jdkVersionString)) { + Version jdkVersion = Version.parseVersion(jdkVersionString); + + 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")); @@ -98,4 +118,6 @@ private String[] _getRuntimeVMArgs() { return args.toArray(new String[0]); } + private static Version _jdk8Version = Version.parseVersion("1.8"); + } \ No newline at end of file diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java index 4fbb2b3d9..589c229e6 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java @@ -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; @@ -86,7 +88,7 @@ public String[] getRuntimeStartProgArgs() { } @Override - public String[] getRuntimeStartVMArgs() { + public String[] getRuntimeStartVMArgs(Sdk javaJdk) { List args = new ArrayList<>(); args.add("-Dorg.jboss.resolver.warning=true"); From ea2ba2f9ad88ea5dd2cd0881e058ee8e5e85564f Mon Sep 17 00:00:00 2001 From: Terry Jia Date: Thu, 24 Jan 2019 11:41:53 +0800 Subject: [PATCH 2/2] INTELLIJ-41 remove unnecessary variable and rename --- .../ide/idea/server/portal/PortalBundle.java | 2 +- .../ide/idea/server/portal/PortalTomcatBundle.java | 14 +++++++------- .../idea/server/portal/PortalWildFlyBundle.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java index a1b3f6422..0e970f7dd 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java @@ -31,7 +31,7 @@ public interface PortalBundle { public String[] getRuntimeStartProgArgs(); - public String[] getRuntimeStartVMArgs(Sdk javaJdk); + public String[] getRuntimeStartVMArgs(Sdk sdk); public String getType(); diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java index f05d84302..fda1ace8d 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java @@ -77,8 +77,8 @@ public String[] getRuntimeStartProgArgs() { } @Override - public String[] getRuntimeStartVMArgs(Sdk javaJdk) { - return _getRuntimeVMArgs(javaJdk); + public String[] getRuntimeStartVMArgs(Sdk sdk) { + return _getRuntimeVMArgs(sdk); } @Override @@ -86,7 +86,7 @@ public String getType() { return "tomcat"; } - private String[] _getRuntimeVMArgs(Sdk javaJdk) { + private String[] _getRuntimeVMArgs(Sdk sdk) { List args = new ArrayList<>(); Path tempPath = FileUtil.pathAppend(bundlePath, "temp"); Path endorsedPath = FileUtil.pathAppend(bundlePath, "endorsed"); @@ -95,12 +95,14 @@ private String[] _getRuntimeVMArgs(Sdk javaJdk) { args.add("-Dcatalina.home=" + bundlePath); args.add("-Dfile.encoding=UTF8"); - String jdkVersionString = JdkUtil.getJdkMainAttribute(javaJdk, Attributes.Name.SPECIFICATION_VERSION); + String jdkVersionString = JdkUtil.getJdkMainAttribute(sdk, Attributes.Name.SPECIFICATION_VERSION); if (!CoreUtil.isNullOrEmpty(jdkVersionString)) { Version jdkVersion = Version.parseVersion(jdkVersionString); - if (jdkVersion.compareTo(_jdk8Version) <= 0) { + Version jdk8Version = Version.parseVersion("1.8"); + + if (jdkVersion.compareTo(jdk8Version) <= 0) { args.add("-Djava.endorsed.dirs=" + endorsedPath); } } @@ -118,6 +120,4 @@ private String[] _getRuntimeVMArgs(Sdk javaJdk) { return args.toArray(new String[0]); } - private static Version _jdk8Version = Version.parseVersion("1.8"); - } \ No newline at end of file diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java index 589c229e6..256af2562 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java @@ -88,7 +88,7 @@ public String[] getRuntimeStartProgArgs() { } @Override - public String[] getRuntimeStartVMArgs(Sdk javaJdk) { + public String[] getRuntimeStartVMArgs(Sdk sdk) { List args = new ArrayList<>(); args.add("-Dorg.jboss.resolver.warning=true");