diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5c5bb1be0..ee3ae9504 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,7 +22,7 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [23.0.0.12] + RUNTIME_VERSION: [24.0.0.3] java: [21, 17, 11, 8] exclude: - java: 8 @@ -67,7 +67,7 @@ jobs: # Run tests that require a minimum of Java 17 or later - name: Run tests that require a minimum of Java 17 or later if: ${{ matrix.java == '17' || matrix.java == '21'}} - run: ./mvnw -V verify --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -Ponline-its -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" + run: ./mvnw -V verify --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -Ponline-its -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*,*compile-jsp-source-17-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" # Run tests - name: Run tests run: ./mvnw -V verify --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -Ponline-its -D"invoker.streamLogsOnFailures"=true -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" @@ -80,7 +80,7 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [23.0.0.12] + RUNTIME_VERSION: [24.0.0.3] java: [21, 17, 11, 8] exclude: - java: 8 @@ -119,7 +119,7 @@ jobs: # Run tests that require a minimum of Java 17 or later - name: Run tests that require a minimum of Java 17 or later if: ${{ matrix.java == '17' || matrix.java == '21'}} - run: .\mvnw.cmd -V verify -Ponline-its --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" + run: .\mvnw.cmd -V verify -Ponline-its --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*,*compile-jsp-source-17-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" # Run tests - name: Run tests working-directory: C:/ci.maven diff --git a/liberty-maven-plugin/pom.xml b/liberty-maven-plugin/pom.xml index 3267fc772..7bd68ec5d 100644 --- a/liberty-maven-plugin/pom.xml +++ b/liberty-maven-plugin/pom.xml @@ -37,7 +37,7 @@ io.openliberty.tools liberty-ant-tasks - 1.9.14 + 1.9.15-SNAPSHOT org.apache.maven @@ -225,6 +225,7 @@ binary-scanner-it/pom.xml springboot-3-tests/pom.xml dev-container-it/pom.xml + compile-jsp-source-17-it/pom.xml @@ -266,6 +267,7 @@ binary-scanner-it/pom.xml springboot-3-tests/pom.xml dev-container-it/pom.xml + compile-jsp-source-17-it/pom.xml @@ -306,6 +308,7 @@ generate-features-it/pom.xml binary-scanner-it/pom.xml springboot-3-tests/pom.xml + compile-jsp-source-17-it/pom.xml @@ -351,6 +354,7 @@ generate-features-it/pom.xml binary-scanner-it/pom.xml springboot-3-tests/pom.xml + compile-jsp-source-17-it/pom.xml diff --git a/liberty-maven-plugin/src/it/compile-jsp-it/pom.xml b/liberty-maven-plugin/src/it/compile-jsp-it/pom.xml index 7da8c6cac..3013e844b 100644 --- a/liberty-maven-plugin/src/it/compile-jsp-it/pom.xml +++ b/liberty-maven-plugin/src/it/compile-jsp-it/pom.xml @@ -27,6 +27,10 @@ + + 1.8 + + diff --git a/liberty-maven-plugin/src/it/compile-jsp-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java b/liberty-maven-plugin/src/it/compile-jsp-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java index 6382291a8..1286ac59c 100644 --- a/liberty-maven-plugin/src/it/compile-jsp-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java +++ b/liberty-maven-plugin/src/it/compile-jsp-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java @@ -66,6 +66,17 @@ public void testXmlElements() throws Exception { Assert.assertTrue("ejbLite-3.2 found ==>", features.contains("ejbLite-3.2")); Assert.assertTrue("mongodb-2.0 found ==>", features.contains("mongodb-2.0")); Assert.assertTrue("jsp-2.3 found ==>", features.contains("jsp-2.3")); + + // parse input XML Document + String expression2 = "/server/jspEngine"; + nodes = (NodeList) xPath.compile(expression2).evaluate(inputDoc, XPathConstants.NODESET); + Assert.assertEquals("Number of elements ==>", 1, nodes.getLength()); + + if (nodes.item(0) instanceof Element) { + Element child = (Element) nodes.item(0); + String nodeValue = child.getAttribute("javaSourceLevel"); + Assert.assertTrue("Unexpected javaSourceLevel ==>"+nodeValue, nodeValue.equals("8")); + } } } } diff --git a/liberty-maven-plugin/src/it/compile-jsp-source-17-it/pom.xml b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/pom.xml new file mode 100644 index 000000000..6c51e2fea --- /dev/null +++ b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/pom.xml @@ -0,0 +1,185 @@ + + + 4.0.0 + + + io.openliberty.tools.it + tests + 1.0-SNAPSHOT + + + compile-jsp-source-17-it + war + + + + commons-logging + commons-logging + 1.0.4 + test + + + junit + junit + 4.13.1 + test + + + + + UTF-8 + UTF-8 + 17 + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.1.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + + + + maven-war-plugin + + false + + + + io.openliberty.tools + liberty-maven-plugin + @pom.version@ + true + + true + test + src/test/resources/server.xml + project + false + + + + install-liberty + package + + install-server + + + + create-liberty-server + package + + create + + + + install-artifact + package + + deploy + + + true + + + + start-liberty-server + pre-integration-test + + install-feature + start + compile-jsp + + + + true + mongodb-2.0 + ejbLite-3.2 + + true + 40 + + + + check-liberty-server + pre-integration-test + + status + + + + stop-liberty-server + post-integration-test + + stop + + + + clean-server + post-integration-test + + clean + + + false + false + false + false + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + true + once + 300 + -enableassertions + ${project.build.directory} + + **/*CompileJSPTest.java + + + + + integration-test + + integration-test + + + + verify + verify + + verify + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + diff --git a/liberty-maven-plugin/src/it/compile-jsp-source-17-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java new file mode 100644 index 000000000..048c15e13 --- /dev/null +++ b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java @@ -0,0 +1,82 @@ +package net.wasdev.wlp.maven.test.app; + +import java.awt.List; +import java.util.ArrayList; +import java.io.File; +import java.io.FileInputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathFactory; + +import org.junit.Assert; +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; +import org.w3c.dom.Element; + + +/** + * + * Web application test case + * + */ + +public class CompileJSPTest { + + public final String COMPILE_JSP_SEVER_XML = "compileJsp/servers/defaultServer/server.xml"; + + @Test + public void testServerXMLPropFileExist() throws Exception { + File f = new File(COMPILE_JSP_SEVER_XML); + Assert.assertTrue(f.getCanonicalFile() + " doesn't exist", f.exists()); + } + + @Test + public void testXmlElements() throws Exception { + File in = new File(COMPILE_JSP_SEVER_XML); + try (FileInputStream input = new FileInputStream(in);) { + + // get input XML Document + DocumentBuilderFactory inputBuilderFactory = DocumentBuilderFactory.newInstance(); + inputBuilderFactory.setIgnoringComments(true); + inputBuilderFactory.setCoalescing(true); + inputBuilderFactory.setIgnoringElementContentWhitespace(true); + inputBuilderFactory.setValidating(false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); + inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); + Document inputDoc=inputBuilder.parse(input); + + // parse input XML Document + XPath xPath = XPathFactory.newInstance().newXPath(); + String expression = "/server/featureManager/feature[text()]"; + NodeList nodes = (NodeList) xPath.compile(expression).evaluate(inputDoc, XPathConstants.NODESET); + Assert.assertEquals("Number of elements ==>", 3, nodes.getLength()); + + ArrayList features = new ArrayList(); + + for(int i = 0; i < nodes.getLength(); i++) { + features.add(nodes.item(i).getTextContent().trim()); + } + + Assert.assertTrue("ejbLite-3.2 found ==>", features.contains("ejbLite-3.2")); + Assert.assertTrue("mongodb-2.0 found ==>", features.contains("mongodb-2.0")); + Assert.assertTrue("jsp-2.3 found ==>", features.contains("jsp-2.3")); + + // parse input XML Document + String expression2 = "/server/jspEngine"; + nodes = (NodeList) xPath.compile(expression2).evaluate(inputDoc, XPathConstants.NODESET); + Assert.assertEquals("Number of elements ==>", 1, nodes.getLength()); + + if (nodes.item(0) instanceof Element) { + Element child = (Element) nodes.item(0); + String nodeValue = child.getAttribute("javaSourceLevel"); + Assert.assertTrue("Unexpected javaSourceLevel ==>"+nodeValue, nodeValue.equals("17")); + } + } + } +} diff --git a/liberty-maven-plugin/src/it/compile-jsp-source-17-it/src/test/resources/server.xml b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/src/test/resources/server.xml new file mode 100644 index 000000000..f3b493111 --- /dev/null +++ b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/src/test/resources/server.xml @@ -0,0 +1,5 @@ + + + jsp-2.3 + + diff --git a/liberty-maven-plugin/src/it/compile-jsp-source-17-it/webapp/index.jsp b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/webapp/index.jsp new file mode 100644 index 000000000..1153e9e08 --- /dev/null +++ b/liberty-maven-plugin/src/it/compile-jsp-source-17-it/webapp/index.jsp @@ -0,0 +1,10 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Maven test install artifact + + +

Successful installation of war

+

Maven test war has been successfully installed into the server.

+ + diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java index 92c523d77..1db2b1237 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/jsp/CompileJspMojo.java @@ -18,6 +18,7 @@ import java.io.File; import java.text.MessageFormat; import java.util.List; +import java.util.Properties; import java.util.Set; import java.util.TreeSet; @@ -83,15 +84,28 @@ private void doCompileJsps() throws MojoExecutionException { // don't delete temporary server dir compile.setCleanup(false); + boolean sourceSet = false; + List plugins = getProject().getBuildPlugins(); for (Plugin plugin : plugins) { if ("org.apache.maven.plugins:maven-compiler-plugin".equals(plugin.getKey())) { Object config = plugin.getConfiguration(); if (config instanceof Xpp3Dom) { Xpp3Dom dom = (Xpp3Dom) config; - Xpp3Dom val = dom.getChild("source"); - if (val != null) { - compile.setSource(val.getValue()); + Xpp3Dom child = dom.getChild("release"); + if (child != null && child.getValue() != null) { + String value = child.getValue(); + getLog().debug("compile-jsp using maven.compiler.release value: "+value+" for javaSourceLevel."); + compile.setSource(value); + sourceSet = true; + } else { + child = dom.getChild("source"); + if (child != null && child.getValue() != null) { + String value = child.getValue(); + getLog().debug("compile-jsp using maven.compiler.source value: "+value+" for javaSourceLevel."); + compile.setSource(value); + sourceSet = true; + } } } break; @@ -107,6 +121,26 @@ private void doCompileJsps() throws MojoExecutionException { } } + if (!sourceSet) { + // look for Maven properties + Properties props = getProject().getProperties(); + if (props.containsKey("maven.compiler.release")) { + String value = props.getProperty("maven.compiler.release"); + if (value != null) { + getLog().debug("compile-jsp using maven.compiler.release value: "+value+" for javaSourceLevel."); + compile.setSource(value); + sourceSet = true; + } + } else if (props.containsKey("maven.compiler.source")) { + String value = props.getProperty("maven.compiler.source"); + if (value != null) { + getLog().debug("compile-jsp using maven.compiler.source value: "+value+" for javaSourceLevel."); + compile.setSource(value); + sourceSet = true; + } + } + } + Set classpath = new TreeSet(); // first add target/classes (or whatever is configured)