vscode-maven icon indicating copy to clipboard operation
vscode-maven copied to clipboard

Maven isn't displaying the variable property containing the name of the artifact properly in VS Code

Open tommai78101 opened this issue 3 years ago • 3 comments

Describe the bug

Maven in Visual Studio displays ${project.build.finalName} if a POM file uses the <finalName> tag inside tag to display the of the produced artifact.

To Reproduce Steps to reproduce the behavior:

  1. 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>
  1. When you open a Maven project in Visual Studio Code, you will see the following:

image

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

tommai78101 avatar Jun 16 '21 15:06 tommai78101

This is also happening on the following environments:

  • OS: Windows 10 Pro 20H2
  • VS Code version: 1.57.1
  • Extension version: v0.31.0

image Displays as such: image

xvelezv avatar Jul 08 '21 15:07 xvelezv

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.

Eskibear avatar Jul 08 '21 16:07 Eskibear

In my opinion, I prefer calculating the effective POM then updating from it, mainly due to it being more accurate.

tommai78101 avatar Jul 10 '21 02:07 tommai78101