Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

NP-10 NetBeans plugin JDK 11 support #17

Merged
merged 1 commit into from Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions payara.common/src/sun/util/logging/resources/logging.properties
@@ -0,0 +1,46 @@
#
# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

# Localizations for Level names. For the US locale
# these are the same as the non-localized level name.

# The following ALL CAPS words should be translated.
ALL=All
# The following ALL CAPS words should be translated.
SEVERE=Severe
# The following ALL CAPS words should be translated.
WARNING=Warning
# The following ALL CAPS words should be translated.
INFO=Info
# The following ALL CAPS words should be translated.
CONFIG= Config
# The following ALL CAPS words should be translated.
FINE=Fine
# The following ALL CAPS words should be translated.
FINER=Finer
# The following ALL CAPS words should be translated.
FINEST=Finest
# The following ALL CAPS words should be translated.
OFF=Off
9 changes: 9 additions & 0 deletions payara.tooling/nbproject/project.xml
Expand Up @@ -24,6 +24,15 @@
<specification-version>0.10</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.xml.jaxb.api</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.29.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
Expand Down
Expand Up @@ -37,12 +37,13 @@
*
* Contributor(s):
*/
// Portions Copyright [2017] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2019] [Payara Foundation and/or its affiliates]

package org.netbeans.modules.payara.tooling.data;

import java.util.List;
import java.util.Map;
import org.netbeans.modules.payara.tooling.server.JDK.Version;

/**
* This interface provides IDE and user specific arguments for starting the server.
Expand All @@ -59,4 +60,6 @@ public interface StartupArgs {

public String getJavaHome();

public Version getJavaVersion();

}
Expand Up @@ -37,12 +37,19 @@
*
* Contributor(s):
*/
// Portions Copyright [2017] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2019] [Payara Foundation and/or its affiliates]

package org.netbeans.modules.payara.tooling.data;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.netbeans.modules.payara.tooling.server.JDK;
import org.netbeans.modules.payara.tooling.server.JDK.Version;
import org.openide.util.Exceptions;

/**
* Payara Server Entity.
Expand All @@ -69,6 +76,9 @@ public class StartupArgsEntity implements StartupArgs {
/** Installation home of Java SDK used to run Payara. */
private String javaHome;

/** Version of Java SDK used to run Payara. */
private Version javaVersion;

////////////////////////////////////////////////////////////////////////////
// Constructors //
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -176,4 +186,23 @@ public void getJavaHome(String javaHome) {
this.javaHome = javaHome;
}

/**
* Get version of Java SDK used to run Payara.
* <p/>
* @return version of Java SDK used to run Payara.
*/
@Override
public Version getJavaVersion() {
if(javaVersion == null && javaHome != null) {
try (BufferedReader bufferedReader
= new BufferedReader(new FileReader(new File(javaHome, "release")));) {
String version = bufferedReader.readLine();
javaVersion = JDK.getVersion(version.substring(version.indexOf("\"") + 1, version.lastIndexOf("\"")));
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
return javaVersion;
}

}
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates]

package org.netbeans.modules.payara.tooling.server;

Expand Down Expand Up @@ -239,17 +239,21 @@ public static Version getVersion() {
return new Version();
}

public static boolean isCorrectJDK(Optional<Version> minVersion, Optional<Version> maxVersion) {
public static boolean isCorrectJDK(Version jdkVersion, Optional<Version> minVersion, Optional<Version> maxVersion) {
boolean correctJDK = true;
if (minVersion.isPresent()) {
correctJDK = JDK_VERSION.newerOrEquals(minVersion.get());
correctJDK = jdkVersion.newerOrEquals(minVersion.get());
}
if (correctJDK && maxVersion.isPresent()) {
correctJDK = JDK_VERSION.olderOrEquals(maxVersion.get());
correctJDK = jdkVersion.olderOrEquals(maxVersion.get());
}
return correctJDK;
}

public static boolean isCorrectJDK(Optional<Version> minVersion, Optional<Version> maxVersion) {
return isCorrectJDK(IDE_JDK_VERSION, minVersion, maxVersion);
}

/**
* No instances are allowed so it is pointless to override toString
* @return Parsed version numbers
Expand All @@ -271,7 +275,7 @@ public static String toStringStatic() {
private static int minor;
private static int subminor;
private static int update;
private static Version JDK_VERSION;
public static Version IDE_JDK_VERSION;

// silently fall back to ridiculous defaults if something is crazily wrong...
private static void initialize() {
Expand Down Expand Up @@ -337,6 +341,6 @@ private static void initialize() {
// ignore -- use defaults
}

JDK_VERSION = new Version();
IDE_JDK_VERSION = new Version();
}
}
Expand Up @@ -37,7 +37,7 @@
*
* Contributor(s):
*/
// Portions Copyright [2017-2018] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2019] [Payara Foundation and/or its affiliates]

package org.netbeans.modules.payara.tooling.server;

Expand All @@ -61,6 +61,8 @@
import org.netbeans.modules.payara.tooling.utils.ServerUtils;
import org.netbeans.modules.payara.tooling.utils.Utils;
import org.netbeans.modules.payara.tooling.data.PayaraServer;
import static org.netbeans.modules.payara.tooling.server.JDK.IDE_JDK_VERSION;
import org.netbeans.modules.payara.tooling.server.JDK.Version;
import org.netbeans.modules.payara.tooling.server.parser.JvmConfigReader.JvmOption;

/**
Expand Down Expand Up @@ -184,10 +186,12 @@ public static ResultProcess startServer(PayaraServer server,
METHOD, "readXMLerror"), domainXmlPath);
}
}

Version javaVersion = args.getJavaVersion() != null ? args.getJavaVersion() : IDE_JDK_VERSION;
List<String> optList
= jvmConfigReader.getJvmOptions()
.stream()
.filter(fullOption -> JDK.isCorrectJDK(fullOption.minVersion, fullOption.maxVersion))
.filter(fullOption -> JDK.isCorrectJDK(javaVersion, fullOption.minVersion, fullOption.maxVersion))
.map(fullOption -> fullOption.option)
.collect(toList());

Expand Down