[ 
https://issues.apache.org/jira/browse/MANTRUN-206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16370692#comment-16370692
 ] 

Guillaume Boué commented on MANTRUN-206:
----------------------------------------

I don't think this can be solved at the plugin level. Once the plugin sees the 
POM, the basedir is already replaced with its absolute value in the plugin 
configuration, and it would need to make the distinction between a real 
pattern, and something that should be escaped. This is not always possible (is 
{{\target}} the literal string or a tabulation character followed by arget?).

A possible solution is to escape the pattern manually:

{code:xml}
<configuration>
  <target>
    <loadresource property="baseDirEscaped">
      <propertyresource name="basedir"/>
      <filterchain>
        <tokenfilter>
          <replacestring from="\" to="\\"/>
        </tokenfilter>
      </filterchain>
    </loadresource>
    <condition property="dir" 
value="${project.reporting.outputDirectory}/xsddoc">
      <matches string="${project.reporting.outputDirectory}" 
pattern="^${baseDirEscaped}" />
    </condition>
  </target>
</configuration>
{code}

> Plugin fails with conditional property containing a Windows path.
> -----------------------------------------------------------------
>
>                 Key: MANTRUN-206
>                 URL: https://issues.apache.org/jira/browse/MANTRUN-206
>             Project: Maven Antrun Plugin
>          Issue Type: Bug
>            Reporter: Robert Scholte
>            Assignee: Guillaume Boué
>            Priority: Major
>
> {code:xml}
> <configuration>
>   <target>
>     <condition property="dir" 
> value="${project.reporting.outputDirectory}/xsddoc">
>       <matches string="${project.reporting.outputDirectory}" 
> pattern="^${basedir}" />
>     </condition>
>   </target>
> </configuration>
> {code}
> This fragment fails on Windows with something like:
> {noformat}
> Caused by: java.util.regex.PatternSyntaxException: Illegal/unsupported escape 
> sequence near index 4
> ^E:\java-workspace\apache-maven-doxia\maven-doxia\doxia-modules\doxia-module-fml
>     ^
>     at java.util.regex.Pattern.error (Pattern.java:1957)
>     at java.util.regex.Pattern.escape (Pattern.java:2473)
>     at java.util.regex.Pattern.atom (Pattern.java:2200)
>     at java.util.regex.Pattern.sequence (Pattern.java:2132)
>     at java.util.regex.Pattern.expr (Pattern.java:1998)
>     at java.util.regex.Pattern.compile (Pattern.java:1698)
>     at java.util.regex.Pattern.<init> (Pattern.java:1351)
>     at java.util.regex.Pattern.compile (Pattern.java:1054)
>     at org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher.getCompiledPattern 
> (Jdk14RegexpMatcher.java:67)
>     at org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher.matches 
> (Jdk14RegexpMatcher.java:94)
>     at org.apache.tools.ant.taskdefs.condition.Matches.eval (Matches.java:117)
>     at org.apache.tools.ant.taskdefs.ConditionTask.execute 
> (ConditionTask.java:120)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke 
> (NativeMethodAccessorImpl.java:62)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke 
> (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:498)
>     at org.apache.tools.ant.dispatch.DispatchUtils.execute 
> (DispatchUtils.java:106)
>     at org.apache.tools.ant.TaskAdapter.execute (TaskAdapter.java:154)
>     at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:292)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke 
> (NativeMethodAccessorImpl.java:62)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke 
> (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:498)
>     at org.apache.tools.ant.dispatch.DispatchUtils.execute 
> (DispatchUtils.java:106)
>     at org.apache.tools.ant.Task.perform (Task.java:348)
>     at org.apache.tools.ant.Target.execute (Target.java:435)
>     at org.apache.tools.ant.Target.performTasks (Target.java:456)
>     at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1393)
>     at org.apache.tools.ant.Project.executeTarget (Project.java:1364)
>     at org.apache.maven.plugin.antrun.AntRunMojo.execute (AntRunMojo.java:313)
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to