Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 360491

Summary: ${project.basedir} and ${basedir} do not expand correctly
Product: z_Archived Reporter: Philippe Beaudoin <philippe.beaudoin>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: igor, tobias.hammerschmidt
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Philippe Beaudoin CLA 2011-10-10 22:59:45 EDT
In my POM, for maven-checkstyle-plugin, I have something like this:

<configuration>
...
<propertyExpansion>basedir=${project.basedir}</propertyExpansion>
</configuration>

In my checkstyle.properties I have:

header.file=target/checkstyle-header.txt

Then, in my checkstyle.xml I have:

<module name="Header">
<property name="fileExtensions" value="java"/>
<property name="severity" value="error"/>
<property name="headerFile" value="${basedir}/${header.file}"/>
</module>

However, when I try to "check code with checkstyle" in Eclipse I get the following error:

cannot initialize module Header - unable to load header file C:Usersbeaudoinworkspace2gwtpgwtp-coregwtp-mvp-client/target/checkstyle-header.txt

From this, it looks like that ${basedir} wrongfully got extended to "C:Usersbeaudoinworkspace2gwtpgwtp-coregwtp-mvp-client" when it should have been "C:/Users/beaudoin/workspace2/gwtp/gwtp-core/gwtp-mvp-client"

I tried using ${basedir} instead of ${project.basedir} but it did not work.

I started looking around here:
http://www.google.com/codesearch#bgpu_i12kK4/tags/maven-2.0.2/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
but could not find any obvious bug.

Note that it works if I hardcode the directory directly:
<propertyExpansion>basedir=C:/Users/beaudoin/workspace2/gwtp/gwtp-core/gwtp-mvp-client</propertyExpansion>

I have cross-posted the issue here:
  https://github.com/bimargulies/m2e-code-quality/issues/7
But I believe it belongs in m2e.
Comment 1 Philippe Beaudoin CLA 2011-10-10 23:18:42 EDT
Found a workaround. Define:
<properties>
  <prop.basedir>${basedir}</prop.basedir>
</properties>

And use:
<configuration>
...
<propertyExpansion>basedir=${prop.basedir}</propertyExpansion>
</configuration>
Comment 2 Philippe Beaudoin CLA 2011-10-10 23:38:17 EDT
(In reply to comment #1)
> Found a workaround. Define:
> <properties>
>   <prop.basedir>${basedir}</prop.basedir>
> </properties>
> 
> And use:
> <configuration>
> ...
> <propertyExpansion>basedir=${prop.basedir}</propertyExpansion>
> </configuration>

Scratch that, workaround doesn't work.
Comment 3 Igor Fedorenko CLA 2011-10-11 07:34:19 EDT
Please provide complete standalone sample project and steps to reproduce the problem.
Comment 4 Igor Fedorenko CLA 2012-05-21 10:41:52 EDT
Closing old/stale bugreports.
Comment 5 Denis Roy CLA 2021-04-19 13:22:05 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/