From 9d132487b5e2544acbd61f230973eb1f2c1973bc Mon Sep 17 00:00:00 2001 From: Sajeer Date: Mon, 13 Apr 2026 19:00:56 +0530 Subject: [PATCH 1/3] Test for no duplicate compilation --- .../dev/it/DevNoDuplicateCompilationTest.java | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevNoDuplicateCompilationTest.java diff --git a/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevNoDuplicateCompilationTest.java b/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevNoDuplicateCompilationTest.java new file mode 100644 index 000000000..187e403ab --- /dev/null +++ b/liberty-maven-plugin/src/it/dev-it/src/test/java/net/wasdev/wlp/test/dev/it/DevNoDuplicateCompilationTest.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2026. + * + * 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 org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class DevNoDuplicateCompilationTest extends BaseDevTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + setUpBeforeClass("-DgenerateFeatures=true"); + } + + @AfterClass + public static void cleanUpAfterClass() throws Exception { + BaseDevTest.cleanUpAfterClass(); + } + + @Test + public void testNoDuplicateCompilation() throws Exception { + assertTrue(verifyLogMessageExists("Liberty is running in dev mode.", 10000)); + assertTrue(verifyLogMessageExists(WEB_APP_AVAILABLE, 20000)); + + File srcHelloWorld = new File(tempProj, "src/main/java/com/demo/HelloWorld.java"); + File targetHelloWorld = new File(targetDir, "classes/com/demo/HelloWorld.class"); + assertTrue(srcHelloWorld.exists()); + assertTrue(targetHelloWorld.exists()); + + // Count initial compilation messages + int initialCompilationCount = countOccurrences(COMPILATION_SUCCESSFUL, logFile); + int initialHotReloadCount = countOccurrences(SERVER_CONFIG_SUCCESS, logFile); + + waitLongEnough(); + long lastModified = targetHelloWorld.lastModified(); + + // Modify the Java file + String modification = "// Test modification for duplicate compilation check"; + BufferedWriter javaWriter = null; + try { + javaWriter = new BufferedWriter(new FileWriter(srcHelloWorld, true)); + javaWriter.append('\n'); + javaWriter.append(modification); + } finally { + if (javaWriter != null) { + javaWriter.close(); + } + } + + assertTrue("Class file was not recompiled", waitForCompilation(targetHelloWorld, lastModified, 10000)); + assertTrue("Source compilation message not found", + verifyLogMessageExists(COMPILATION_SUCCESSFUL, 10000, ++initialCompilationCount)); + assertTrue("Liberty hot reload message (CWWKZ0003I) not found", + verifyLogMessageExists(SERVER_CONFIG_SUCCESS, 10000, ++initialHotReloadCount)); + + Thread.sleep(3000); + + // Count final compilation messages + int finalCompilationCount = countOccurrences(COMPILATION_SUCCESSFUL, logFile); + int finalHotReloadCount = countOccurrences(SERVER_CONFIG_SUCCESS, logFile); + + assertEquals("Duplicate compilation detected - compilation happened more than once", + initialCompilationCount, finalCompilationCount); + assertEquals("Multiple hot reloads detected - should only reload once per change", + initialHotReloadCount, finalHotReloadCount); + } + + @Test + public void testMultipleSequentialChanges() throws Exception { + assertTrue(verifyLogMessageExists("Liberty is running in dev mode.", 10000)); + assertTrue(verifyLogMessageExists(WEB_APP_AVAILABLE, 20000)); + + File srcHelloWorld = new File(tempProj, "src/main/java/com/demo/HelloWorld.java"); + File targetHelloWorld = new File(targetDir, "classes/com/demo/HelloWorld.class"); + assertTrue(srcHelloWorld.exists()); + assertTrue(targetHelloWorld.exists()); + + // Perform multiple sequential changes + for (int i = 1; i <= 3; i++) { + int compilationCountBefore = countOccurrences(COMPILATION_SUCCESSFUL, logFile); + int hotReloadCountBefore = countOccurrences(SERVER_CONFIG_SUCCESS, logFile); + + waitLongEnough(); + long lastModified = targetHelloWorld.lastModified(); + + // Modify the Java file + String modification = "// Test modification #" + i + " for duplicate compilation check"; + BufferedWriter javaWriter = null; + try { + javaWriter = new BufferedWriter(new FileWriter(srcHelloWorld, true)); + javaWriter.append('\n'); + javaWriter.append(modification); + } finally { + if (javaWriter != null) { + javaWriter.close(); + } + } + + assertTrue("Class file was not recompiled for change #" + i, + waitForCompilation(targetHelloWorld, lastModified, 10000)); + assertTrue("Source compilation message not found for change #" + i, + verifyLogMessageExists(COMPILATION_SUCCESSFUL, 10000, ++compilationCountBefore)); + assertTrue("Liberty hot reload message (CWWKZ0003I) not found for change #" + i, + verifyLogMessageExists(SERVER_CONFIG_SUCCESS, 10000, ++hotReloadCountBefore)); + + Thread.sleep(3000); + + // Count compilation messages after change + int compilationCountAfter = countOccurrences(COMPILATION_SUCCESSFUL, logFile); + int hotReloadCountAfter = countOccurrences(SERVER_CONFIG_SUCCESS, logFile); + + assertEquals("Duplicate compilation detected for change #" + i, + compilationCountBefore, compilationCountAfter); + assertEquals("Multiple hot reloads detected for change #" + i, + hotReloadCountBefore, hotReloadCountAfter); + } + } +} From 19a5fb796bebb5228412dfb3cd936311ea7118cf Mon Sep 17 00:00:00 2001 From: Sajeer Date: Tue, 14 Apr 2026 22:33:54 +0530 Subject: [PATCH 2/3] Connected ci.common --- .github/workflows/maven.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 73ef567c7..f96457065 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -98,7 +98,8 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: OpenLiberty/ci.common + repository: sajeerzeji/ci.common + reference: GH752-duplicate_processFileChanges_calls_for_java_source_files_in_devmode path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -206,7 +207,7 @@ jobs: - name: Clone ci.ant and ci.common repos to github.workspace run: | echo ${{github.workspace}} - git clone https://github.com/OpenLiberty/ci.common.git ${{github.workspace}}/ci.common + git clone https://github.com/sajeerzeji/ci.common.git --branch GH752-duplicate_processFileChanges_calls_for_java_source_files_in_devmode --single-branch ${{github.workspace}}/ci.common git clone https://github.com/OpenLiberty/ci.ant.git ${{github.workspace}}/ci.ant - name: Set up Maven uses: stCarolas/setup-maven@v4.5 From 57d22d33245498cc84c470a0f0749ea08a915ada Mon Sep 17 00:00:00 2001 From: Sajeer Date: Wed, 29 Apr 2026 11:30:51 +0530 Subject: [PATCH 3/3] Workflow reverted as ci.common got merged --- .github/workflows/maven.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f96457065..73ef567c7 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -98,8 +98,7 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: sajeerzeji/ci.common - reference: GH752-duplicate_processFileChanges_calls_for_java_source_files_in_devmode + repository: OpenLiberty/ci.common path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -207,7 +206,7 @@ jobs: - name: Clone ci.ant and ci.common repos to github.workspace run: | echo ${{github.workspace}} - git clone https://github.com/sajeerzeji/ci.common.git --branch GH752-duplicate_processFileChanges_calls_for_java_source_files_in_devmode --single-branch ${{github.workspace}}/ci.common + git clone https://github.com/OpenLiberty/ci.common.git ${{github.workspace}}/ci.common git clone https://github.com/OpenLiberty/ci.ant.git ${{github.workspace}}/ci.ant - name: Set up Maven uses: stCarolas/setup-maven@v4.5