vscode-maven
vscode-maven copied to clipboard
Maven isn't displaying the variable property containing the name of the artifact properly in VS Code
Describe the bug
Maven in Visual Studio displays ${project.build.finalName} if a POM file uses the <finalName> tag inside
To Reproduce Steps to reproduce the behavior:
- Copy and place the following test Maven POM file down in a test Maven project:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>foo.bar</groupId>
<artifactId>HelloWorld</artifactId>
<version>0.0.1</version>
</parent>
<groupId>test.test</groupId>
<artifactId>my_artifact</artifactId>
<packaging>pom</packaging>
<name>${project.build.finalName}</name>
<description>This is a legitimate Maven POM file, with a broken name being displayed in Visual Studio Code Maven integration.</description>
<build>
<finalName>THIS_IS_A_FINAL_NAME</finalName>
</build>
</project>
- When you open a Maven project in Visual Studio Code, you will see the following:
Expected behavior
The <finalName> value should be displayed in the menu. THIS_IS_A_FINAL_NAME should be displayed, instead of ${project.build.finalName}
.
Environments (please complete the following information as much as possible):
- OS: Ubuntu 20.04.02 LTS
- VS Code version: 1.57.0
- Extension version: v0.31.0
This is also happening on the following environments:
- OS: Windows 10 Pro 20H2
- VS Code version: 1.57.1
- Extension version: v0.31.0
Displays as such:
It's not reading from effective pom. Currently only properties
are substituted.
One approach is, whenever effective pom is calculated, we update the name from effective pom. Another one is, we read the pom.xml and do substitution on our own.
In my opinion, I prefer calculating the effective POM then updating from it, mainly due to it being more accurate.