Skip to content

Commit cc260c3

Browse files
committed
Merge pull request #562 from GoogleCloudPlatform:update-to-jetty-12.1.15
PiperOrigin-RevId: 1019780961 Change-Id: I4122136988d819fde3b1467e9d5cd7bea0e0c0f8
2 parents 40c9f83 + 954713b commit cc260c3

4 files changed

Lines changed: 254 additions & 86 deletions

File tree

‎.github/workflows/maven.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5959

6060
- name: Set up JDK
61-
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
61+
uses: actions/setup-java@77dd5b2ce225ea11469928ac317850245a74ae78 # v6.2.0
6262
with:
6363
distribution: ${{ matrix.jdk }}
6464
java-version: ${{ matrix.java }}

‎api_dev/src/main/java/com/google/appengine/tools/info/Jetty121EE11Sdk.java‎

Lines changed: 124 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import java.util.ArrayList;
2424
import java.util.Arrays;
2525
import java.util.Collections;
26+
import java.util.LinkedHashSet;
2627
import java.util.List;
28+
import java.util.Set;
2729

2830
/**
2931
* Implementation of the SDK abstraction by the existing GAE SDK distribution, which is composed of
@@ -87,7 +89,7 @@ public String getQuickStartClasspath() {
8789
new File(getSdkRoot(), "lib/tools/quickstart/quickstartgenerator-jetty121-ee11.jar");
8890

8991
File jettyDir = new File(getSdkRoot(), JETTY121_HOME_LIB_PATH);
90-
for (File f : jettyDir.listFiles()) {
92+
for (File f : listFiles(jettyDir)) {
9193
if (!f.isDirectory()
9294
&& !(f.getName().contains("cdi-")
9395
|| f.getName().contains("-alpn-")
@@ -110,32 +112,71 @@ public String getQuickStartClasspath() {
110112
}
111113
// Add the API jar, in case it is needed (b/120480580).
112114
list.add(getSdkRoot() + "/lib/impl/appengine-api.jar");
113-
list.add(new File(jettyDir, "jakarta.servlet-api-6.1.0.jar").getAbsolutePath()); // ee11 apis
114115

115-
// Note: Do not put the Apache JSP files in the classpath. If needed, they should be part of
116-
// the application itself under WEB-INF/lib.
117-
for (String subdir : new String[] {"ee11-annotations"}) {
118-
for (File f : new File(jettyDir, subdir).listFiles()) {
119-
list.add(f.getAbsolutePath());
120-
}
116+
File servletApi = new File(jettyDir, "jakarta.servlet-api-6.1.0.jar");
117+
if (!servletApi.exists()) {
118+
servletApi = new File(jettyDir, "ee11/support/jakarta.servlet.jakarta.servlet-api-6.1.0.jar");
121119
}
122-
for (String subdir : new String[] {"annotations"}) {
123-
for (File f : new File(jettyDir, subdir).listFiles()) {
124-
list.add(f.getAbsolutePath());
125-
}
120+
if (!servletApi.exists()) {
121+
servletApi = getJetty121Jar("jakarta.servlet-api-6.1");
126122
}
127-
for (String subdir : new String[] {"ee11-jaspi"}) {
128-
for (File f : new File(jettyDir, subdir).listFiles()) {
129-
list.add(f.getAbsolutePath());
123+
list.add(servletApi.getAbsolutePath()); // ee11 apis
124+
125+
File ee11Dir = new File(jettyDir, "ee11");
126+
if (ee11Dir.isDirectory()) {
127+
// Jetty 12.1.15+ layout: EE11 jars are in lib/ee11 and lib/ee11/support
128+
for (File f : listFiles(ee11Dir)) {
129+
if (!f.isDirectory()
130+
&& !(f.getName().contains("apache-jsp")
131+
|| f.getName().contains("-cdi-")
132+
|| f.getName().contains("-alpn-")
133+
|| f.getName().contains("-demo-")
134+
|| f.getName().contains("-websocket-")
135+
|| f.getName().contains("-gcloud-")
136+
|| f.getName().contains("-infinispan-")
137+
|| f.getName().contains("-hazelcast-")
138+
|| f.getName().contains("-ethereum-"))) {
139+
list.add(f.getAbsolutePath());
140+
}
141+
}
142+
File ee11SupportDir = new File(ee11Dir, "support");
143+
if (ee11SupportDir.isDirectory()) {
144+
for (File f : listFiles(ee11SupportDir)) {
145+
if (!f.isDirectory()
146+
&& (f.getName().contains("jakarta.annotation")
147+
|| f.getName().contains("jakarta.authentication"))) {
148+
list.add(f.getAbsolutePath());
149+
}
150+
}
151+
}
152+
File supportDir = new File(jettyDir, "support");
153+
if (supportDir.isDirectory()) {
154+
for (File f : listFiles(supportDir)) {
155+
if (!f.isDirectory() && (f.getName().contains("asm-") || f.getName().contains("slf4j-api"))) {
156+
list.add(f.getAbsolutePath());
157+
}
158+
}
159+
}
160+
} else {
161+
// Note: Do not put the Apache JSP files in the classpath. If needed, they should be part of
162+
// the application itself under WEB-INF/lib.
163+
for (String subdir : new String[] {"ee11-annotations", "annotations", "ee11-jaspi"}) {
164+
File sub = new File(jettyDir, subdir);
165+
if (sub.isDirectory()) {
166+
for (File f : listFiles(sub)) {
167+
list.add(f.getAbsolutePath());
168+
}
169+
}
170+
}
171+
File logDir = new File(jettyDir, "logging");
172+
if (logDir.isDirectory()) {
173+
for (File f : listFiles(logDir)) {
174+
list.add(f.getAbsolutePath());
175+
}
130176
}
131177
}
132178

133179
list.add(quickstart.getAbsolutePath());
134-
// Add Jars for logging.
135-
for (File f : new File(jettyDir, "logging").listFiles()) {
136-
list.add(f.getAbsolutePath());
137-
}
138-
139180
return Joiner.on(System.getProperty("path.separator")).join(list);
140181
}
141182

@@ -145,26 +186,40 @@ public File getResourcesDirectory() {
145186
}
146187

147188
private List<File> getImplLibFiles() {
148-
List<File> lf = getJetty121Jars("");
189+
Set<File> lf = new LinkedHashSet<>();
190+
lf.addAll(getJetty121Jars(""));
149191
lf.addAll(getJetty121JspJars());
150192
lf.addAll(getJetty121Jars("logging"));
151193
// We also want the devserver to be able to handle annotated servlet, via ASM:
152194
lf.addAll(getJetty121Jars("annotations"));
153195
lf.addAll(getJetty121Jars("ee11-annotations"));
154196
lf.addAll(getJetty121Jars("ee11-apache-jsp"));
155197
lf.addAll(getJetty121Jars("ee11-glassfish-jstl"));
198+
// Jetty 12.1.15+ layout support:
199+
lf.addAll(getJetty121Jars("ee11"));
200+
lf.addAll(getJetty121Jars("ee11/support"));
201+
lf.addAll(getJetty121Jars("support"));
156202

157203
lf.addAll(getLibs(sdkRoot, "impl"));
158204
lf.add(new File(sdkRoot, "lib/impl/jetty121/appengine-local-runtime-jetty121-ee11.jar"));
159205
// The ee11-glassfish-jstl directory contains Oracle JSTL, but we need Apache JSTL for the
160206
// local dev console JSPs. Thus, we include the Apache JSTL jar from ee10-glassfish-jstl.
161207
// See https://github.com/eclipse-ee4j/wasp/issues/77 for more details, but we are facing it.
162208
File jettyHomeLib = new File(sdkRoot, JETTY121_HOME_LIB_PATH);
163-
lf.add(
209+
File apacheJstl =
164210
new File(
165211
jettyHomeLib,
166-
"ee10-glassfish-jstl/org.glassfish.web.jakarta.servlet.jsp.jstl-3.0.1.jar"));
167-
return Collections.unmodifiableList(lf);
212+
"ee10-glassfish-jstl/org.glassfish.web.jakarta.servlet.jsp.jstl-3.0.1.jar");
213+
if (!apacheJstl.exists()) {
214+
apacheJstl =
215+
new File(
216+
jettyHomeLib,
217+
"ee10/support/org.glassfish.web.jakarta.servlet.jsp.jstl-3.0.1.jar");
218+
}
219+
if (apacheJstl.exists()) {
220+
lf.add(apacheJstl);
221+
}
222+
return Collections.unmodifiableList(new ArrayList<>(lf));
168223
}
169224

170225
/**
@@ -176,32 +231,17 @@ public List<URL> getSharedJspLibs() {
176231
return Collections.unmodifiableList(toURLs(getSharedJspLibFiles()));
177232
}
178233

179-
@Override
180-
protected File getJetty121Jar(String fileNamePattern) {
181-
File path = new File(sdkRoot, JETTY121_HOME_LIB_PATH + File.separator);
182-
183-
if (!path.exists()) {
184-
throw new IllegalArgumentException("Unable to find " + path.getAbsolutePath());
185-
}
186-
for (File f : listFiles(path)) {
187-
if (f.getName().endsWith(".jar")) {
188-
// All but CDI jar. All the tests are still passing without CDI that should not be exposed
189-
// in our runtime (private Jetty dependency we do not want to expose to the customer).
190-
if (f.getName().contains(fileNamePattern)) {
191-
return f;
192-
}
193-
}
194-
}
195-
throw new IllegalArgumentException(
196-
"Unable to find " + fileNamePattern + " at " + path.getAbsolutePath());
197-
}
198-
199234
@Override
200235
protected List<File> getJetty121Jars(String subDir) {
201-
File path = new File(sdkRoot, JETTY121_HOME_LIB_PATH + File.separator + subDir);
236+
File path = subDir.isEmpty()
237+
? new File(sdkRoot, JETTY121_HOME_LIB_PATH)
238+
: new File(sdkRoot, JETTY121_HOME_LIB_PATH + File.separator + subDir);
202239

203240
if (!path.exists()) {
204-
throw new IllegalArgumentException("Unable to find " + path.getAbsolutePath());
241+
if (subDir.isEmpty()) {
242+
throw new IllegalArgumentException("Unable to find " + path.getAbsolutePath());
243+
}
244+
return Collections.emptyList();
205245
}
206246
List<File> jars = new ArrayList<>();
207247
for (File f : listFiles(path)) {
@@ -227,6 +267,7 @@ protected List<File> getJetty121Jars(String subDir) {
227267
|| f.getName().contains("ee9") // we want ee11 only. jakarta apis should be in shared
228268
|| f.getName().contains("ee10") // we want ee11 only. jakarta apis should be in shared
229269
|| f.getName().contains("jetty-jakarta-servlet-api") // no old jakarta APIs
270+
|| (subDir.equals("ee11") && f.getName().contains("apache-jsp")) // apache-jsp comes from nolog in ee11-apache-jsp
230271
)) {
231272
jars.add(f);
232273
}
@@ -237,25 +278,55 @@ protected List<File> getJetty121Jars(String subDir) {
237278

238279
@Override
239280
List<File> getJetty121JspJars() {
240-
241-
List<File> lf = getJetty121Jars("ee11-apache-jsp");
242-
lf.addAll(getJetty121Jars("ee11-glassfish-jstl"));
281+
Set<File> lf = new LinkedHashSet<>();
282+
File ee11Dir = new File(sdkRoot, JETTY121_HOME_LIB_PATH + File.separator + "ee11");
283+
if (ee11Dir.isDirectory()) {
284+
for (File f : listFiles(ee11Dir)) {
285+
if (f.getName().endsWith(".jar") && f.getName().contains("glassfish-jstl")) {
286+
lf.add(f);
287+
}
288+
}
289+
File supportDir = new File(ee11Dir, "support");
290+
if (supportDir.isDirectory()) {
291+
for (File f : listFiles(supportDir)) {
292+
if (f.getName().endsWith(".jar")
293+
&& (f.getName().contains("apache-el")
294+
|| f.getName().contains("apache-jsp")
295+
|| f.getName().contains("jstl")
296+
|| f.getName().contains("jsp-api")
297+
|| f.getName().contains("jakarta.el")
298+
|| f.getName().contains("wasp"))) {
299+
lf.add(f);
300+
}
301+
}
302+
}
303+
lf.addAll(getJetty121Jars("ee11-apache-jsp"));
304+
} else {
305+
lf.addAll(getJetty121Jars("ee11-apache-jsp"));
306+
lf.addAll(getJetty121Jars("ee11-glassfish-jstl"));
307+
}
243308
lf.add(getJetty121Jar("ee11-servlet-"));
244309
lf.add(
245310
new File(
246311
sdkRoot,
247312
"lib/shared/jetty12/appengine-local-runtime-shared.jar")); // contains DTD and XSD
248313
// schemas
249-
return lf;
314+
return new ArrayList<>(lf);
250315
}
251316

252317
List<File> getJetty121SharedLibFiles() {
253-
List<File> sharedLibs;
254-
sharedLibs = new ArrayList<>();
318+
List<File> sharedLibs = new ArrayList<>();
255319
sharedLibs.add(new File(sdkRoot, "lib/shared/jetty12/appengine-local-runtime-shared.jar"));
256320
File jettyHomeLib = new File(sdkRoot, JETTY121_HOME_LIB_PATH);
257321

258-
sharedLibs.add(new File(jettyHomeLib, "jakarta.servlet-api-6.1.0.jar")); // contains schemas.
322+
File servletApi = new File(jettyHomeLib, "jakarta.servlet-api-6.1.0.jar");
323+
if (!servletApi.exists()) {
324+
servletApi = new File(jettyHomeLib, "ee11/support/jakarta.servlet.jakarta.servlet-api-6.1.0.jar");
325+
}
326+
if (!servletApi.exists()) {
327+
servletApi = getJetty121Jar("jakarta.servlet-api-6.1");
328+
}
329+
sharedLibs.add(servletApi); // contains schemas.
259330
// We want to match this file: "jetty-util-9.3.8.v20160314.jar"
260331
// but without hardcoding the Jetty version which is changing from time to time.
261332
class JettyVersionFilter implements FileFilter {

0 commit comments

Comments
 (0)