Skip to content

Add Monorepo#6

Merged
quocky05 merged 48 commits intomainfrom
monorepo
May 2, 2026
Merged

Add Monorepo#6
quocky05 merged 48 commits intomainfrom
monorepo

Conversation

@phongthanh1412
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings April 29, 2026 01:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Jenkins CI support for the monorepo and aligns the Maven build to a Java 21 baseline.

Changes:

  • Downgrade Maven compiler/source/target (and java.version) from 25 to 21 in the root pom.xml.
  • Add a new Jenkinsfile that conditionally builds/tests selected modules based on path changes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pom.xml Updates project Java/compiler baseline to 21.
Jenkinsfile Introduces a declarative Jenkins pipeline with parallel, per-module conditional builds and JUnit report publishing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Jenkinsfile Outdated
Comment on lines +10 to +18
stage('Monorepo Build & Test') {
parallel {

stage('Media Service') {
when { changeset "media/**" }
steps {
echo 'Changes detected in Media Service. Starting Build & Test...'
sh 'mvn clean test -pl media -am'
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All stages in the parallel block are gated by when { changeset "<module>/**" }, so changes to root/shared files (e.g., pom.xml, common-library/**, deployment/**, etc.) will skip every branch and the pipeline will report success without running any build/tests (including for this PR, which changes pom.xml). Add a fallback that runs a full build when changes are outside the listed module paths, or expand the when conditions to include shared/root paths and/or a catch-all branch.

Copilot uses AI. Check for mistakes.
Comment thread Jenkinsfile
Comment on lines +11 to +34
parallel {

stage('Media Service') {
when { changeset "media/**" }
steps {
echo 'Changes detected in Media Service. Starting Build & Test...'
sh 'mvn clean test -pl media -am'
}
}

stage('Product Service') {
when { changeset "product/**" }
steps {
echo 'Changes detected in Product Service. Starting Build & Test...'
sh 'mvn clean test -pl product -am'
}
}

stage('Cart Service') {
when { changeset "cart/**" }
steps {
echo 'Changes detected in Cart Service. Starting Build & Test...'
sh 'mvn clean test -pl cart -am'
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running multiple mvn clean test -pl <module> -am executions in parallel within the same workspace can race on shared module build outputs (e.g., common-library/target) and Maven reactor state, making builds flaky or corrupting artifacts. Consider serializing module builds, or isolating each parallel branch into its own workspace (e.g., ws(...) / separate checkout) and/or avoiding -am in parallel by building shared dependencies once up front.

Copilot uses AI. Check for mistakes.
Comment thread Jenkinsfile
sh 'mvn clean test -pl inventory -am'
}
}

Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pipeline only defines conditional builds for a subset of Maven modules (media/product/cart/rating/tax/webhook/promotion/location/inventory), but the root pom.xml lists additional modules (e.g., customer, order, payment, search, storefront-bff, delivery, etc.). As written, changes under those module directories will not trigger any build/test stage. Add stages (or a more generic mechanism) to ensure every module has coverage.

Suggested change
stage('Other Maven Modules') {
when {
expression {
def coveredModules = [
'media',
'product',
'cart',
'rating',
'tax',
'webhook',
'promotion',
'location',
'inventory'
] as Set
return currentBuild.changeSets.any { changeSet ->
changeSet.items.any { item ->
item.affectedFiles.any { file ->
def path = file.path ?: ''
def topLevelDir = path.tokenize('/')[0]
topLevelDir && !coveredModules.contains(topLevelDir)
}
}
}
}
}
steps {
echo 'Changes detected outside the explicitly covered modules. Starting full monorepo Build & Test...'
sh 'mvn clean test'
}
}

Copilot uses AI. Check for mistakes.
Comment thread pom.xml
Comment on lines +42 to +44
<java.version>21</java.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the project compiler/JDK baseline to Java 21, but the repo still references Java 25 elsewhere (e.g., README.md lists Java 25, and .github/workflows/actions/action.yaml sets up JDK 25). To avoid confusion and ensure consistent builds across CI environments, align the docs and CI toolchains with the intended Java baseline (or document why CI intentionally runs a newer JDK than the compilation target).

Suggested change
<java.version>21</java.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- Java 21 is the project compilation baseline; keep compiler settings derived from this single property. -->
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

Copilot uses AI. Check for mistakes.
quocky05
quocky05 previously approved these changes May 2, 2026
@quocky05 quocky05 merged commit 632bb50 into main May 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants