diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 24d837339..f6091f18b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -58,7 +58,7 @@ jobs: - name: Set up Maven uses: stCarolas/setup-maven@v4.5 with: - maven-version: 3.9.2 + maven-version: 3.9.9 # Install dependencies - name: Install ci.ant and ci.common run: | @@ -107,7 +107,7 @@ jobs: - name: Set up Maven uses: stCarolas/setup-maven@v4.5 with: - maven-version: 3.9.2 + maven-version: 3.9.9 # Install ci.ant - name: Install ci.ant working-directory: C:/ci.ant diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 3c6fda8c6..1a60da793 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/liberty-maven-plugin/pom.xml b/liberty-maven-plugin/pom.xml index 0f642c1cc..df85db359 100644 --- a/liberty-maven-plugin/pom.xml +++ b/liberty-maven-plugin/pom.xml @@ -90,10 +90,15 @@ ci.common 1.8.37-SNAPSHOT + + org.apache.commons + commons-lang3 + 3.11 + org.twdata.maven mojo-executor - 2.3.2 + 2.4.1 xmlunit diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/pom.xml b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/pom.xml new file mode 100755 index 000000000..2500534bc --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/pom.xml @@ -0,0 +1,259 @@ + + + + 4.0.0 + + dev-it-tests + basic-dev-project-with-default-execution-id + 1.0-SNAPSHOT + war + + + ISO_8859_1 + UTF-8 + 1.8 + 1.8 + -Xms512m + LibertyProject + + 9080 + 9443 + + usr + + + + + + oss-sonatype + oss-sonatype + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + false + + + + + + + + io.openliberty.features + features-bom + RUNTIME_VERSION + pom + import + + + + + + + + io.openliberty.features + jaxrs-2.1 + esa + provided + + + io.openliberty.features + jsonp-1.1 + esa + provided + + + io.openliberty.features + cdi-2.0 + esa + provided + + + io.openliberty.features + mpConfig-1.3 + esa + provided + + + io.openliberty.features + mpRestClient-1.2 + esa + provided + + + + + + + + junit + junit + 4.13.1 + test + + + org.apache.cxf + cxf-rt-rs-client + 3.2.6 + test + + + org.apache.cxf + cxf-rt-rs-extension-providers + 3.2.6 + test + + + org.glassfish + javax.json + 1.0.4 + test + + + + org.apache.commons + commons-lang3 + 3.0 + + + + javax.xml.bind + jaxb-api + 2.3.1 + provided + + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + provided + + + javax.activation + activation + 1.1.1 + provided + + + javax.batch + javax.batch-api + 1.0.1 + provided + + + + org.slf4j + slf4j-api + 2.0.7 + + + ch.qos.logback + logback-classic + 1.3.12 + runtime + + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + + false + pom.xml + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + test + default-test + + + **/it/** + + ${project.build.directory}/test-reports/unit + + + + + + + io.openliberty.tools + liberty-maven-plugin + SUB_VERSION + + + io.openliberty + openliberty-kernel + RUNTIME_VERSION + zip + + ${app.name} + ${packaging.type} + + ${testServerHttpPort} + ${testServerHttpsPort} + json + + + -Xms512m + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.1.2 + + + integration-test + integration-test + + integration-test + + + + **/it/**/*.java + + + + ${testServerHttpPort} + + + + + + verify-results + + verify + + + + + ${project.build.directory}/test-reports/it/failsafe-summary.xml + ${project.build.directory}/test-reports/it + + + + + diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloLogger.java b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloLogger.java new file mode 100755 index 000000000..241bc76f1 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloLogger.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2020. + * + * Licensed 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. + *******************************************************************************/ +package com.demo; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import static javax.ws.rs.core.MediaType.TEXT_PLAIN; + +@Path("/show-log") +public class HelloLogger { + private static final Logger log = LoggerFactory.getLogger(HelloLogger.class); + + @GET + @Produces(TEXT_PLAIN) + public String showLog() { + log.info("Here is the Log"); + return "Log has been shown"; + } +} diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloServlet.java b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloServlet.java new file mode 100644 index 000000000..5afcb4f24 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloServlet.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2019. + * + * Licensed 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. + *******************************************************************************/ +package com.demo; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(urlPatterns="/servlet") +public class HelloServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + private static final Logger log = LoggerFactory.getLogger(HelloLogger.class); + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + log.info("SLF4J Logger is ready for messages."); + response.getWriter().append("hello world"); + } +} \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloWorld.java b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloWorld.java new file mode 100755 index 000000000..7c580a445 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/java/com/demo/HelloWorld.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2019. + * + * Licensed 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. + *******************************************************************************/ +package com.demo; + +public class HelloWorld { + + public String helloWorld() { + return "helloWorld"; + } +} diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/bootstrap.properties b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/bootstrap.properties new file mode 100644 index 000000000..46fee5e9c --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/bootstrap.properties @@ -0,0 +1 @@ +com.ibm.ws.logging.trace.specification=config=all=enabled:*=info=enabled \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/extraFeatures.xml b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/extraFeatures.xml new file mode 100644 index 000000000..6fa271bbf --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/extraFeatures.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/server.xml b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/server.xml new file mode 100755 index 000000000..013f8a951 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/liberty/config/server.xml @@ -0,0 +1,11 @@ + + + + jaxrs-2.1 + + + + + + diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/resources/placeHolder.txt b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-default-execution-id/src/main/resources/placeHolder.txt new file mode 100644 index 000000000..e69de29bb diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/pom.xml b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/pom.xml new file mode 100755 index 000000000..8531de9fa --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/pom.xml @@ -0,0 +1,270 @@ + + + + 4.0.0 + + dev-it-tests + basic-dev-project-with-execution-id + 1.0-SNAPSHOT + war + + + ISO_8859_1 + UTF-8 + 1.8 + 1.8 + -Xms512m + LibertyProject + + 9080 + 9443 + + usr + + + + + + oss-sonatype + oss-sonatype + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + false + + + + + + + + io.openliberty.features + features-bom + RUNTIME_VERSION + pom + import + + + + + + + + io.openliberty.features + jaxrs-2.1 + esa + provided + + + io.openliberty.features + jsonp-1.1 + esa + provided + + + io.openliberty.features + cdi-2.0 + esa + provided + + + io.openliberty.features + mpConfig-1.3 + esa + provided + + + io.openliberty.features + mpRestClient-1.2 + esa + provided + + + + + + + + junit + junit + 4.13.1 + test + + + org.apache.cxf + cxf-rt-rs-client + 3.2.6 + test + + + org.apache.cxf + cxf-rt-rs-extension-providers + 3.2.6 + test + + + org.glassfish + javax.json + 1.0.4 + test + + + + org.apache.commons + commons-lang3 + 3.0 + + + + javax.xml.bind + jaxb-api + 2.3.1 + provided + + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + provided + + + javax.activation + activation + 1.1.1 + provided + + + javax.batch + javax.batch-api + 1.0.1 + provided + + + + org.slf4j + slf4j-api + 2.0.7 + + + ch.qos.logback + logback-classic + 1.3.12 + runtime + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + java-compile + compile + compile + + + + + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + + false + pom.xml + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + test + default-test + + + **/it/** + + ${project.build.directory}/test-reports/unit + + + + + + + io.openliberty.tools + liberty-maven-plugin + SUB_VERSION + + + io.openliberty + openliberty-kernel + RUNTIME_VERSION + zip + + ${app.name} + ${packaging.type} + + ${testServerHttpPort} + ${testServerHttpsPort} + json + + + -Xms512m + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.1.2 + + + integration-test + integration-test + + integration-test + + + + **/it/**/*.java + + + + ${testServerHttpPort} + + + + + + verify-results + + verify + + + + + ${project.build.directory}/test-reports/it/failsafe-summary.xml + ${project.build.directory}/test-reports/it + + + + + diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloLogger.java b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloLogger.java new file mode 100755 index 000000000..4ff18e503 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloLogger.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2025. + * + * Licensed 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. + *******************************************************************************/ +package com.demo; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import static javax.ws.rs.core.MediaType.TEXT_PLAIN; + +@Path("/show-log") +public class HelloLogger { + private static final Logger log = LoggerFactory.getLogger(HelloLogger.class); + + @GET + @Produces(TEXT_PLAIN) + public String showLog() { + log.info("Here is the Log"); + return "Log has been shown"; + } +} diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloServlet.java b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloServlet.java new file mode 100644 index 000000000..52777ebd2 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloServlet.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2025. + * + * Licensed 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. + *******************************************************************************/ +package com.demo; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(urlPatterns="/servlet") +public class HelloServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + private static final Logger log = LoggerFactory.getLogger(HelloLogger.class); + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + log.info("SLF4J Logger is ready for messages."); + response.getWriter().append("hello world"); + } +} \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloWorld.java b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloWorld.java new file mode 100755 index 000000000..cac040467 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/java/com/demo/HelloWorld.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2025. + * + * Licensed 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. + *******************************************************************************/ +package com.demo; + +public class HelloWorld { + + public String helloWorld() { + return "helloWorld"; + } +} diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/bootstrap.properties b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/bootstrap.properties new file mode 100644 index 000000000..46fee5e9c --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/bootstrap.properties @@ -0,0 +1 @@ +com.ibm.ws.logging.trace.specification=config=all=enabled:*=info=enabled \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/extraFeatures.xml b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/extraFeatures.xml new file mode 100644 index 000000000..6fa271bbf --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/extraFeatures.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/server.xml b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/server.xml new file mode 100755 index 000000000..013f8a951 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/liberty/config/server.xml @@ -0,0 +1,11 @@ + + + + jaxrs-2.1 + + + + + + diff --git a/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/resources/placeHolder.txt b/liberty-maven-plugin/src/it/dev-it/resources/basic-dev-project-with-execution-id/src/main/resources/placeHolder.txt new file mode 100644 index 000000000..e69de29bb diff --git a/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevRecompileWithCustomExecutionIdTest.java b/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevRecompileWithCustomExecutionIdTest.java new file mode 100644 index 000000000..c9f6bd2ea --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevRecompileWithCustomExecutionIdTest.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2025. + * + * Licensed 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. + *******************************************************************************/ +package net.wasdev.wlp.test.dev.it; + +import static org.junit.Assert.*; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.nio.file.Files; +import java.util.Scanner; + +import org.apache.commons.io.FileUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import static io.openliberty.tools.common.plugins.util.BinaryScannerUtil.*; + +public class DevRecompileWithCustomExecutionIdTest extends BaseDevTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + setUpBeforeClass(null, "../resources/basic-dev-project-with-execution-id", true, false, null, null); + startProcess(null, true, "mvn compile liberty:", true); + } + + @AfterClass + public static void cleanUpAfterClass() throws Exception { + BaseDevTest.cleanUpAfterClass(true, true); + } + + @Test + public void validateRunExecutionNotSkipped() throws Exception { + //java-compile is the custom execution id + assertTrue(getLogTail(), verifyLogMessageExists("Running maven-compiler-plugin:compile#java-compile", 120000)); + assertTrue(getLogTail(), verifyLogMessageExists("Nothing to compile - all classes are up to date.", 120000)); + } +} \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevRecompileWithDefaultExecutionIdTest.java b/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevRecompileWithDefaultExecutionIdTest.java new file mode 100644 index 000000000..f714a4d68 --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevRecompileWithDefaultExecutionIdTest.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2025. + * + * Licensed 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. + *******************************************************************************/ +package net.wasdev.wlp.test.dev.it; + +import static org.junit.Assert.*; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.nio.file.Files; +import java.util.Scanner; + +import org.apache.commons.io.FileUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import static io.openliberty.tools.common.plugins.util.BinaryScannerUtil.*; + +public class DevRecompileWithDefaultExecutionIdTest extends BaseDevTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + setUpBeforeClass(null, "../resources/basic-dev-project-with-default-execution-id", true, false, null, null); + startProcess(null, true, "mvn compile liberty:", true); + } + + @AfterClass + public static void cleanUpAfterClass() throws Exception { + BaseDevTest.cleanUpAfterClass(true, true); + } + + @Test + public void validateRunExecutionNotSkipped() throws Exception { + // Check that the correct execution id is picked up + // in this case, we are not passing any execution id in pom.xml, hence default execution id will be taken up + assertTrue(getLogTail(), verifyLogMessageExists("Running maven-compiler-plugin:compile#default-compile", 120000)); + assertTrue(getLogTail(), verifyLogMessageExists("Nothing to compile - all classes are up to date.", 120000)); + } +} \ No newline at end of file diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/ServerFeatureSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/ServerFeatureSupport.java index 36cf2e422..591bf0cab 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/ServerFeatureSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/ServerFeatureSupport.java @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2021, 2024. + * (C) Copyright IBM Corporation 2021, 2025. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,17 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Comparator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Properties; import java.util.Set; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.descriptor.PluginDescriptor; @@ -344,4 +347,25 @@ protected Plugin getPluginForProject(String groupId, String artifactId, MavenPro } return plugin; } + + /** + * Get Plugin execution id from current project build configuration + * @param goal + * @param plugin + * @return + */ + protected String getExecutionId(String goal, Plugin plugin) { + // by default, each goal will have default execution, it will be named as default-{goal_name} + // if user has specified execution id in for a plugin, plugin execution list will have multiple entries + // if multiple entries are present, default execution id will have lowest priority(-1) + // due to this, we are taking pluginExecution will maximum priority + Optional currentExecution = plugin.getExecutions().stream() + .filter(pluginExecution -> pluginExecution.getGoals().stream().anyMatch(goal1 -> goal1.equals(goal))) + .max(Comparator.comparing(PluginExecution::getPriority)); + if (currentExecution.isPresent()) { + return currentExecution.get().getId(); + } else { + return "default-" + goal; + } + } } diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java index 709ddaf88..b0255d578 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2019, 2024. + * (C) Copyright IBM Corporation 2019, 2025. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -2019,6 +2019,7 @@ private void runCompileMojo(String goal, MavenProject mavenProject) throws MojoE MavenProject tempProject = mavenProject; Xpp3Dom config = ExecuteMojoUtil.getPluginGoalConfig(plugin, goal, getLog()); config = Xpp3Dom.mergeXpp3Dom(configuration(element(name("failOnError"), "false")), config); + goal = goal + "#" + getExecutionId(goal, plugin); getLog().info("Running maven-compiler-plugin:" + goal + " on " + tempProject.getFile()); getLog().debug("configuration:\n" + config); executeMojo(plugin, goal(goal), config, executionEnvironment(tempProject, tempSession, pluginManager)); diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java index 953f4eadb..0b6e4bc85 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2014, 2024. + * (C) Copyright IBM Corporation 2014, 2025. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -178,6 +178,7 @@ protected ServerTask initializeJava() { protected void runMojo(String groupId, String artifactId, String goal) throws MojoExecutionException { Plugin plugin = getPlugin(groupId, artifactId); Xpp3Dom config = ExecuteMojoUtil.getPluginGoalConfig(plugin, goal, getLog()); + goal = goal + "#" + getExecutionId(goal, plugin); getLog().info("Running " + artifactId + ":" + goal); getLog().debug("configuration:\n" + config); executeMojo(plugin, goal(goal), config, diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/utils/ExecuteMojoUtil.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/utils/ExecuteMojoUtil.java index a8e5432d7..763b0b403 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/utils/ExecuteMojoUtil.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/utils/ExecuteMojoUtil.java @@ -22,9 +22,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; @@ -269,8 +271,9 @@ public static Xpp3Dom getPluginGoalConfig(Plugin plugin, String goal, Log log) { String execId = "default"; int numExec = 0; - List executions = plugin.getExecutions(); - if (executions != null) { + List executions = plugin.getExecutions() + .stream().sorted(Comparator.comparing(PluginExecution::getPriority).reversed()).collect(Collectors.toList()); + if (!executions.isEmpty()) { for (PluginExecution e : executions) { if (e.getGoals() != null && e.getGoals().contains(goal)) { if (numExec == 0) { @@ -289,10 +292,10 @@ public static Xpp3Dom getPluginGoalConfig(Plugin plugin, String goal, Log log) { config = (Xpp3Dom) plugin.getConfiguration(); } if (numExec > 1) { - log.warn(plugin.getArtifactId() + ":" + goal + log.warn(plugin.getArtifactId() + ":" + goal + " goal has multiple execution configurations (default to \"" + execId + "\" execution)"); } - + if (config == null) { config = configuration(); } else {