maven-replace-plugin to replace multiple tokens in multiple input files

437 Views Asked by At

We are working with two DBs (oracle and sqlserver) and want to replace componentPrefix for both DB files. But the semicolon only on Oracle. How can we achieve it?

Here is my pom:

               <execution>
                    <id>replace-tablename-prefix-tokens</id>
                    <goals>
                        <goal>replace</goal>
                    </goals>
                    <phase>generate-resources</phase>
                    <configuration>
                        <includes>
                            <inputFilePattern>oracle/updates/*.sql</inputFilePattern>
                            <inputFilePattern>sqlserver/updates/*.sql</inputFilePattern>
                        </includes>
                        <basedir>${dbdeploy.support.unpack.dir}/db/source_scripts/</basedir>
                        <replacements>
                            <replacement>
                                <token>@componentPrefix@</token>
                                <value>${db.prefix.am.tablename}</value>
                            </replacement>
                            <replacement>
                                <token>;</token>
                                <value>/</value>
                            </replacement>
                        </replacements>
                    </configuration>
                </execution>
1

There are 1 best solutions below

2
Sergio Gragera On BEST ANSWER

Why don't you have in oracle/upcates/*.sql files already replaced the semicolon by slash?

On the other hand, you can have two executions of a plugin:

           <execution>
                <id>replace-tablename-prefix-tokens</id>
                <goals>
                    <goal>replace</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                    <includes>
                        <inputFilePattern>oracle/updates/*.sql</inputFilePattern>
                        <inputFilePattern>sqlserver/updates/*.sql</inputFilePattern>
                    </includes>
                    <basedir>${dbdeploy.support.unpack.dir}/db/source_scripts/</basedir>
                    <replacements>
                        <replacement>
                            <token>@componentPrefix@</token>
                            <value>${db.prefix.am.tablename}</value>
                        </replacement>
                    </replacements>
                </configuration>
            </execution>

           <execution>
                <id>replace-oracle</id>
                <goals>
                    <goal>replace</goal>
                </goals>
                <phase>generate-resources</phase>
                <configuration>
                    <includes>
                        <inputFilePattern>oracle/updates/*.sql</inputFilePattern>
                    </includes>
                    <basedir>${dbdeploy.support.unpack.dir}/db/source_scripts/</basedir>
                    <replacements>
                        <replacement>
                            <token>;</token>
                            <value>/</value>
                        </replacement>
                    </replacements>
                </configuration>
            </execution>