Skip to content

Commit 7177c82

Browse files
committed
Merge branch '2.x' into FISH-6772-javaee8-to-jakartaee10
2 parents 3f408d8 + b8ce791 commit 7177c82

17 files changed

Lines changed: 68 additions & 113 deletions

File tree

bundles/fish.payara.eclipse.tools.micro/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Payara Micro Tools
44
Bundle-SymbolicName: fish.payara.eclipse.tools.micro;singleton:=true
5-
Bundle-Version: 2.2.0
5+
Bundle-Version: 2.3.0
66
Bundle-ClassPath: .
77
Bundle-Localization: plugin
88
Bundle-Activator: fish.payara.eclipse.tools.micro.PayaraMicroPlugin

bundles/fish.payara.eclipse.tools.micro/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>fish.payara.eclipse</groupId>
1111
<artifactId>fish.payara.eclipse.bundles</artifactId>
12-
<version>2.2.0</version>
12+
<version>2.3.0</version>
1313
</parent>
1414
<build>
1515
<sourceDirectory>src</sourceDirectory>

bundles/fish.payara.eclipse.tools.server/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Payara Server Tools
44
Bundle-SymbolicName: fish.payara.eclipse.tools.server;singleton:=true
5-
Bundle-Version: 2.2.0
5+
Bundle-Version: 2.3.0
66
Bundle-ClassPath: .
77
Bundle-Localization: plugin
88
Bundle-Activator: fish.payara.eclipse.tools.server.PayaraServerPlugin

bundles/fish.payara.eclipse.tools.server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>fish.payara.eclipse</groupId>
1111
<artifactId>fish.payara.eclipse.bundles</artifactId>
12-
<version>2.2.0</version>
12+
<version>2.3.0</version>
1313
</parent>
1414
<build>
1515
<sourceDirectory>src</sourceDirectory>

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/sdk/server/ServerTasks.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,7 @@ private static JDK.Version getJavaVersion(StartupArgs args) {
239239
return JDK_VERSION;
240240
}
241241

242-
String[] versions = JavaUtils.getJavaVersionString(args.getJavaHome()).split(":");
243-
JDK.Version targetJDKVersion = null;
244-
245-
if (versions.length > 0) {
246-
targetJDKVersion = JDK.getVersion(versions[0], System.getProperty("java.vendor"));
247-
}
248-
249-
return targetJDKVersion;
242+
return JavaUtils.getJavaVersion(args.getJavaHome());
250243
}
251244

252245
public static Integer getDebugPort(ResultProcess process) {

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/sdk/utils/JavaUtils.java

Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.BufferedReader;
2424
import java.io.File;
25+
import java.io.FileReader;
2526
import java.io.IOException;
2627
import java.io.InputStream;
2728
import java.io.InputStreamReader;
@@ -38,6 +39,8 @@
3839
import java.util.regex.Pattern;
3940

4041
import fish.payara.eclipse.tools.server.sdk.logging.Logger;
42+
import fish.payara.eclipse.tools.server.sdk.server.JDK;
43+
import fish.payara.eclipse.tools.server.sdk.server.JDK.Version;
4144
import fish.payara.eclipse.tools.server.sdk.server.config.JavaSEPlatform;
4245

4346
/**
@@ -274,63 +277,32 @@ public static JavaVersion javaVmVersion(File javaVm) {
274277
return new JavaVersion(major, minor, revision, patch);
275278
}
276279

277-
public static String getJavaVersionString(String javaHome) {
278-
return getJavaVersionString(new File(javaVmExecutableFullPath(javaHome)));
279-
}
280-
281-
public static String getJavaVersionString(File javaVm) {
282-
List<String> javaVersions = new ArrayList<>();
283-
284-
try {
285-
CodeSource src = JavaVersionDetector.class.getProtectionDomain().getCodeSource();
286-
if (src != null) {
287-
288-
String className = JavaVersionDetector.class.getName();
289-
String classFileName = JavaVersionDetector.class.getSimpleName() + ".class";
290-
String classFilePackage = JavaVersionDetector.class.getPackage().getName().replace('.', '/');
291-
292-
URL classURL = JavaVersionDetector.class.getResource(classFileName);
293-
294-
if (classURL != null) {
295-
try (InputStream inputStream = classURL.openConnection().getInputStream()) {
296-
297-
Path rootClassPath = Files.createTempDirectory("JavaVersionDetector");
298-
299-
Files.copy(
300-
inputStream,
301-
Files.createDirectories(rootClassPath.resolve(classFilePackage))
302-
.resolve(classFileName));
303-
304-
Process process = new ProcessBuilder(
305-
javaVm.getAbsolutePath(),
306-
VM_CLASSPATH_OPTION, rootClassPath.toAbsolutePath().toString(),
307-
className)
308-
.start();
309-
310-
try (Scanner scanner = new Scanner(process.getErrorStream())) {
311-
scanner.useDelimiter("\\A")
312-
.forEachRemaining(e -> javaVersions.add(e));
313-
}
314-
315-
}
316-
}
317-
}
318-
} catch (Exception e) {
319-
LOGGER.log(WARNING, "javaVmVersion", "Caught exception when getting VM version", e);
320-
}
321-
322-
if (!javaVersions.isEmpty()) {
323-
return javaVersions.get(0);
324-
}
325-
326-
JavaVersion version = javaVmVersion(javaVm);
327-
328-
if (version != null) {
329-
return version.toString();
330-
}
331-
332-
return null;
333-
}
280+
public static Version getJavaVersion(String javaHome) {
281+
Version javaVersion = null;
282+
if(javaHome != null) {
283+
try (BufferedReader bufferedReader
284+
= new BufferedReader(new FileReader(new File(javaHome, "release")));) { // NOI18N
285+
String implementorLine = null;
286+
String javaVersionLine = null;
287+
String line;
288+
while ((line = bufferedReader.readLine()) != null) {
289+
if (line.startsWith("JAVA_VERSION=")) { // NOI18N
290+
javaVersionLine = line;
291+
} else if (line.startsWith("IMPLEMENTOR=")) { // NOI18N
292+
implementorLine = line;
293+
}
294+
}
295+
if (javaVersionLine != null) {
296+
String version = javaVersionLine.substring(javaVersionLine.indexOf("\"") + 1, javaVersionLine.lastIndexOf("\"")); // NOI18N
297+
String vendor = implementorLine != null ? implementorLine.substring(implementorLine.indexOf("\"") + 1, implementorLine.lastIndexOf("\"")) : null; // NOI18N
298+
javaVersion = JDK.getVersion(version, vendor);
299+
}
300+
} catch (IOException ex) {
301+
LOGGER.log(WARNING, "javaVmVersion", "Caught exception when getting VM version", ex);
302+
}
303+
}
304+
return javaVersion;
305+
}
334306

335307
/**
336308
* Build Java VM executable full path from Java Home directory.

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/sdk/utils/JavaVersionDetector.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/ui/wizards/NewPayaraRuntimeWizardFragment.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void modifyText(ModifyEvent e) {
153153
validate(handle);
154154
}
155155
});
156-
156+
157157
label = new Label(group, SWT.NONE);
158158
label.setText(GlassfishWizardResources.payaraLocation);
159159
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END);
@@ -163,6 +163,9 @@ public void modifyText(ModifyEvent e) {
163163
serverLocation = new Text(group, SWT.BORDER);
164164
data = new GridData(GridData.FILL_HORIZONTAL);
165165
serverLocation.setLayoutData(data);
166+
if(getServerRuntime().getLocation() != null) {
167+
serverLocation.setText(getServerRuntime().getLocation().toPortableString());
168+
}
166169
serverLocation.addModifyListener(new ModifyListener() {
167170
@Override
168171
public void modifyText(ModifyEvent e) {
@@ -183,9 +186,6 @@ public void widgetSelected(SelectionEvent se) {
183186
serverLocation.setText(selectedDirectory);
184187
getServerRuntime().setLocation(new Path(serverLocation.getText().trim()));
185188
}
186-
// JdkFilter jdkFilter = payaraRuntime.getVersion() == null ? null
187-
// : new JdkFilter(payaraRuntime.getJavaVersionConstraint());
188-
// updateJREs(jdkFilter);
189189
}
190190
});
191191

@@ -201,9 +201,9 @@ public void widgetSelected(SelectionEvent se) {
201201

202202
jrecombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
203203
jrecombo.setItems(jreNames);
204+
setDefaultJREComboText();
204205
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
205206
jrecombo.setLayoutData(data);
206-
207207
jrecombo.addSelectionListener(new SelectionListener() {
208208
@Override
209209
public void widgetSelected(SelectionEvent e) {
@@ -239,6 +239,25 @@ public void widgetSelected(SelectionEvent e) {
239239
}
240240
});
241241
}
242+
243+
private void setDefaultJREComboText() {
244+
PayaraRuntime payaraRuntime = (PayaraRuntime) getServerRuntime().loadAdapter(PayaraRuntime.class, null);
245+
if (payaraRuntime != null && payaraRuntime.getVMInstall() != null) {
246+
String selectedJRE = payaraRuntime.getVMInstall().getName();
247+
248+
int defaultIndex = -1;
249+
for (int i = 0; i < jreNames.length; i++) {
250+
if (jreNames[i].equals(selectedJRE)) {
251+
defaultIndex = i;
252+
break;
253+
}
254+
}
255+
256+
if (defaultIndex != -1) {
257+
jrecombo.select(defaultIndex);
258+
}
259+
}
260+
}
242261

243262
protected void updateJREs(JdkFilter jdkFilter) {
244263
// get all installed JVMs

bundles/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>fish.payara.eclipse</groupId>
1111
<artifactId>fish.payara.eclipse.root</artifactId>
12-
<version>2.2.0</version>
12+
<version>2.3.0</version>
1313
</parent>
1414

1515
<modules>

features/fish.payara.eclipse.tools.micro.feature/feature.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<feature
33
id="fish.payara.eclipse.tools.micro.feature"
44
label="%featureName"
5-
version="2.2.0"
5+
version="2.3.0"
66
provider-name="%providerName">
77

88
<description url="https://www.payara.fish/products/ecosystem-catalog/">

0 commit comments

Comments
 (0)