simonetallevi / maven-replacer-plugin

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

What regex syntax is used by maven-replacer-plugin? #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using Maven-replacer-plugin version is : 1.3.1 on Debian Lenny.

^ in the java syntax means: The beginning of a line. However, when using it , 
maven-replacer-plugin does nothing.

Example:

for something like:"url=abdef" When I use :

^url=.*
url=http://www.google.fr/
#nothing happens.

FYI, this one works:
\burl=.*
url=http://www.google.fr/

Thanks

Original issue reported on code.google.com by reda.abdi on 8 Aug 2010 at 1:38

GoogleCodeExporter commented 9 years ago
Either can work. However, if you wish to use ^ in Debian, you may need to 
experiment with 
<regexFlags>
    <regexFlag>UNIX_LINES</regexFlag>
</regexFlags>

in your configuration. See the [UsageGuide] for more information on this.

Original comment by baker.st...@gmail.com on 8 Aug 2010 at 10:50

GoogleCodeExporter commented 9 years ago
Hi Baker,

I just tried the UNIX_LINES flag but without success.

Here is my configuration:

<profile>
            <id>pre</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.google.code.maven-replacer-plugin</groupId>
                        <artifactId>maven-replacer-plugin</artifactId>
                        <version>1.3.1</version>
                        <executions>
                            <execution>
                                <!-- <phase>prepare-package</phase>  //Not working because of maven 2.0.9 version. Available in Maven 2.1 -->
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>replace</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <encoding>UTF-8</encoding>
                            <basedir>target/classes</basedir>
                            <filesToInclude>
                                database.properties
                            </filesToInclude>
                            <tokenValueMap>regex.conf</tokenValueMap>
                            <regexFlags>
                                <regexFlag>UNIX_LINES</regexFlag>
                            </regexFlags>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

And my regex.conf substitution file contains the following:

^db.url=.*
db.url=jdbc:mysql://localhost:3306/testDB

++

Original comment by reda.abdi on 9 Aug 2010 at 5:18

GoogleCodeExporter commented 9 years ago
Sorry for the late response.
Try out this config:

<configuration>
    <basedir>target/classes</basedir>
    <file>database.properties</file>
    <token>^db.url=.*</token>
    <value>db.url=jdbc:mysql://localhost:3306/testDB</value>
    <regexFlags>
        <regex>MULTILINE</regex>
    </regexFlags>
</configuration>

I suspect the tokenValueMap parameter has a problem with a hidden leading 
character which is being considered in the regex match.

Either don't use the option for now, or add TWO blank lines at the start of 
regex.conf (these will be considered a blank token/value pair and have no 
effect).

Original comment by baker.st...@gmail.com on 11 Aug 2010 at 12:39

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I have released a new version which I believe has fixed this bug.
Please update to version 1.3.2

Original comment by baker.st...@gmail.com on 21 Aug 2010 at 3:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Note: If your file contains multiple lines, you should add to your config:
<regexFlags>
    <regexFlag>MULTILINE</regexFlag>
</regexFlags>

Original comment by baker.st...@gmail.com on 21 Aug 2010 at 3:46

GoogleCodeExporter commented 9 years ago
Just issue clean up.

Original comment by baker.st...@gmail.com on 17 Sep 2012 at 12:42