Uploaded image for project: 'Maven Enforcer Plugin'
  1. Maven Enforcer Plugin
  2. MENFORCER-370

<condition/> should not take resolved properties as Java string, but escape backslashes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 3.0.0-M2
    • None
    • Plugin
    • None

    Description

      Running Maven with ${project.basedir} in the <evaluateBeanshell><condition> in a pom.xml fails under Windows, while Linux is fine.
      Already

          <evaluateBeanshell>
              <condition>
                  print(java.nio.file.Paths.get("${project.basedir}/".replace("\\", "/"));
                  1==1
              </condition>
          </evaluateBeanshell>
      

      fails with Couldn't evaluate condition... as ${project.basedir} is apparently taken as a Java string directly, w/o escaping the backslashes.
      While the message part

          <evaluateBeanshell>
              <condition>
                  1==0
              </condition>
              <message>condition failed, project.basedir=${project.basedir}</message>
          </evaluateBeanshell>
      

      logs the Windows path correctly:

          [WARNING] Rule 2: org.apache.maven.plugins.enforcer.EvaluateBeanshell failed with message:
          condition failed, project.basedir=C:\Users\me\git\project\dir_with_pom_file
      

      Attachments

        Activity

          People

            rfscholte Robert Scholte
            DaMarvin Damian
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: