mozzash / maven-replacer-plugin

Automatically exported from code.google.com/p/maven-replacer-plugin
MIT License
0 stars 0 forks source link

Patterns containing any of '^', '$', '<', '>' do not match #98

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Specify regex pattern containing any of '^', '$', '<', '>'

What is the expected output? What do you see instead?

Pattern "^.*$" should match every input line but matches no line.
Pattern "<build>" should match input "<build>" but matches nothing.

What version of the product are you using?

1.5.3

Please provide any additional information below.

There is no match regardless of whether the pattern is wrapped in a CDATA block 
or the '>' and '<' are written in escaped form.

OS: OSX
Java: 7 update 67
Maven: 3.2.1

Original issue reported on code.google.com by ralf.viv...@gmail.com on 12 Oct 2014 at 2:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Can you post all the configuration?

Also, make sure to use: <regex>true</regex> when using a token containing regex 
for matching.

Original comment by baker.st...@gmail.com on 13 Oct 2014 at 1:31

GoogleCodeExporter commented 9 years ago
I have downgraded to 1.5.2 and relative paths do work in that version.

The configuration I use is as follows. For testing I added the pattern "^.*$" 
with an empty string as replacement value, which I think should yield a file 
with empty lines. But it does not. The other patterns match, yielding some 
empty lines in the output file.

<plugin>
    <groupId>com.google.code.maven-replacer-plugin</groupId>
    <artifactId>replacer</artifactId>
    <version>1.5.2</version>
    <executions>
        <execution>
            <phase>prepare-package</phase>
            <goals>
                <goal>replace</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <file>target/feature/feature.xml</file>
        <regex>true</regex>
        <replacements>
            <replacement>
                <token>^.*$</token>
                <value></value>
            </replacement>
            <replacement>
                <!-- For whatever reason, the plugin refuses to match '<', '>', '^', and '$'. CDATA section or not. -->
                <token>.*titan-.*/${titan.version}./bundle.</token>
                <value></value>
            </replacement>
            <replacement>
                <!-- For whatever reason, the plugin refuses to match '<', '>', '^', and '$'. CDATA section or not. -->
                <token>.*camel-uldap.*/${project.version}./bundle.</token>
                <value></value>
            </replacement>
        </replacements>
    </configuration>
</plugin>

Original comment by ralf.viv...@gmail.com on 14 Oct 2014 at 2:54

GoogleCodeExporter commented 9 years ago
I have exactly the same problem.

I want to remove all spaces at each line before a tag with the following 
configuration:

            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <basedir>${project.build.directory}</basedir>
                    <filesToInclude>${project.build.finalName}/WEB-INF/views/**/*.jsp</filesToInclude>
                    <token>>\s*<</token>
                    <value>><</value>
                    <regex>true</regex>
                    <regexFlags>
                        <regexFlag>MULTILINE</regexFlag>
                    </regexFlags>
                </configuration>
            </plugin>

Doesn't work...so it's exactly the same...

Original comment by marcmust...@googlemail.com on 16 Mar 2015 at 2:09