From 395c4427d7d61f699f4290697f516d6e340ea09a Mon Sep 17 00:00:00 2001 From: Achal Talati Date: Fri, 15 Mar 2024 14:19:35 +0530 Subject: [PATCH 1/2] added patch for issue-95 --- patches/7158.diff | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 patches/7158.diff diff --git a/patches/7158.diff b/patches/7158.diff new file mode 100644 index 0000000..66c1a64 --- /dev/null +++ b/patches/7158.diff @@ -0,0 +1,62 @@ +diff --git a/java/maven.hints/src/org/netbeans/modules/maven/hints/pom/ParentVersionError.java b/java/maven.hints/src/org/netbeans/modules/maven/hints/pom/ParentVersionError.java +index 65bd4dfd502d..c0cfcfc93c84 100644 +--- a/java/maven.hints/src/org/netbeans/modules/maven/hints/pom/ParentVersionError.java ++++ b/java/maven.hints/src/org/netbeans/modules/maven/hints/pom/ParentVersionError.java +@@ -40,6 +40,7 @@ + import org.netbeans.modules.maven.indexer.api.RepositoryQueries.Result; + import org.netbeans.modules.maven.model.pom.POMModel; + import org.netbeans.modules.maven.model.pom.Parent; ++import org.netbeans.modules.maven.model.pom.Properties; + import org.netbeans.modules.xml.xam.Model; + import org.netbeans.spi.editor.hints.ChangeInfo; + import org.netbeans.spi.editor.hints.ErrorDescription; +@@ -108,6 +109,15 @@ public List getErrorsForDocument(POMModel model, Project prj) + NbMavenProject nbprj = parentPrj.getLookup().lookup(NbMavenProject.class); + if (nbprj != null) { //do we have some non-maven project maybe? + MavenProject mav = nbprj.getMavenProject(); ++ if (PomModelUtils.isPropertyExpression(declaredVersion)) { ++ String propVal = PomModelUtils.getProperty(model, declaredVersion); ++ if (propVal != null) { ++ declaredVersion = propVal; ++ } else { ++ String key = PomModelUtils.getPropertyName(declaredVersion); ++ declaredVersion = mav.getProperties().getProperty(key, declaredVersion); ++ } ++ } + //#167711 check the coordinates to filter out parents in non-default location without relative-path elemnt + if (parGr.equals(mav.getGroupId()) && + parArt.equals(mav.getArtifactId())) { +diff --git a/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/pom/ParentVersionErrorTest.java b/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/pom/ParentVersionErrorTest.java +index 29a75a5398fa..e3524d091ef5 100644 +--- a/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/pom/ParentVersionErrorTest.java ++++ b/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/pom/ParentVersionErrorTest.java +@@ -86,5 +86,28 @@ public void testSpecialRelativePath() throws Exception { // #194281 + Project prj = ProjectManager.getDefault().findProject(pom.getParent()); + assertEquals(Collections.emptyList(), new ParentVersionError().getErrorsForDocument(model, prj)); + } +- ++ ++ public void testVariablePresentInVersion() throws Exception { // #194281 ++ TestFileUtils.writeFile(work, "pom.xml", "\n" + ++ " 4.0.0\n" + ++ " grp\n" + ++ " common\n" + ++ " ${revision}\n" + ++ " \n" + ++ " 1.1\n" + ++ " \n" + ++ "\n"); ++ FileObject pom = TestFileUtils.writeFile(work, "prj/pom.xml", "\n" + ++ " 4.0.0\n" + ++ " \n" + ++ " grp\n" + ++ " common\n" + ++ " ${revision}\n" + ++ " \n" + ++ " prj\n" + ++ "\n"); ++ POMModel model = POMModelFactory.getDefault().getModel(Utilities.createModelSource(pom)); ++ Project prj = ProjectManager.getDefault().findProject(pom.getParent()); ++ assertEquals(Collections.emptyList(), new ParentVersionError().getErrorsForDocument(model, prj)); ++ } + } From 4771e583088f42beb125fd354248d36fc65a85e9 Mon Sep 17 00:00:00 2001 From: Achal Talati Date: Fri, 15 Mar 2024 14:20:15 +0530 Subject: [PATCH 2/2] Update build.xml --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index b4ee88a..b30d7ac 100644 --- a/build.xml +++ b/build.xml @@ -31,7 +31,7 @@ - +