@@ -116,11 +116,11 @@ ba_log "Generating Codename One application skeleton via codenameone-maven-plugi
116116
117117APP_DIR=" $WORK_DIR /$ARTIFACT_ID "
118118
119- # --- Normalize CN1 versions without versions-maven-plugin ---
119+ # --- Normalize Codename One versions (safe for Maven parent resolution) ---
120120
121121ROOT_POM=" $APP_DIR /pom.xml"
122122
123- # 1 ) Ensure codenameone.version property exists (or update it )
123+ # 0 ) Ensure property exists (you can keep this for deps/plugins )
124124ensure_property () {
125125 local pom=" $1 " name=" $2 " value=" $3 "
126126 if ! grep -q " <properties>" " $pom " ; then
@@ -138,29 +138,28 @@ ensure_property() {
138138 perl -0777 -pe " s|(<${name} >)[^<]+(</${name} >)|\$ 1${value} \$ 2|s" -i " $pom "
139139 fi
140140}
141-
142141ensure_property " $ROOT_POM " " codenameone.version" " $CN1_VERSION "
143142
144- # 2) In every pom.xml:
145- # - Point <parent><version> to ${codenameone.version} for Codename One parent
146- # - Set com.codenameone dependencies/plugins <version>${codenameone.version}</version>
143+ # 1) Parent: set literal version (Maven DOES NOT allow a property here)
147144while IFS= read -r -d ' ' P; do
148- # Parent version -> ${codenameone.version}
149- perl -0777 -pe ' s!(<parent>\s*<groupId>com\.codenameone</groupId>\s*<artifactId>codenameone-maven-parent</artifactId>\s*<version>)[^<]+(</version>)!${1}${codenameone.version}${2}!s ' -i " $P "
145+ perl -0777 -pe ' s!(<parent>\s*<groupId>com\.codenameone</groupId>\s*<artifactId>codenameone-maven-parent</artifactId>\s*<version>)[^<]+(</version>)!$1 ' " $CN1_VERSION " ' $2!s ' -i " $P "
146+ done < <( find " $APP_DIR " -type f -name pom.xml -print0 )
150147
151- # Dependencies (only com.codenameone)
148+ # 2) com.codenameone deps/plugins -> use the property (optional but tidy)
149+ while IFS= read -r -d ' ' P; do
152150 perl -0777 -pe ' s!(<dependency>\s*<groupId>com\.codenameone[^<]*</groupId>\s*<artifactId>[^<]+</artifactId>\s*<version>)[^<]+(</version>)!${1}${codenameone.version}${2}!sg' -i " $P "
153-
154- # Plugins (only com.codenameone)
155151 perl -0777 -pe ' s!(<plugin>\s*<groupId>com\.codenameone[^<]*</groupId>\s*<artifactId>[^<]+</artifactId>\s*<version>)[^<]+(</version>)!${1}${codenameone.version}${2}!sg' -i " $P "
156152done < <( find " $APP_DIR " -type f -name pom.xml -print0)
157153
158- # 3) Build with the property set so any missed spots still resolve correctly
154+ # 3) Build with the property set (covers any missed spots)
159155EXTRA_MVN_ARGS+=(" -Dcodenameone.version=${CN1_VERSION} " )
160156
161- grep -nA2 -B2 ' < parent> ' " $APP_DIR /pom.xml "
162- grep -nA3 - B3 ' <pluginManagement >' " $APP_DIR /pom.xml"
157+ # Show parent block without failing the build
158+ grep -n -A3 - B3 ' <parent >' " $APP_DIR /pom.xml" || true
163159
160+ # Optional: dump effective POM to inspect pluginManagement
161+ " ${MAVEN_HOME} /bin/mvn" -q -f " $APP_DIR /pom.xml" help:effective-pom -Doutput=" $APP_DIR /effective-pom.xml" || true
162+ tail -n +1 " $APP_DIR /effective-pom.xml" | sed -n ' 1,200p' > /dev/null || true
164163
165164[ -d " $APP_DIR " ] || { ba_log " Failed to create Codename One application project" >&2 ; exit 1; }
166165[ -f " $APP_DIR /build.sh" ] && chmod +x " $APP_DIR /build.sh"
0 commit comments