Skip to content

Commit 5b39d5c

Browse files
committed
support multimodule when addin deps
1 parent 08c5218 commit 5b39d5c

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

scripts/pit/lib/lib-patch-v25.sh

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,21 @@ applyv25patches() {
5050
;;
5151
start)
5252
## TODO: document this for tests using spring tests
53-
addMavenDep org.springframework.boot spring-boot-webmvc-test test
53+
addMavenDep pom.xml org.springframework.boot spring-boot-webmvc-test test
5454
## TODO: open an issue in start, why after vaadin:dance this is not installed
5555
## For some reason npm install glob@^11.0.3 --save modifies devdeps but not deps
5656
perl -0777 -pi -e 's|( "lit":)|\n "glob": "^11.0.3",$1|' package.json
5757
;;
5858
bookstore-example)
5959
## TODO: check that documentation mention elemental is not a transitive dep anymore
60-
addMavenDep "com.google.gwt" "gwt-elemental" compile '\<version\>2.9.0\</version\>'
60+
addMavenDep pom.xml "com.google.gwt" "gwt-elemental" compile '\<version\>2.9.0\</version\>'
6161
;;
62-
flow-quickstart-tutorial)
63-
addMavenDep "commons-io" "commons-io" "compile"
62+
flow-quickstart-tutorial|multi-module-example)
63+
## TODO: document that this transitive dependency has removed, users might rely on that
64+
## see https://github.com/vaadin/copilot-internal/issues/7175
65+
for __file in `getPomFiles`; do
66+
addMavenDep "$__file" "commons-io" "commons-io" "compile"
67+
done
6468
addGradleDep "commons-io" "commons-io"
6569
;;
6670
esac
@@ -504,7 +508,7 @@ replaceVaadinSpringWithStarter() {
504508
# Check if it's not already vaadin-spring-boot-starter
505509
if ! grep -q "vaadin-spring-boot-starter" pom.xml 2>/dev/null; then
506510
[ -z "$TEST" ] && warn "Replacing vaadin-spring with vaadin-spring-boot-starter in pom.xml" || cmd "## Replacing vaadin-spring with vaadin-spring-boot-starter in pom.xml"
507-
511+
508512
# Replace vaadin-spring with vaadin-spring-boot-starter
509513
_cmd="perl -pi -e 's|<artifactId>vaadin-spring</artifactId>|<artifactId>vaadin-spring-boot-starter</artifactId>|g' pom.xml"
510514
cmd "$_cmd"
@@ -525,16 +529,17 @@ replaceVaadinSpringWithStarter() {
525529
# $1 optional
526530
addDevModeIfNeeded() {
527531
# Add vaadin-dev dependency if Spring is not found
528-
# Handle Maven projects
529-
if [ -f "pom.xml" ]; then
532+
# Handle Maven projects in all modules
533+
for pom in */pom.xml; do
534+
[ -f "$pom" ] || continue
530535
# Check for actual dependency, not exclusions
531-
if ! grep -A 2 -B 2 "vaadin-dev" pom.xml 2>/dev/null | grep -q "<dependency>" 2>/dev/null; then
532-
[ -z "$TEST" ] && log "Adding vaadin-dev dependency to Maven project"
533-
addMavenDep "com.vaadin" "vaadin-dev" "compile" "$1"
536+
if ! grep -A 2 -B 2 "vaadin-dev" "$pom" 2>/dev/null | grep -q "<dependency>" 2>/dev/null; then
537+
[ -z "$TEST" ] && log "Adding vaadin-dev dependency to Maven project ($pom)"
538+
addMavenDep "$pom" "com.vaadin" "vaadin-dev" "compile" "$1"
534539
else
535-
[ -z "$TEST" ] && log "vaadin-dev dependency already present in Maven project"
540+
[ -z "$TEST" ] && log "vaadin-dev dependency already present in Maven project ($pom)"
536541
fi
537-
fi
542+
done
538543

539544
# Handle Gradle projects
540545
if [ -f "build.gradle" ]; then
@@ -582,7 +587,7 @@ addHillaStarterIfNeeded() {
582587
if [ -f "pom.xml" ]; then
583588
if ! grep -q "hilla-spring-boot-starter" pom.xml 2>/dev/null; then
584589
[ -z "$TEST" ] && log "Adding Hilla Spring Boot Starter dependency to Maven project"
585-
addMavenDep "com.vaadin" "hilla-spring-boot-starter" "compile"
590+
addMavenDep pom.xml "com.vaadin" "hilla-spring-boot-starter" "compile"
586591
else
587592
[ -z "$TEST" ] && log "Hilla Spring Boot Starter dependency already present in Maven project"
588593
fi

scripts/pit/lib/lib-utils.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,16 @@ addRepoToPom() {
821821
}
822822

823823
## Adds a maven dep in the block </dependencies> previous to </build>
824-
## $1 groupId
825-
## $2 artifactId
826-
## $3 scope
827-
## $4 extra content e.g. <version>nnn</version>
824+
## $1 pom.xml file
825+
## $2 groupId
826+
## $3 artifactId
827+
## $4 scope
828+
## $5 extra content e.g. <version>nnn</version>
828829
addMavenDep() {
829-
local GI=$1; local AI=$2; local SC=$3; local EX="$4"
830+
local POM=$1; local GI=$2; local AI=$3; local SC=$4; local EX="$5"
830831
local t=' '
831-
__cmd="perl -0777 -pi -e 's|(\n[ \t]*)(</dependencies>\s+(<build>\|<repo\|<dependencyM))|\$1$t<dependency>\$1$t$t<groupId>${GI}</groupId>\$1$t$t<artifactId>${AI}</artifactId>\$1$t$t<scope>${SC}</scope>${EX}\$1$t</dependency>\$1\$2|' pom.xml"
832+
[ -z "$POM" ] && POM=pom.xml
833+
__cmd="perl -0777 -pi -e 's|(\n[ \t]*)(</dependencies>\s+(<build>\|<repo\|<dependencyM))|\$1$t<dependency>\$1$t$t<groupId>${GI}</groupId>\$1$t$t<artifactId>${AI}</artifactId>\$1$t$t<scope>${SC}</scope>${EX}\$1$t</dependency>\$1\$2|' $POM"
832834
runCmd -f "Adding dependency $GI $AI $SC to pom.xml" "$__cmd"
833835
}
834836

0 commit comments

Comments
 (0)