|
| 1 | +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 |
| 2 | +index 65bd4dfd502d..c0cfcfc93c84 100644 |
| 3 | +--- a/java/maven.hints/src/org/netbeans/modules/maven/hints/pom/ParentVersionError.java |
| 4 | ++++ b/java/maven.hints/src/org/netbeans/modules/maven/hints/pom/ParentVersionError.java |
| 5 | +@@ -40,6 +40,7 @@ |
| 6 | + import org.netbeans.modules.maven.indexer.api.RepositoryQueries.Result; |
| 7 | + import org.netbeans.modules.maven.model.pom.POMModel; |
| 8 | + import org.netbeans.modules.maven.model.pom.Parent; |
| 9 | ++import org.netbeans.modules.maven.model.pom.Properties; |
| 10 | + import org.netbeans.modules.xml.xam.Model; |
| 11 | + import org.netbeans.spi.editor.hints.ChangeInfo; |
| 12 | + import org.netbeans.spi.editor.hints.ErrorDescription; |
| 13 | +@@ -108,6 +109,15 @@ public List<ErrorDescription> getErrorsForDocument(POMModel model, Project prj) |
| 14 | + NbMavenProject nbprj = parentPrj.getLookup().lookup(NbMavenProject.class); |
| 15 | + if (nbprj != null) { //do we have some non-maven project maybe? |
| 16 | + MavenProject mav = nbprj.getMavenProject(); |
| 17 | ++ if (PomModelUtils.isPropertyExpression(declaredVersion)) { |
| 18 | ++ String propVal = PomModelUtils.getProperty(model, declaredVersion); |
| 19 | ++ if (propVal != null) { |
| 20 | ++ declaredVersion = propVal; |
| 21 | ++ } else { |
| 22 | ++ String key = PomModelUtils.getPropertyName(declaredVersion); |
| 23 | ++ declaredVersion = mav.getProperties().getProperty(key, declaredVersion); |
| 24 | ++ } |
| 25 | ++ } |
| 26 | + //#167711 check the coordinates to filter out parents in non-default location without relative-path elemnt |
| 27 | + if (parGr.equals(mav.getGroupId()) && |
| 28 | + parArt.equals(mav.getArtifactId())) { |
| 29 | +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 |
| 30 | +index 29a75a5398fa..e3524d091ef5 100644 |
| 31 | +--- a/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/pom/ParentVersionErrorTest.java |
| 32 | ++++ b/java/maven.hints/test/unit/src/org/netbeans/modules/maven/hints/pom/ParentVersionErrorTest.java |
| 33 | +@@ -86,5 +86,28 @@ public void testSpecialRelativePath() throws Exception { // #194281 |
| 34 | + Project prj = ProjectManager.getDefault().findProject(pom.getParent()); |
| 35 | + assertEquals(Collections.<ErrorDescription>emptyList(), new ParentVersionError().getErrorsForDocument(model, prj)); |
| 36 | + } |
| 37 | +- |
| 38 | ++ |
| 39 | ++ public void testVariablePresentInVersion() throws Exception { // #194281 |
| 40 | ++ TestFileUtils.writeFile(work, "pom.xml", "<project xmlns='http://maven.apache.org/POM/4.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd'>\n" + |
| 41 | ++ " <modelVersion>4.0.0</modelVersion>\n" + |
| 42 | ++ " <groupId>grp</groupId>\n" + |
| 43 | ++ " <artifactId>common</artifactId>\n" + |
| 44 | ++ " <version>${revision}</version>\n" + |
| 45 | ++ " <properties>\n" + |
| 46 | ++ " <revision>1.1</revision>\n" + |
| 47 | ++ " </properties>\n" + |
| 48 | ++ "</project>\n"); |
| 49 | ++ FileObject pom = TestFileUtils.writeFile(work, "prj/pom.xml", "<project xmlns='http://maven.apache.org/POM/4.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd'>\n" + |
| 50 | ++ " <modelVersion>4.0.0</modelVersion>\n" + |
| 51 | ++ " <parent>\n" + |
| 52 | ++ " <groupId>grp</groupId>\n" + |
| 53 | ++ " <artifactId>common</artifactId>\n" + |
| 54 | ++ " <version>${revision}</version>\n" + |
| 55 | ++ " </parent>\n" + |
| 56 | ++ " <artifactId>prj</artifactId>\n" + |
| 57 | ++ "</project>\n"); |
| 58 | ++ POMModel model = POMModelFactory.getDefault().getModel(Utilities.createModelSource(pom)); |
| 59 | ++ Project prj = ProjectManager.getDefault().findProject(pom.getParent()); |
| 60 | ++ assertEquals(Collections.<ErrorDescription>emptyList(), new ParentVersionError().getErrorsForDocument(model, prj)); |
| 61 | ++ } |
| 62 | + } |
0 commit comments