From 9f9868b754bdd6ac9dc523ace9ae8c20735c6cb5 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 10 Mar 2023 00:34:31 +1100 Subject: [PATCH] Issue #9463 NPE in ee10 maven plugin startup (#9475) * Issue #9463 NPE in ee10 maven plugin startup --- .../invoker.properties | 2 + .../src/it/jetty-combinedresource-it/pom.xml | 113 ++++++++++++++++++ .../postbuild.groovy | 22 ++++ .../public/blah.html | 1 + .../src/config/jetty.xml | 40 +++++++ .../src/main/webapp/WEB-INF/web.xml | 14 +++ .../src/main/webapp/index.html | 1 + .../plugin/AbstractUnassembledWebAppMojo.java | 8 +- .../invoker.properties | 2 + .../src/it/jetty-combinedresource-it/pom.xml | 113 ++++++++++++++++++ .../postbuild.groovy | 22 ++++ .../public/blah.html | 1 + .../src/config/jetty.xml | 40 +++++++ .../src/main/webapp/WEB-INF/web.xml | 14 +++ .../src/main/webapp/index.html | 1 + .../plugin/AbstractUnassembledWebAppMojo.java | 3 +- 16 files changed, 392 insertions(+), 5 deletions(-) create mode 100644 jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties create mode 100644 jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/pom.xml create mode 100644 jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy create mode 100644 jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html create mode 100644 jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml create mode 100644 jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml create mode 100644 jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html create mode 100644 jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties create mode 100644 jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/pom.xml create mode 100644 jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy create mode 100644 jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html create mode 100644 jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml create mode 100644 jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml create mode 100644 jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties new file mode 100644 index 00000000000..816c3f38def --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = verify -V -e +#test-compile failsafe:integration-test \ No newline at end of file diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/pom.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/pom.xml new file mode 100644 index 00000000000..cc772b30e8c --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + + org.eclipse.jetty.ee10.its + it-parent-pom + 0.0.1-SNAPSHOT + + + org.eclipse.jetty.ee10.its.jetty-combinedresource-it + jetty-simple-project + 0.0.1-SNAPSHOT + pom + + EE10 :: Webapp with multiple base resources + + + ${project.build.directory}/jetty-combinedresource-port.txt + + + + + org.eclipse.jetty.ee10 + jetty-ee10-maven-plugin + tests + test-jar + test + + + org.eclipse.jetty + jetty-client + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.awaitility + awaitility + test + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${jetty.port.file} + ${project.groupId}:${project.artifactId} + BLAH + /blah.html + + + org.eclipse.jetty.ee10:jetty-ee10-maven-plugin + + + **/*TestGetContent* + + + + + integration-test + + integration-test + + + + verify + + verify + + + + + + org.eclipse.jetty.ee10 + jetty-ee10-maven-plugin + + + start-jetty + test-compile + + start + + + + pom + + + + ${project.basedir}/public + ${project.basedir}/src/main/webapp + + + + ${jetty.port.file} + + + ${basedir}/src/config/jetty.xml + + + + + + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy new file mode 100644 index 00000000000..f9182cc833d --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( 'Started Server' ) +assert buildLog.text.contains( 'Running org.eclipse.jetty.ee10.maven.plugin.it.IntegrationTestGetContent') +assert buildLog.text.contains( 'contentCheck') diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html new file mode 100644 index 00000000000..e4e860f38ac --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html @@ -0,0 +1 @@ +BLAH diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml new file mode 100644 index 00000000000..445b5961914 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml @@ -0,0 +1,40 @@ + + + + + + https + + 32768 + 8192 + 8192 + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + 30000 + + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..7a8e003f946 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,14 @@ + + + + test + + + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html new file mode 100644 index 00000000000..593ac2e6079 --- /dev/null +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html @@ -0,0 +1 @@ +JJJJJ diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java index be7541ea224..c292818f76c 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractUnassembledWebAppMojo.java @@ -147,12 +147,12 @@ public abstract class AbstractUnassembledWebAppMojo extends AbstractWebAppMojo //On every subsequent re-run set it back to the original base dir before //we might have applied any war overlays onto it - webApp.setBaseResource(originalBaseResource); - - if (webApp.getWar() == null) - webApp.setWar(originalBaseResource.getURI().toURL().toExternalForm()); + //TODO the war does not need to be set, _except_ that QuickStartConfiguration checks for non null + if (webApp.getWar() == null) + webApp.setWar(originalBaseResource.toString()); + if (classesDirectory != null) webApp.setClasses(classesDirectory); diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties new file mode 100644 index 00000000000..816c3f38def --- /dev/null +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = verify -V -e +#test-compile failsafe:integration-test \ No newline at end of file diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/pom.xml b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/pom.xml new file mode 100644 index 00000000000..7022e1f74a9 --- /dev/null +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + + org.eclipse.jetty.ee9.its + it-parent-pom + 0.0.1-SNAPSHOT + + + org.eclipse.jetty.ee9.its.jetty-combinedresource-it + jetty-simple-project + 0.0.1-SNAPSHOT + pom + + EE9 :: Webapp with multiple base resources + + + ${project.build.directory}/jetty-combinedresource-port.txt + + + + + org.eclipse.jetty.ee9 + jetty-ee9-maven-plugin + tests + test-jar + test + + + org.eclipse.jetty + jetty-client + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.awaitility + awaitility + test + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${jetty.port.file} + ${project.groupId}:${project.artifactId} + BLAH + /blah.html + + + org.eclipse.jetty.ee9:jetty-ee9-maven-plugin + + + **/*TestGetContent* + + + + + integration-test + + integration-test + + + + verify + + verify + + + + + + org.eclipse.jetty.ee9 + jetty-ee9-maven-plugin + + + start-jetty + test-compile + + start + + + + pom + + + + ${project.basedir}/public + ${project.basedir}/src/main/webapp + + + + ${jetty.port.file} + + + ${basedir}/src/config/jetty.xml + + + + + + + + diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy new file mode 100644 index 00000000000..c98900fba31 --- /dev/null +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/postbuild.groovy @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( 'Started Server' ) +assert buildLog.text.contains( 'Running org.eclipse.jetty.ee9.maven.plugin.it.IntegrationTestGetContent') +assert buildLog.text.contains( 'contentCheck') diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html new file mode 100644 index 00000000000..e4e860f38ac --- /dev/null +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/public/blah.html @@ -0,0 +1 @@ +BLAH diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml new file mode 100644 index 00000000000..b2e4ff6a33e --- /dev/null +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/config/jetty.xml @@ -0,0 +1,40 @@ + + + + + + https + + 32768 + 8192 + 8192 + 1024 + + + + + + + + + + + + + + + + + + + + + + + + + 30000 + + + + diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..7a8e003f946 --- /dev/null +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,14 @@ + + + + test + + + + + diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html new file mode 100644 index 00000000000..593ac2e6079 --- /dev/null +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/it/jetty-combinedresource-it/src/main/webapp/index.html @@ -0,0 +1 @@ +JJJJJ diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/AbstractUnassembledWebAppMojo.java b/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/AbstractUnassembledWebAppMojo.java index f2f37bc326d..a749b3eb5de 100644 --- a/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/AbstractUnassembledWebAppMojo.java +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/AbstractUnassembledWebAppMojo.java @@ -142,8 +142,9 @@ public abstract class AbstractUnassembledWebAppMojo extends AbstractWebAppMojo //we might have applied any war overlays onto it webApp.setBaseResource(originalBaseResource); + //TODO the war does not need to be set, _except_ that QuickStartConfiguration checks for non null if (webApp.getWar() == null) - webApp.setWar(originalBaseResource.getURI().toURL().toExternalForm()); + webApp.setWar(originalBaseResource.toString()); if (classesDirectory != null) webApp.setClasses(classesDirectory);