Skip to content

Commit cd74998

Browse files
authored
Merge pull request #84 from jGauravGupta/FISH-9444
FISH-9444 Payara Eclipse Tools with Payara 7 support
2 parents 53280d1 + 6b1e3f7 commit cd74998

15 files changed

Lines changed: 184 additions & 60 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@
4646
/features/fish.payara.eclipse.tools.server.feature/.polyglot.build.properties
4747
/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.1.0.20221015-0744.xml
4848
/.metadata/
49+
/.idea

bundles/fish.payara.eclipse.tools.micro/src/fish/payara/eclipse/tools/micro/MavenBuildTool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2020-2022 Payara Foundation
2+
* Copyright (c) 2020-2024 Payara Foundation
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v2.0
@@ -89,7 +89,7 @@ public List<String> getStartCommand(String contextPath, String microVersion, Str
8989
} else {
9090
commands.add("package");
9191
}
92-
commands.add(PLUGIN + "start");
92+
commands.add(PLUGIN + "dev");
9393
if (contextPath != null && !contextPath.trim().isEmpty()) {
9494
commands.add("-DcontextRoot=" + contextPath);
9595
}

bundles/fish.payara.eclipse.tools.micro/src/fish/payara/eclipse/tools/micro/Messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ runtimeName=Runtime Name
44
emptyRuntimeName=Runtime name is required!
55
duplicateRuntimeName=Runtime name {0} is already used!
66
runtimeIdentified=Found Payara Server version {0}.
7-
unsupportedVersion=Only Payara 6, 5, 4 and 3.1 are supported
7+
unsupportedVersion=Only Payara 7, 6, 5, 4 and 3.1 are supported
88
versionsNotMatching=The versions of local and remote server do not match.
99
runtimeNotValid=There is no valid Payara runtime in specified directory.
1010

bundles/fish.payara.eclipse.tools.micro/src/fish/payara/eclipse/tools/micro/ui/MicroProjectTab.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2020-2022 Payara Foundation
2+
* Copyright (c) 2020-2024 Payara Foundation
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v2.0
@@ -9,7 +9,6 @@
99
*/
1010
package fish.payara.eclipse.tools.micro.ui;
1111

12-
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_MICRO_VERSIONS;
1312
import static fish.payara.eclipse.tools.micro.MicroConstants.ATTR_BUILD_ARTIFACT;
1413
import static fish.payara.eclipse.tools.micro.MicroConstants.ATTR_CONTEXT_PATH;
1514
import static fish.payara.eclipse.tools.micro.MicroConstants.ATTR_DEBUG_PORT;
@@ -35,6 +34,7 @@
3534
import java.util.List;
3635
import java.util.Map;
3736

37+
import fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard;
3838
import org.eclipse.core.resources.IProject;
3939
import org.eclipse.core.resources.IResource;
4040
import org.eclipse.core.resources.IWorkspace;
@@ -82,7 +82,7 @@ public void createControl(Composite parent) {
8282

8383
group = SWTFactory.createGroup(mainComposite, Messages.microVersionComponentLabel, 1, 1,
8484
GridData.FILL_HORIZONTAL);
85-
microVersionText = SWTFactory.createCombo(group, SWT.READ_ONLY, 1, ARCHETYPE_MICRO_VERSIONS);
85+
microVersionText = SWTFactory.createCombo(group, SWT.READ_ONLY, 1, MicroProjectWizard.getVersions().toArray(new String[0]));
8686
microVersionText.addModifyListener(getDefaultListener());
8787

8888
group = SWTFactory.createGroup(mainComposite, Messages.buildArtifactComponentLabel, 1, 1,

bundles/fish.payara.eclipse.tools.micro/src/fish/payara/eclipse/tools/micro/ui/wizards/MicroProjectWizard.java

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2020-2022 Payara Foundation
2+
* Copyright (c) 2020-2024 Payara Foundation
33
* Copyright (c) 2008-2010 Sonatype, Inc.
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v2.0
@@ -13,6 +13,12 @@
1313
import static java.lang.Boolean.TRUE;
1414
import static java.util.stream.Collectors.toList;
1515

16+
import java.io.BufferedReader;
17+
import java.io.InputStreamReader;
18+
import java.io.StringReader;
19+
import java.net.HttpURLConnection;
20+
import java.net.URL;
21+
import java.net.UnknownHostException;
1622
import java.util.ArrayList;
1723
import java.util.Collection;
1824
import java.util.HashMap;
@@ -53,6 +59,12 @@
5359
import org.eclipse.ui.INewWizard;
5460
import org.eclipse.ui.IWorkbench;
5561
import org.eclipse.ui.IWorkingSet;
62+
import org.w3c.dom.Document;
63+
import org.w3c.dom.NodeList;
64+
import org.xml.sax.InputSource;
65+
66+
import javax.xml.parsers.DocumentBuilder;
67+
import javax.xml.parsers.DocumentBuilderFactory;
5668

5769
public class MicroProjectWizard extends Wizard implements INewWizard {
5870

@@ -75,24 +87,15 @@ public MicroProjectWizard() {
7587
private static final String NAME = "\\[name\\]"; //$NON-NLS-1$
7688
private static final String PROJECT_NAME_REGEX = "\\$\\{[^\\}]++\\}"; //$NON-NLS-1$
7789

78-
private static final String ARCHETYPE_GROUP_ID = "fish.payara.maven.archetypes"; //$NON-NLS-1$
79-
private static final String ARCHETYPE_ARTIFACT_ID = "payara-micro-maven-archetype"; //$NON-NLS-1$
90+
public static final String ARCHETYPE_GROUP_ID = "fish.payara.maven.archetypes"; //$NON-NLS-1$
91+
public static final String ARCHETYPE_ARTIFACT_ID = "payara-micro-maven-archetype"; //$NON-NLS-1$
8092
public static final String ARCHETYPE_VERSION_5X = "1.4.0"; //$NON-NLS-1$
81-
public static final String ARCHETYPE_VERSION_6X = "2.0"; //$NON-NLS-1$
93+
public static final String STARTER_ARCHETYPE_GROUP_ID = "fish.payara.starter";
94+
public static final String STARTER_ARCHETYPE_ARTIFACT_ID = "payara-starter-archetype";
95+
public static final String ARCHETYPE_VERSION_6X = "1.0-beta9"; //$NON-NLS-1$
8296
private static final String ARCHETYPE_JDK_VERSION = "jdkVersion"; //$NON-NLS-1$
8397
private static final String ARCHETYPE_JDK_VERSION_DEFAULT_VALUE = "1.8"; //$NON-NLS-1$
8498
public static final String ARCHETYPE_MICRO_VERSION = "payaraMicroVersion"; //$NON-NLS-1$
85-
private static final String ARCHETYPE_MICRO_VERSION_DEFAULT_VALUE = "6.2023.2"; //$NON-NLS-1$
86-
public static final String[] ARCHETYPE_MICRO_VERSIONS = new String[]{"6.2023.2", "6.2023.1", "6.2022.2", "6.2022.1",
87-
"5.2022.5", "5.2022.4", "5.2022.3",
88-
"5.2022.2", "5.2022.1", "5.2021.10",
89-
"5.2021.9", "5.2021.8", "5.2021.7",
90-
"5.2021.6", "5.2021.5", "5.2021.4",
91-
"5.2021.3", "5.2021.2", "5.2021.1",
92-
"5.2020.7", "5.2020.6", "5.2020.5",
93-
"5.2020.4", "5.2020.3", "5.2020.2",
94-
"5.201", "5.194", "5.193.1", "5.192",
95-
"5.191", "5.184", "5.183", "5.182", "5.181"}; //$NON-NLS-1$
9699
public static final String ARCHETYPE_AUTOBIND_HTTP = "autoBindHttp"; //$NON-NLS-1$
97100
private static final String ARCHETYPE_CONCURRENT_API = "addConcurrentApi"; //$NON-NLS-1$
98101
private static final String ARCHETYPE_RESOURCE_API = "addResourceApi"; //$NON-NLS-1$
@@ -105,6 +108,57 @@ public MicroProjectWizard() {
105108
private static final String ARCHETYPE_DEPLOY_WAR = "deployWar"; //$NON-NLS-1$
106109
private static final String EMPTY = ""; //$NON-NLS-1$
107110

111+
112+
public static final String DEFAULT_REPOSITORY_URL = "https://repo1.maven.org/maven2/"; // NOI18N
113+
114+
private static final String METADATA_URL = "fish/payara/extras/payara-micro/maven-metadata.xml"; // NOI18N
115+
116+
private static final List<String> versions = new ArrayList<>();
117+
public static List<String> getVersions() {
118+
if (versions.isEmpty()) {
119+
try {
120+
// Construct the full URL
121+
String urlString = DEFAULT_REPOSITORY_URL + METADATA_URL;
122+
URL url = new URL(urlString);
123+
124+
// Open connection
125+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
126+
connection.setRequestMethod("GET");
127+
128+
// Read the response
129+
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
130+
StringBuilder xmlResponse = new StringBuilder();
131+
String line;
132+
while ((line = in.readLine()) != null) {
133+
xmlResponse.append(line);
134+
}
135+
in.close();
136+
137+
// Parse the XML response
138+
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
139+
DocumentBuilder builder = factory.newDocumentBuilder();
140+
Document doc = builder.parse(new InputSource(new StringReader(xmlResponse.toString())));
141+
142+
String latest = doc.getElementsByTagName("latest").item(0).getTextContent();
143+
// Extract versions
144+
NodeList versionNodes = doc.getElementsByTagName("version");
145+
for (int i = versionNodes.getLength() - 1; i >= 0; i--) {
146+
String version = versionNodes.item(i).getTextContent();
147+
if ((version.contains("Alpha") || version.contains("Beta") || version.contains("SNAPSHOT")) // NOI18N
148+
&& !version.equals(latest)) {
149+
continue;
150+
};
151+
versions.add(version);
152+
}
153+
154+
} catch (Exception e) {
155+
e.printStackTrace();
156+
}
157+
158+
}
159+
return versions;
160+
}
161+
108162
@Override
109163
public void init(IWorkbench workbench, IStructuredSelection selection) {
110164
this.selection = selection;
@@ -134,12 +188,12 @@ public void createPageControls(Composite pageContainer) {
134188

135189
private Archetype getArchetype() {
136190
Archetype archetype = new Archetype();
137-
archetype.setGroupId(ARCHETYPE_GROUP_ID);
138-
archetype.setArtifactId(ARCHETYPE_ARTIFACT_ID);
191+
archetype.setGroupId(STARTER_ARCHETYPE_GROUP_ID);
192+
archetype.setArtifactId(STARTER_ARCHETYPE_ARTIFACT_ID);
139193
archetype.setVersion(ARCHETYPE_VERSION_6X);
140194
Properties properties = new Properties();
141195
properties.put(ARCHETYPE_JDK_VERSION, ARCHETYPE_JDK_VERSION_DEFAULT_VALUE);
142-
properties.put(ARCHETYPE_MICRO_VERSION, ARCHETYPE_MICRO_VERSION_DEFAULT_VALUE);
196+
properties.put(ARCHETYPE_MICRO_VERSION, getVersions().get(0));
143197
properties.put(ARCHETYPE_AUTOBIND_HTTP, TRUE.toString());
144198
properties.put(ARCHETYPE_CONCURRENT_API, FALSE.toString());
145199
properties.put(ARCHETYPE_RESOURCE_API, FALSE.toString());

bundles/fish.payara.eclipse.tools.micro/src/fish/payara/eclipse/tools/micro/ui/wizards/MicroSettingsWizardPage.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2020-2022 Payara Foundation
2+
* Copyright (c) 2020-2024 Payara Foundation
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v2.0
@@ -12,15 +12,17 @@
1212
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_AUTOBIND_HTTP;
1313
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_CONTEXT_ROOT;
1414
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_MICRO_VERSION;
15-
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_MICRO_VERSIONS;
1615
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_VERSION_5X;
1716
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_VERSION_6X;
17+
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_GROUP_ID;
18+
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.ARCHETYPE_ARTIFACT_ID;
19+
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.STARTER_ARCHETYPE_GROUP_ID;
20+
import static fish.payara.eclipse.tools.micro.ui.wizards.MicroProjectWizard.STARTER_ARCHETYPE_ARTIFACT_ID;
1821
import static java.nio.charset.StandardCharsets.UTF_8;
1922

2023
import java.io.UnsupportedEncodingException;
2124
import java.net.URLEncoder;
2225
import java.util.Map;
23-
import java.util.Properties;
2426
import java.util.stream.Collectors;
2527

2628
import org.apache.maven.archetype.catalog.Archetype;
@@ -76,7 +78,7 @@ private void createUI(Composite parent) {
7678
microVersionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
7779
microVersionCombo.setData("name", ARCHETYPE_MICRO_VERSION); //$NON-NLS-1$
7880
microVersionCombo.addModifyListener(e -> validate());
79-
microVersionCombo.setItems(ARCHETYPE_MICRO_VERSIONS);
81+
microVersionCombo.setItems(MicroProjectWizard.getVersions().toArray(new String[0]));
8082

8183
Label autobindLabel = new Label(parent, SWT.NONE);
8284
autobindLabel.setText(Messages.autobindComponentLabel);
@@ -129,19 +131,25 @@ private String validateInput() {
129131
}
130132

131133
public Archetype getArchetype() {
132-
String[] versionToken = microVersionCombo.getText().trim().split("\\.");
133-
archetype.setVersion(versionToken.length > 1 && Integer.parseInt(versionToken[0]) < 6 ? ARCHETYPE_VERSION_5X : ARCHETYPE_VERSION_6X);
134+
String[] versionToken = microVersionCombo.getText().trim().split("\\.");
135+
if (versionToken.length > 1 && Integer.parseInt(versionToken[0]) < 6) {
136+
archetype.setGroupId(ARCHETYPE_GROUP_ID);
137+
archetype.setArtifactId(ARCHETYPE_ARTIFACT_ID);
138+
archetype.setVersion(ARCHETYPE_VERSION_5X);
139+
} else {
140+
archetype.setGroupId(STARTER_ARCHETYPE_GROUP_ID);
141+
archetype.setArtifactId(STARTER_ARCHETYPE_ARTIFACT_ID);
142+
archetype.setVersion(ARCHETYPE_VERSION_6X);
143+
}
144+
134145
return archetype;
135146
}
136147

137148
public Map<String, String> getProperties() {
138-
Map<String, String> properties = archetype.getProperties()
139-
.entrySet().stream().collect(
140-
Collectors.toMap(
141-
e -> e.getKey().toString(),
142-
e -> e.getValue().toString()
143-
)
144-
);
149+
Map<String, String> properties = archetype.getProperties()
150+
.entrySet()
151+
.stream()
152+
.collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
145153
String contextRoot = contextPathCombo.getText().trim();
146154
try {
147155
contextRoot = contextRoot.startsWith("/") ? '/' + URLEncoder.encode(contextRoot.substring(1), UTF_8.name())

bundles/fish.payara.eclipse.tools.server/plugin.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ runtimeTypeVendor=Oracle Corporation
2727
runtimeTypeGlassFishVendor=Payara
2828

2929
runtimeTypeNameglassfish=Payara
30-
runtimeTypeDescriptionglassfish=Supports Payara 6, 5, 4 and 3.1
30+
runtimeTypeDescriptionglassfish=Supports Payara 7, 6, 5, 4 and 3.1
3131
serverTypeNameglassfish=Payara
32-
serverTypeDescriptionPayara=Supports Payara Server 6, 5 and 4. Can also be used for GlassFish.
32+
serverTypeDescriptionPayara=Supports Payara Server 7, 6, 5 and 4. Can also be used for GlassFish.
3333

3434
payara.server.runConfigurationName=Payara Server
3535
payara.micro.runConfigurationName=Payara Micro

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

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
<moduleType types="jst.web" versions="2.2, 2.3, 2.4, 2.5, 3.0, 3.1, 4.0, 5.0, 6.0, 6.1"/>
3030
<moduleType types="jst.ejb" versions="1.1, 2.0, 2.1, 3.0, 3.1, 3.2, 4.0, 4.1"/>
3131
<moduleType types="jst.connector" versions="1.0, 1.5, 1.6, 1.7, 2.0, 2.1"/>
32-
<moduleType types="jst.ear" versions="1.2, 1.3, 1.4, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0"/>
32+
<moduleType types="jst.ear" versions="1.2, 1.3, 1.4, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0"/>
3333
<moduleType types="jst.utility" versions="1.0"/>
34-
<moduleType types="jst.appclient" versions="1.2, 1.3, 1.4, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0"/>
34+
<moduleType types="jst.appclient" versions="1.2, 1.3, 1.4, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0"/>
3535
</runtimeType>
3636
</extension>
3737

@@ -88,6 +88,7 @@
8888
<runtime-component-version type="payara.runtime" version="4"/>
8989
<runtime-component-version type="payara.runtime" version="5"/>
9090
<runtime-component-version type="payara.runtime" version="6"/>
91+
<runtime-component-version type="payara.runtime" version="7"/>
9192

9293
<supported>
9394
<runtime-component id="payara.runtime" version="3.1"/>
@@ -127,7 +128,7 @@
127128
<facet id="jst.utility" version="1.0"/>
128129
<facet id="jst.webfragment" version="4.0]" />
129130
</supported>
130-
131+
131132
<supported>
132133
<runtime-component id="payara.runtime" version="6"/>
133134
<facet id="glassfish.web" version="6.0]"/>
@@ -137,9 +138,22 @@
137138
<facet id="jst.ear" version="10.0]"/>
138139
<facet id="jst.connector" version="2.1]"/>
139140
<facet id="jst.appclient" version="10.0]"/>
140-
<facet id="jst.utility" version="1.0"/>
141+
<facet id="jst.utility" version="1.0"/>
141142
<facet id="jst.webfragment" version="6.0]" />
142143
</supported>
144+
145+
<supported>
146+
<runtime-component id="payara.runtime" version="7"/>
147+
<facet id="glassfish.web" version="7.0]"/>
148+
<facet id="glassfish.ejb" version="7.0]"/>
149+
<facet id="jst.web" version="7.0]"/>
150+
<facet id="jst.ejb" version="4.0]"/>
151+
<facet id="jst.ear" version="11.0]"/>
152+
<facet id="jst.connector" version="2.1]"/>
153+
<facet id="jst.appclient" version="11.0]"/>
154+
<facet id="jst.utility" version="1.0"/>
155+
<facet id="jst.webfragment" version="7.0]" />
156+
</supported>
143157
</extension>
144158

145159
<extension point="org.eclipse.wst.common.project.facet.core.runtimes">
@@ -317,23 +331,39 @@
317331
<fixed-facet id="jst.ejb"/>
318332
</context>
319333
<facet id="glassfish.ejb" version="5.0" />
320-
</default-facets>
334+
</default-facets>
321335

322336
<default-facets>
323337
<context>
324338
<runtime-component id="payara.runtime" version="6"/>
325339
<fixed-facet id="jst.web"/>
326340
</context>
327341
<facet id="glassfish.web" version="6.0" />
328-
</default-facets>
342+
</default-facets>
329343

330344
<default-facets>
331345
<context>
332346
<runtime-component id="payara.runtime" version="6"/>
333347
<fixed-facet id="jst.ejb"/>
334348
</context>
335349
<facet id="glassfish.ejb" version="6.0" />
336-
</default-facets>
350+
</default-facets>
351+
352+
<default-facets>
353+
<context>
354+
<runtime-component id="payara.runtime" version="7"/>
355+
<fixed-facet id="jst.web"/>
356+
</context>
357+
<facet id="glassfish.web" version="7.0" />
358+
</default-facets>
359+
360+
<default-facets>
361+
<context>
362+
<runtime-component id="payara.runtime" version="7"/>
363+
<fixed-facet id="jst.ejb"/>
364+
</context>
365+
<facet id="glassfish.ejb" version="7.0" />
366+
</default-facets>
337367
</extension>
338368

339369
<extension point="org.eclipse.wst.common.project.facet.core.runtimeBridges">

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/Messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ runtimeName=Runtime Name
44
emptyRuntimeName=Runtime name is required!
55
duplicateRuntimeName=Runtime name {0} is already used!
66
runtimeIdentified=Found Payara Server version {0}.
7-
unsupportedVersion=Only Payara 6, 5, 4 and 3.1 are supported
7+
unsupportedVersion=Only Payara 7, 6, 5, 4 and 3.1 are supported
88
versionsNotMatching=The versions of local and remote server do not match.
99
runtimeNotValid=There is no valid Payara runtime in specified directory.
1010

0 commit comments

Comments
 (0)