/grep-maven-plugin

a maven plugin that greps through text files. can print the results or fail the build if [not] found etc.

Primary LanguageJavaBSD 2-Clause "Simplified" LicenseBSD-2-Clause

grep-maven-plugin

a maven plugin that greps through files and prints the results

usage example:


<build>
    <plugins>
        <plugin>
            <groupId>net.radai</groupId>
            <artifactId>grep-maven-plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
            <executions>
                <execution>
                    <goals>
                        <goal>grep</goal>
                    </goals>
                    <phase>test</phase>
                    <configuration>
                        <greps>
                            <grep>
                                <file>src/main/resources/file.txt</file>
                                <grepPattern>prop1</grepPattern>
                            </grep>
                            <grep>
                                <file>src/main/resources/archive.zip/directory/file.txt</file>
                                <grepPattern>prop1</grepPattern>
                                <outputPattern>found in file ${fileName} at line ${lineNumber} : ${line}</outputPattern>
                            </grep>
                        </greps>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

failing the build if a pattern if found/not-found:


<grep>
    <failIfFound>true</failIfFound>
    ...or...
    <failIfNotFound>true</failIfNotFound>
</grep>

to use this you will need to add the Sonatype OSS repository to your maven project:


<pluginRepositories>
   <pluginRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/groups/public</url>
   </pluginRepository>
</pluginRepositories>